use of com.infiniteautomation.mango.rest.latest.model.modules.AngularJSModuleDefinitionGroupModel in project ma-modules-public by infiniteautomation.
the class ModulesRestController method getAngularJSModules.
public static AngularJSModuleDefinitionGroupModel getAngularJSModules(boolean developmentMode) {
AngularJSModuleDefinitionGroupModel model = new AngularJSModuleDefinitionGroupModel();
URI webUri = Common.MA_HOME_PATH.resolve(Constants.DIR_WEB).toUri();
for (AngularJSModuleDefinition def : ModuleRegistry.getAngularJSDefinitions()) {
Module module = def.getModule();
Version moduleVersion = module.getVersion();
String version = moduleVersion.toString();
String preReleaseVersion = moduleVersion.getPreReleaseVersion();
if ("SNAPSHOT".equals(preReleaseVersion)) {
Date buildDate = module.getBuildDate();
if (developmentMode) {
Path filePath = def.getAbsoluteJavaScriptPath();
try {
buildDate = new Date(Files.getLastModifiedTime(filePath).toMillis());
} catch (IOException e) {
// ignore
}
}
String preRelease = PRE_RELEASE_FORMATTER.format(buildDate.toInstant());
version = moduleVersion.setPreReleaseVersion(preRelease).toString();
}
URI uri = webUri.relativize(def.getAbsoluteJavaScriptPath().toUri());
String urlWithVersion = UriComponentsBuilder.fromUri(uri).queryParam("v", version).build().toUriString();
ModuleInfo info = new ModuleInfo();
info.setUrl(uri.toString());
info.setVersion(version);
info.setName(module.getName());
info.setUpgradedDate(module.getUpgradedDate());
model.add("/" + urlWithVersion, info);
}
return model;
}
Aggregations