Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI Updates: Bug fixes and unit labels in card

Robin Dekkersbf04ccf4a403
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index cbcc25105..000000000
--- a/build.gradle
+++ /dev/null
@@ -1,3 +0,0 @@
-allprojects {
- apply from: "${findProject(":openremote") != null ? project(":openremote").projectDir : rootDir}/project.gradle"
-}
diff --git a/project.gradle b/project.gradle
deleted file mode 100644
index bb46a88cd..000000000
--- a/project.gradle
+++ /dev/null
@@ -1,161 +0,0 @@
-// Common configuration applied to all projects
-import static org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS
-import static org.apache.tools.ant.taskdefs.condition.Os.isFamily
-
-// Build plugins
-buildscript {
- repositories {
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
-}
-
-// Give test projects more memory (Gradle 5 reduced this to 512MB)
-subprojects {
- tasks.withType(Test) {
- maxHeapSize = "2g"
- }
-}
-
-// Default repositories for dependency resolution
-repositories {
- maven {
- url = "https://repo.osgeo.org/repository/release/"
- }
- mavenCentral()
- jcenter()
- maven {
- url "https://oss.sonatype.org/content/repositories/snapshots/"
- }
- maven {
- url "http://m2repo.openremote.com/content/groups/public/"
- }
-}
-
-// Eclipse needs help
-apply plugin: "eclipse"
-
-// Intellij needs help
-apply plugin: 'idea'
-// Use the same output directories in IDE as in gradle
-idea {
- module {
- outputDir file('build/classes/main')
- testOutputDir file('build/classes/test')
- excludeDirs += file(".node")
- excludeDirs += file("node_modules")
- excludeDirs += file("dist")
- excludeDirs += file("build")
- }
-}
-
-// Helper functions for project/task resolution when the main
-// repo is checked out as a git submodule and therefore a subproject
-def isCustomProject() {
- findProject(":openremote") != null
-}
-
-def resolvePath(String path) {
- isCustomProject() ? ":openremote" + path : path
-}
-
-def resolveProject(String path) {
- project(resolvePath(path))
-}
-
-def resolveTask(String path) {
- tasks.getByPath(resolvePath(path))
-}
-
-ext {
- resolvePath = this.&resolvePath
- resolveProject = this.&resolveProject
- resolveTask = this.&resolveTask
- isCustomProject = this.&isCustomProject
-}
-
-if (project.convention.findPlugin(JavaPluginConvention)) {
- // Change the output directory for the main and test source sets back to the old path
- sourceSets.main.java.outputDir = new File(buildDir, "classes/main")
- sourceSets.test.java.outputDir = new File(buildDir, "classes/test")
-}
-
-// Configure versions in gradle.properties (putting a gradle.properties file
-// in a subproject only overrides root properties of same name for the actual
-// subproject, not for its children!)
-version = hasProperty("openremoteVersion") ? openremoteVersion : projectVersion
-
-// Add UI tasks
-ext.npmCommand = {
- cmd ->
- isFamily(FAMILY_WINDOWS) ? "${cmd}.cmd" : cmd
-}
-
-// Add yarn tasks
-task yarnInstall(type: Exec){
- commandLine npmCommand("yarn"), "install"
-}
-task yarnInstallForce(type: Exec){
- commandLine npmCommand("yarn"), "install", "--force"
-}
-
-// Add npm tasks
-task npmInstall(type: Exec){
- commandLine npmCommand("npm"), "install"
-}
-task npmClean(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "run-script", "clean"
-}
-task npmBuild(type: Exec){
- mustRunAfter npmClean
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "run-script", "build"
-}
-task npmTest(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "run-script", "test"
-}
-task npmServe(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "run-script", "serve"
-}
-task npmPrepare(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "run-script", "prepublishOnly"
-}
-task npmPublish(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "publish"
-}
-task npmServeProduction(type: Exec){
- dependsOn tasks.getByPath(":yarnInstall")
- commandLine npmCommand("npm"), "run-script", "serveProduction"
-}
-
-// Add typescript tasks
-task tscWatch(type: Exec) {
- commandLine npmCommand("npx"), "tsc", "-b", "--watch"
-}
-
-// Configure Java build
-plugins.withType(JavaPlugin).whenPluginAdded {
-
- // Use Java 8
- tasks.withType(JavaCompile) {
- sourceCompatibility = "1.8"
- targetCompatibility = "1.8"
- def warnLogFile = file("$buildDir/${name}Warnings.log")
- logging.addStandardErrorListener(new StandardOutputListener() {
- void onOutput(CharSequence output) {
- warnLogFile << output
- }
- })
- options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
- options.encoding = 'UTF-8'
- }
-
- // JAR/ZIP base name is the fully qualified subproject name
- archivesBaseName = "${rootProject.name}${path.replaceAll(":", "-")}"
-}
\ No newline at end of file
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.ts
index aa9295cdb..99241c58f 100644
--- a/ui/component/core/src/util.ts
+++ b/ui/component/core/src/util.ts
@@ -461,7 +461,23 @@ export function loadJs(url: string) {
document.body.appendChild(script);
});
};
+export function sortByNumber<T>(valueExtractor: (item: T) => number): (a: T, b: T) => number {
+ return (a,b) => {
+ const v1 = valueExtractor(a);
+ const v2 = valueExtractor(b);
+ if (!v1 && !v2) {
+ return 0;
+ }
+ if (v1 && !v2) {
+ return 1;
+ }
+ if (!v1 && v2) {
+ return -1;
+ }
+ return v1 - v2;
+ };
+}
export function sortByString<T>(valueExtractor: (item: T) => string): (a: T, b: T) => number {
return (a,b) => {
const v1 = valueExtractor(a);
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 416e78995..3849e8286 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -699,7 +699,12 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
}
protected _getSortFunction(): (a: UiAssetTreeNode, b: UiAssetTreeNode) => number {
- return Util.sortByString((node: UiAssetTreeNode) => (node.asset as any)![this.sortBy!]);
+ switch (this.sortBy) {
+ case "createdOn":
+ return Util.sortByNumber((node: UiAssetTreeNode) => (node.asset as any)![this.sortBy!]);
+ default:
+ return Util.sortByString((node: UiAssetTreeNode) => (node.asset as any)![this.sortBy!]);
+ }
}
protected _loadAssets() {
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 1f1d86456..66181e43d 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -766,8 +766,10 @@ export class OrAttributeCard extends LitElement {
const roundedVal = +value.toFixed(this.mainValueDecimals); // + operator prevents str return
const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(this.attributeName!);
- const unitKey = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor);
- const unit = i18next.t("units." + unitKey);
+ const attributeValueDescriptor = attributeDescriptor && attributeDescriptor.valueDescriptor ? typeof attributeDescriptor.valueDescriptor === "string" ? AssetModelUtil.getAttributeValueDescriptor(attributeDescriptor.valueDescriptor as string) : attributeDescriptor.valueDescriptor : attr ? AssetModelUtil.getAttributeValueDescriptor(attr.type as string) : undefined;
+ const unitKey = Util.getMetaValue(MetaItemType.UNIT_TYPE, attr, attributeDescriptor, attributeValueDescriptor)
+
+ const unit = i18next.t(["units." + unitKey, unitKey])
this.setMainValueSize(roundedVal.toString());
diff --git a/ui/component/or-rules/src/flow-viewer/services/project.ts b/ui/component/or-rules/src/flow-viewer/services/project.ts
index fc654b542..c9a9ca6a4 100644
--- a/ui/component/or-rules/src/flow-viewer/services/project.ts
+++ b/ui/component/or-rules/src/flow-viewer/services/project.ts
@@ -81,7 +81,7 @@ export class Project extends EventEmitter {
collection.nodes!.forEach((node) => {
this.addNode(node);
});
- await this.workspace.updateComplete;
+ if(this.workspace) await this.workspace.updateComplete;
collection.connections!.forEach((conn) => {
this.createConnection(conn.from!, conn.to!);
});
diff --git a/ui/component/or-rules/src/or-rule-list.ts b/ui/component/or-rules/src/or-rule-list.ts
index 378984c20..a0e282749 100644
--- a/ui/component/or-rules/src/or-rule-list.ts
+++ b/ui/component/or-rules/src/or-rule-list.ts
@@ -569,7 +569,12 @@ export class OrRuleList extends translate(i18next)(LitElement) {
}
protected _getSortFunction(): (a: RulesetNode, b: RulesetNode) => number {
- return Util.sortByString((node: RulesetNode) => (node.ruleset as any)![this.sortBy!]);
+ switch (this.sortBy) {
+ case "createdOn":
+ return Util.sortByNumber((node: RulesetNode) => (node.ruleset as any)![this.sortBy!]);
+ default:
+ return Util.sortByString((node: RulesetNode) => (node.ruleset as any)![this.sortBy!]);
+ }
}
protected _getRealm(): string | undefined {
diff --git a/ui/component/or-rules/src/or-rule-viewer.ts b/ui/component/or-rules/src/or-rule-viewer.ts
index ac3942eea..fb55c3d4b 100644
--- a/ui/component/or-rules/src/or-rule-viewer.ts
+++ b/ui/component/or-rules/src/or-rule-viewer.ts
@@ -55,7 +55,7 @@ export const style = css`
box-sizing: border-box;
min-height: var(--internal-or-rules-header-height);
height: var(--internal-or-rules-header-height);
- z-index: 9;
+ z-index: 7;
padding: 15px 20px;
--or-icon-fill: var(--internal-or-rules-panel-color);
}