use of org.motechproject.server.web.dto.ModuleConfig in project motech by motech.
the class ModuleController method restDocConfig.
private ModuleConfig restDocConfig() {
ModuleConfig config = new ModuleConfig();
config.setName("rest-docs");
config.setTemplate("../server/resources/partials/rest-docs-index.html");
config.setScript("../server/resources/rest-docs/rest-docs-app.js");
return config;
}
use of org.motechproject.server.web.dto.ModuleConfig in project motech by motech.
the class ModuleController method addConfig.
private void addConfig(List<ModuleConfig> configuration, String name, String script, String template, String css) {
ModuleConfig config = new ModuleConfig();
config.setName(name);
config.setScript(script);
config.setTemplate(template);
config.setCss(css);
if (isNotBlank(name)) {
if (containsConfig(configuration, name)) {
throw new IllegalStateException("The angular module name have to be unique");
}
configuration.add(config);
}
}
use of org.motechproject.server.web.dto.ModuleConfig in project motech by motech.
the class ModuleController method getConfig.
@RequestMapping(value = "/module/config", method = RequestMethod.GET)
@ResponseBody
public List<ModuleConfig> getConfig() throws IOException {
List<ModuleConfig> configuration = new ArrayList<>();
for (Bundle bundle : bundleContext.getBundles()) {
ModuleRegistrationData data = uiFrameworkService.getModuleDataByBundle(bundle);
if (null != data) {
Map<String, String> scripts = findScripts(bundle);
for (Map.Entry<String, String> script : scripts.entrySet()) {
addConfig(configuration, script.getKey(), getPath(data, script.getValue()));
}
List<String> angularModules = data.getAngularModules();
String name = isEmpty(angularModules) ? null : angularModules.get(0);
List<URL> css = filterByClass(URL.class, bundle.findEntries("/webapp/css/", "*.css", true));
String cssPath = null;
if (!css.isEmpty() && !bundle.getSymbolicName().equalsIgnoreCase("org.motechproject.motech-platform-server-bundle")) {
cssPath = getPath(data, getCSSPath(css.get(0)));
}
addConfig(configuration, name, getPath(data, "/js/app.js"), data.getUrl(), cssPath);
}
}
// rest documentation han an Angular module within server-bundle
configuration.add(restDocConfig());
return configuration;
}
Aggregations