100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Enhance rule list nodes with icon showing rule status (#886)
DonWillems4f5e8316298c
diff --git a/manager/src/web/shared/locales/en/or.json b/manager/src/web/shared/locales/en/or.jsonindex e67ba9be9..20ee6b8e4 100644--- a/manager/src/web/shared/locales/en/or.json+++ b/manager/src/web/shared/locales/en/or.json@@ -515,6 +515,17 @@},"realmDeleteConfirm": "Warning! this will delete everything in this realm, type the realm name '{{realmName}}' to confirm.","realmDeleteFailed": "Failed to delete realm",+ "rulesetStatus": {+ "DEPLOYED": "Successfully deployed",+ "NOSTATUS": "Disabled",+ "LOOP_ERROR": "Loop error",+ "COMPILATION_ERROR": "Compilation error",+ "EXECUTION_ERROR": "Execution error",+ "EXPIRED": "Validity period over",+ "PAUSED": "Paused until in validity period",+ "REMOVED": "Removed",+ "READY": "Ready; waiting error resolution"+ },"public": "Public","shared": "Shared","private": "Private",diff --git a/manager/src/web/shared/locales/nl/or.json b/manager/src/web/shared/locales/nl/or.jsonindex 8fad3f409..fca8d72a9 100644--- a/manager/src/web/shared/locales/nl/or.json+++ b/manager/src/web/shared/locales/nl/or.json@@ -120,6 +120,7 @@"noAssetTypeSelected": "Kies een asset type uit de lijst aan de linkerkant","loading": "Aan het laden...","noAssetsFound": "Geen assets gevonden",+ "filterInvite": "Filter met minsters 3 karakters","location": "Locatie","longPressSetLoc": "Druk lang op de kaart om locatie in te stellen","hour": "Uur",@@ -164,6 +165,7 @@"noRuleStateAttributes": "Geen attributen met 'rule state' of 'agent link' configuratie item gevonden","noDatapointsAttributes": "Geen attributen met 'store data points' of 'agent link' configuratie item gevonden","noAttributesToShow": "Geen attributen gevonden",+ "noAttributesConnected": "Geen attributen verbonden","noDatapointsOrRuleStateAttributes": "Geen attributen met 'rule state', 'store data points', of 'agent link' configuratie item gevonden","copy": "Kopiëren","paste": "Plakken",@@ -442,8 +444,7 @@"dismiss": "sluiten","createAssetFailed": "Asset aanmaken is niet gelukt","moveAssetFailed": "Failed to move asset",- "logCategory": {- },+ "logCategory": {},"readPermissions": "Leesrechten","writePermissions": "Schrijfrechten","valueType": "Waarde type",@@ -500,6 +501,7 @@"invalidEmail": "Ongeldig emailadres","yes": "Ja","no": "Nee",+ "linked": "Gelinkt","filter": {"filter": "Filter","clear": "LEEGMAKEN",@@ -511,6 +513,19 @@"attributeValueLabel": "Attribuutwaarde","assetTypeDoesNotExist": "Filter: Asset type bestaat niet"},+ "realmDeleteConfirm": "Let op! Hiermee verwijder je alles in deze realm, typ de realm naam '{{realmName}}' om te bevestigen.",+ "realmDeleteFailed": "Realm verwijderen mislukt",+ "rulesetStatus": {+ "DEPLOYED": "Succesvol aangemaakt",+ "NOSTATUS": "Uitgeschakeld",+ "LOOP_ERROR": "Loop fout",+ "COMPILATION_ERROR": "Compilatiefout",+ "EXECUTION_ERROR": "Uitvoeringsfout",+ "EXPIRED": "Geldigheidsperiode in het verleden",+ "PAUSED": "Geldigheidsperiode in de toekomst",+ "REMOVED": "Verwijderd",+ "READY": "In afwachting van fout oplossing"+ },"public": "Openbaar","shared": "Gedeeld","private": "Prive",diff --git a/ui/component/or-rules/src/index.ts b/ui/component/or-rules/src/index.tsindex 6bbcacc9b..96722ecaf 100644--- a/ui/component/or-rules/src/index.ts+++ b/ui/component/or-rules/src/index.ts@@ -683,9 +683,12 @@ export const style = css`--internal-or-rules-list-text-size: var(--or-rules-list-text-size, 15px);--internal-or-rules-list-header-height: var(--or-rules-list-header-height, 48px);+ --internal-or-rules-list-icon-color-error: var(--or-rules-list-icon-color-error, var(--or-app-color6, ${unsafeCSS(DefaultColor6)}));+ --internal-or-rules-list-icon-color-ok: var(--or-rules-list-icon-color-ok, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));+--internal-or-rules-list-button-size: var(--or-rules-list-button-size, 24px);- --internal-or-rules-header-background-color: var(--or-rules-header-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));+ --internal-or-rules-header-background-color: var(--or-rules-header-background-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));--internal-or-rules-header-height: var(--or-rules-header-height, unset);--or-panel-background-color: var(--internal-or-rules-panel-color);diff --git a/ui/component/or-rules/src/or-rule-list.ts b/ui/component/or-rules/src/or-rule-list.tsindex 4380a267f..f7d49917c 100644--- a/ui/component/or-rules/src/or-rule-list.ts+++ b/ui/component/or-rules/src/or-rule-list.ts@@ -57,6 +57,7 @@ const style = css`height: var(--internal-or-asset-tree-header-height);line-height: var(--internal-or-asset-tree-header-height);color: var(--internal-or-asset-tree-header-text-color);+ background-color: var(--internal-or-rules-header-background-color);}#header-btns {@@ -68,11 +69,8 @@ const style = css`}.node-status {- width: 10px;- height: 10px;- border-radius: 5px;- margin-right: 10px;- display: none;+ --or-icon-width: 18px;+ margin-right: 8px;}.node-language{@@ -80,20 +78,12 @@ const style = css`opacity: 50%;}- .bg-green {- background-color: #28b328;+ .iconfill-gray {+ --or-icon-fill: var(--internal-or-rules-list-icon-color-ok);}- .bg-red {- background-color: red;- }-- .bg-blue {- background-color: #3e92dc;- }-- .bg-grey {- background-color: #b7b7b7;+ .iconfill-red {+ --or-icon-fill: var(--internal-or-rules-list-icon-color-error);}`;@@ -230,7 +220,7 @@ export class OrRuleList extends translate(i18next)(LitElement) {}const allowedLanguages = this._allowedLanguages;- const sortOptions = ["name", "createdOn"]+ const sortOptions = ["name", "createdOn", "status"]if (allowedLanguages && allowedLanguages.length > 1) sortOptions.push("lang")let addTemplate: TemplateResult | string = ``;@@ -305,11 +295,75 @@ export class OrRuleList extends translate(i18next)(LitElement) {}protected _nodeTemplate(node: RulesetNode): TemplateResult | string {++ let statusIcon: string = "help";+ let statusClass: string = "iconfill-gray";+ let nodeIcon: string = "mdi-state-machine";+ let nodeTitle: string = "Unknown language";+ switch (node.ruleset.status){+ case "DEPLOYED":+ statusIcon = "";+ statusClass = "iconfill-gray";+ break;+ case "READY":+ statusIcon = "check";+ statusClass = "iconfill-gray";+ break;+ case "COMPILATION_ERROR":+ case "LOOP_ERROR":+ case "EXECUTION_ERROR":+ statusIcon = "alert-octagon";+ statusClass = "iconfill-red";+ break;+ case "DISABLED":+ statusIcon = "minus-circle";+ statusClass = "iconfill-gray";+ break;+ case "PAUSED":+ statusIcon = "calendar-arrow-right";+ statusClass = "iconfill-gray";+ break;+ case "EXPIRED":+ statusIcon = "calendar-remove";+ statusClass = "iconfill-gray";+ break;+ case "REMOVED":+ statusIcon = "close";+ statusClass = "iconfill-gray";+ break;+ default:+ statusIcon = "stop";+ statusClass = "iconfill-gray";+ }++ switch (node.ruleset.lang) {+ case (RulesetLang.JSON):+ nodeIcon = "ray-start-arrow";+ nodeTitle = "When-Then";+ break;+ case (RulesetLang.FLOW):+ nodeIcon = "transit-connection-variant";+ nodeTitle = "Flow";+ break;+ case (RulesetLang.GROOVY):+ nodeIcon = "alpha-g-box-outline";+ nodeTitle = "Groovy";+ break;+ case (RulesetLang.JAVASCRIPT):+ nodeIcon = "language-javascript";+ nodeTitle = "JavaScript";+ break;+ default:+ nodeIcon = "mdi-state-machine";+ nodeTitle = "Unknown language";+ }+return html`<li ?data-selected="${node.selected}" @click="${(evt: MouseEvent) => this._onNodeClicked(evt, node)}"><div class="node-container">- <span class="node-status ${OrRuleList._getNodeStatusClasses(node.ruleset)}"></span>- <span class="node-name">${node.ruleset.name}<span class="node-language">${node.ruleset.lang !== RulesetLang.JSON ? node.ruleset.lang : ""}</span></span>+ <or-icon style="--or-icon-width: 18px; margin-right: 8px;" icon="${nodeIcon}" title="${i18next.t(nodeTitle)}"></or-icon>+ <span class="node-name">${node.ruleset.name}</span>+ <or-icon class="node-status ${statusClass}" title="${i18next.t("rulesetStatus." + (node.ruleset.status ? node.ruleset.status : "NOSTATUS"))}" icon="${statusIcon}"></or-icon></div></li>`;@@ -566,6 +620,8 @@ export class OrRuleList extends translate(i18next)(LitElement) {switch (this.sortBy) {case "createdOn":return Util.sortByNumber((node: RulesetNode) => (node.ruleset as any)![this.sortBy!]);+ case "status":+ return Util.sortByString((node: RulesetNode) => (node.ruleset as any)![this.sortBy!]);default:return Util.sortByString((node: RulesetNode) => (node.ruleset as any)![this.sortBy!]);}diff --git a/ui/component/or-rules/src/or-rule-viewer.ts b/ui/component/or-rules/src/or-rule-viewer.tsindex d542d64f0..b0cb86e40 100644--- a/ui/component/or-rules/src/or-rule-viewer.ts+++ b/ui/component/or-rules/src/or-rule-viewer.ts@@ -168,7 +168,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {<or-mwc-input id="rule-name" outlined .type="${InputType.TEXT}" .label="${i18next.t("ruleName")}" ?focused="${this._focusName}" .value="${this.ruleset ? this.ruleset.name : null}" ?disabled="${this._isReadonly()}" required minlength="3" maxlength="255" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._changeName(e.detail.value)}"></or-mwc-input><or-rule-validity id="rule-header-validity" .ruleset="${this.ruleset}"></or-rule-validity><div id="rule-header-controls">-+ <span id="rule-status" title="${this.ruleset.error}">${this.ruleset.status == ("LOOP_ERROR" || "COMPILATION_ERROR" || "EXECUTION_ERROR") ? this.ruleset.status : ""}</span><span id="active-wrapper"><or-translate value="enabled"></or-translate><or-mwc-input .type="${InputType.SWITCH}" .value="${this.ruleset && this.ruleset.enabled}" ?disabled="${!this.ruleset.id}" @or-mwc-input-changed="${this._toggleEnabled}"></or-mwc-input>