Skip to content

armgit / core

Public Imported from GitHub
0

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

Style updates

robindekkers4009f630b076
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index 4f0459a02..800a94a3c 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -11,7 +11,7 @@ class OrInput extends LitElement {
name: string = '';
@property({type: String})
- value: string = '';
+ public value: string = "";
static get styles() {
@@ -23,14 +23,13 @@ class OrInput extends LitElement {
protected render() {
return html`
- <input id="or-input" type="${this.type}" name="${this.name}" @change="${this.onChange}" value="${this.value}" />
+ <input class="or-input" type="${this.type}" name="${this.name}" @change="${this.onChange}" .value="${this.value}" />
`;
}
-
onChange() {
if(this.shadowRoot){
- const input = (<HTMLInputElement>this.shadowRoot.getElementById('or-input'));
+ const input = (<HTMLInputElement> this.shadowRoot.querySelector('.or-input'));
const value = input.value;
const name = input.name;
@@ -44,7 +43,6 @@ class OrInput extends LitElement {
}
}
-
constructor() {
super();
}
diff --git a/ui/component/or-input/src/style.ts b/ui/component/or-input/src/style.ts
index f1819d9ed..1f206e261 100644
--- a/ui/component/or-input/src/style.ts
+++ b/ui/component/or-input/src/style.ts
@@ -6,10 +6,12 @@ export const orInputStyle = css`
input {
position: relative;
font-family: inherit;
- background-color: transparent;
padding: 10px;
border-radius: 0;
border: none;
font-size: 14px;
+
+ border-bottom: 2px solid #d5d5d5;
+ background-color: #f2f2f2;
}
`;
\ No newline at end of file
diff --git a/ui/component/or-rules-editor/package.json b/ui/component/or-rules-editor/package.json
index 55e24c10d..4488a1e6e 100644
--- a/ui/component/or-rules-editor/package.json
+++ b/ui/component/or-rules-editor/package.json
@@ -12,6 +12,7 @@
"license": "AGPL-3.0-or-later",
"dependencies": {
"@openremote/core": "^1.0.0",
+ "@openremote/model": "^1.0.1",
"@openremote/or-input": "^1.0.0",
"@openremote/or-select": "^1.0.0",
"@openremote/rest": "^1.0.0",
diff --git a/ui/component/or-rules-editor/src/const/attribute-descriptors.ts b/ui/component/or-rules-editor/src/const/attribute-descriptors.ts
index b4270c898..731bfef33 100644
--- a/ui/component/or-rules-editor/src/const/attribute-descriptors.ts
+++ b/ui/component/or-rules-editor/src/const/attribute-descriptors.ts
@@ -4,21 +4,21 @@ import {
} from "@openremote/model";
export const attributeDescriptors: any[] = [ {
- name: "flightProfiles",
+ attributeName: "flightProfiles",
attributeValueDescriptor : {
icon : "cubes",
valueType : "OBJECT",
name: "OBJECT"
}
}, {
- name: "languageCodes",
+ attributeName: "languageCodes",
attributeValueDescriptor : {
icon : "ellipsis-h",
valueType : "ARRAY",
name: "ARRAY"
}
}, {
- name: "flightName",
+ attributeName: "flightName",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -26,7 +26,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "flightDirection",
+ attributeName: "flightDirection",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -34,7 +34,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "airlineIata",
+ attributeName: "airlineIata",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -42,7 +42,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "scheduleDate",
+ attributeName: "scheduleDate",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -50,7 +50,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "scheduleTime",
+ attributeName: "scheduleTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -58,7 +58,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "scheduledInBlockTime",
+ attributeName: "scheduledInBlockTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -66,7 +66,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "estimatedLandingTime",
+ attributeName: "estimatedLandingTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -74,7 +74,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "actualLandingTime",
+ attributeName: "actualLandingTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -82,7 +82,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "estimatedPierTime",
+ attributeName: "estimatedPierTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -90,7 +90,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "estimatedCheckPointTime",
+ attributeName: "estimatedCheckPointTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -98,7 +98,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "estimatedSchengenCheckPointTime",
+ attributeName: "estimatedSchengenCheckPointTime",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -106,7 +106,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "terminal",
+ attributeName: "terminal",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -114,7 +114,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "gate",
+ attributeName: "gate",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -122,7 +122,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "gateNumber",
+ attributeName: "gateNumber",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "hashtag",
@@ -130,7 +130,7 @@ export const attributeDescriptors: any[] = [ {
name: "NUMBER"
}
}, {
- name: "pier",
+ attributeName: "pier",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -138,7 +138,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "checkPoint",
+ attributeName: "checkPoint",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -146,7 +146,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "pierDisplayName",
+ attributeName: "pierDisplayName",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -154,7 +154,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "passengerCapacity",
+ attributeName: "passengerCapacity",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "hashtag",
@@ -162,7 +162,7 @@ export const attributeDescriptors: any[] = [ {
name: "NUMBER"
}
}, {
- name: "passengerArrivalCheckPoint",
+ attributeName: "passengerArrivalCheckPoint",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "hashtag",
@@ -170,7 +170,7 @@ export const attributeDescriptors: any[] = [ {
name: "NUMBER"
}
}, {
- name: "passengerSchengenCheckPoint",
+ attributeName: "passengerSchengenCheckPoint",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "hashtag",
@@ -178,7 +178,7 @@ export const attributeDescriptors: any[] = [ {
name: "NUMBER"
}
}, {
- name: "airportName",
+ attributeName: "airportName",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -186,7 +186,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "airportIata",
+ attributeName: "airportIata",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -194,7 +194,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "city",
+ attributeName: "city",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -202,7 +202,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "countryCode",
+ attributeName: "countryCode",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
@@ -210,7 +210,7 @@ export const attributeDescriptors: any[] = [ {
name: "STRING"
}
}, {
- name: "originRegion",
+ attributeName: "originRegion",
metaItemDescriptors : [ ],
valueDescriptor : {
icon : "file-text-o",
diff --git a/ui/component/or-rules-editor/src/index.ts b/ui/component/or-rules-editor/src/index.ts
index 96c579325..5e22e6c3d 100644
--- a/ui/component/or-rules-editor/src/index.ts
+++ b/ui/component/or-rules-editor/src/index.ts
@@ -1,4 +1,4 @@
-import {customElement, html, LitElement, property, TemplateResult} from "lit-element";
+import {customElement, html, LitElement, property, TemplateResult, PropertyValues} from "lit-element";
import "@openremote/or-select";
import "@openremote/or-icon";
@@ -71,10 +71,14 @@ class OrRulesEditor extends LitElement {
@property({type: Object})
private rule?: Rule;
+ @property({type: Boolean})
+ private isValidRule?: boolean;
+
constructor() {
super();
this.readRules();
+ this.addEventListener("rules:validated", this.validatedRule);
this.addEventListener("rules:set-active-rule", this.setActiveRule);
this.addEventListener("rules:write-rule", this.writeRule);
this.addEventListener("rules:create-rule", this.createRule);
@@ -96,14 +100,20 @@ class OrRulesEditor extends LitElement {
</side-menu>
${this.ruleset ? html`
<or-body>
- <or-rule-header class="bg-white shadow" .ruleset="${this.ruleset}" .rule="${this.rule}"></or-rule-header>
-
+
${this.rule ? html`
+ <or-rule-header class="bg-white shadow" .ruleset="${this.ruleset}" .rule="${this.rule}" ?valid="${this.isValidRule}"></or-rule-header>
+
<div class="content">
<or-rule-when .rule="${this.rule}" .attributeDescriptors="${attributeDescriptors}"></or-rule-when>
<or-rule-then .rule="${this.rule}" .attributeDescriptors="${attributeDescriptors}"></or-rule-then>
</div>
- ` : ``}
+ ` : `
+ <div class="content layout vertical center-center">
+ <h3>Kies links een profiel of maakt een nieuw profiel aan.</h3>
+ <button @click="${this.createRule}">profiel aanmaken</button>
+ </div>
+ `}
</or-body>
` : html``}
@@ -111,6 +121,10 @@ class OrRulesEditor extends LitElement {
`;
}
+ private validatedRule(e: any) {
+ this.isValidRule = e.detail.isValidRule;
+ }
+
private readRules() {
rest.api.RulesResource.getTenantRulesets(openremote.config.realm, {
language: RulesetLang.JSON,
@@ -146,7 +160,7 @@ class OrRulesEditor extends LitElement {
}
if (this.rulesets) {
- const newRule = rulesetTemplate;
+ const newRule = {...rulesetTemplate};
this.rulesets = [...this.rulesets, rulesetTemplate];
this.ruleset = newRule;
this.computeRuleset();
@@ -205,7 +219,12 @@ class OrRulesEditor extends LitElement {
private cleanRule() {
if (this.rulesets && this.ruleset) {
const index = findIndex(this.rulesets, ["id", this.ruleset.id]);
- this.rulesets.splice(index, 1);
+ if (index) {
+ this.rulesets.splice(index, 1);
+ } else {
+ this.rulesets.splice(this.rulesets.length - 1, 1);
+ }
+
this.rulesets = [...this.rulesets];
this.ruleset = undefined;
this.rule = undefined;
@@ -217,7 +236,7 @@ class OrRulesEditor extends LitElement {
if (this.ruleset && this.ruleset.rules) {
this.rule = JSON.parse(this.ruleset.rules).rules[0];
} else if (this.ruleset && !this.ruleset.rules) {
- this.rule = ruleTemplate;
+ this.rule = {...ruleTemplate};
this.rule.name = this.ruleset.name;
}
this.requestUpdate();
diff --git a/ui/component/or-rules-editor/src/or-rule-header/index.ts b/ui/component/or-rules-editor/src/or-rule-header/index.ts
index 304955930..794b70004 100644
--- a/ui/component/or-rules-editor/src/or-rule-header/index.ts
+++ b/ui/component/or-rules-editor/src/or-rule-header/index.ts
@@ -1,26 +1,29 @@
-import {html, LitElement, property, customElement} from 'lit-element';
+import {html, LitElement, property, customElement, PropertyValues} from 'lit-element';
import '../selects/or-select-operator';
import '../selects/or-select-asset-attribute';
import '@openremote/or-input';
import '@openremote/or-select';
import '@openremote/or-icon';
-import {TenantRuleset} from '@openremote/model';
+import {TenantRuleset, Rule} from '@openremote/model';
import {style} from './style';
@customElement('or-rule-header')
class OrRuleHeader extends LitElement {
@property({type: Object})
- ruleset?: TenantRuleset;
+ public ruleset?: TenantRuleset;
+
+ @property({type: Object})
+ public rule?: Rule;
@property({type: Boolean})
- editmode: boolean = false;
+ public valid: boolean = false;
static get styles() {
return [
style
- ]
+ ];
}
protected render() {
@@ -29,21 +32,20 @@ class OrRuleHeader extends LitElement {
<div class="rule-container">
<div class="layout horizontal">
- ${this.editmode ? html`
- <or-input type="text" value="${this.ruleset ? this.ruleset.name : null}"></or-input>
- ` : html`
- <h1>${this.ruleset ? this.ruleset.name : ''}</h1>
- `}
-
- <span @click="${this.toggleEditmode}"><or-icon style="margin:10px;" icon="pencil-outline"></or-icon></span>
- <span class="rule-status ${this.ruleset && this.ruleset.enabled ? 'bg-green' : 'bg-red'}"></span>
- <button class="button-simple" @click="${this.toggleEnabled}">${this.ruleset!.enabled ? 'deactiveren' : 'publiceren'}</button>
+ <input @change="${this.changeName}" type="text" .value="${this.ruleset ? this.ruleset.name : null}" />
- ${this.ruleset && this.ruleset.id ? html`
- <button @click="${this.updateRule}">opslaan</button>
- ` : html`
- <button @click="${this.createRule}">toevoegen</button>
- `}
+ <div class="layout horizontal" style="margin-left: auto;">
+ <span style="margin: 9px 0;">Actief</span>
+ <label class="switch" ?data-disabled="${!this.ruleset!.id}">
+ <input @change="${this.toggleEnabled}" ?disabled="${!this.ruleset!.id}" ?checked="${this.ruleset!.enabled}" type="checkbox">
+ <span class="slider round"></span>
+ </label>
+ ${this.ruleset && this.ruleset.id ? html`
+ <button ?disabled="${!this.valid}" @click="${this.updateRule}">opslaan</button>
+ ` : html`
+ <button ?disabled="${!this.valid}" @click="${this.createRule}">opslaan</button>
+ `}
+ </div>
</div>
</div>
@@ -52,12 +54,11 @@ class OrRuleHeader extends LitElement {
constructor() {
super();
- this.addEventListener('or-input:changed', this.changeName);
}
- changeName (e:any) {
- const value = e.detail.value;
- if(this.ruleset) {
+ changeName(e:any) {
+ const value = e.target.value;
+ if (this.ruleset) {
this.ruleset.name = value;
}
}
@@ -89,9 +90,5 @@ class OrRuleHeader extends LitElement {
}
}
- toggleEditmode() {
- this.editmode = !this.editmode;
- }
-
}
diff --git a/ui/component/or-rules-editor/src/or-rule-header/style.ts b/ui/component/or-rules-editor/src/or-rule-header/style.ts
index 76f7691a9..f39597681 100644
--- a/ui/component/or-rules-editor/src/or-rule-header/style.ts
+++ b/ui/component/or-rules-editor/src/or-rule-header/style.ts
@@ -8,26 +8,35 @@ export const style = css`
z-index: 1;
}
-
+
.rule-container {
padding: 20px;
}
-
+
.layout.horizontal {
display: flex;
flex-direction: row;
}
-
- h1 {
- margin: 0;
+
+ input {
+ font-size: 18px;
+ font-weight: bold;
+ border: none;
+ background-color: transparent;
+ border-bottom: 2px solid transparent;
+
+ transition: all 150ms ease-in;
}
-
+
+ input:hover {
+ border-bottom: 2px solid #d5d5d5;
+ }
+
button {
-
padding: 0 20px;
font-size: 14px;
height: 40px;
-
+
border-radius: 5px;
background-color: var(--app-primary-color);
margin-left: auto;
@@ -36,29 +45,86 @@ export const style = css`
cursor: pointer;
}
+ button[disabled] {
+ background-color: #e4e4e4;
+ }
+
.button-simple {
- margin-left: 10px;
border: none;
color: var(--app-primary-color);
background-color: var(--app-white-color);
}
or-input {
- padding: 10px;
+ padding: 10px;
}
-
- .rule-status {
- width: 8px;
- height: 8px;
- border-radius: 8px;
- margin: 15px
+
+
+ /* The switch - the box around the slider */
+ .switch {
+ position: relative;
+ display: inline-block;
+ width: 36px;
+ height: 14px;
+ margin: 13px 20px
}
-
- .bg-green {
- background-color: green;
+
+ /* Hide default HTML checkbox */
+ .switch input {
+ opacity: 0;
+ width: 0;
+ height: 0;
}
-
- .bg-red {
- background-color: red
+
+ /* The slider */
+ .slider {
+ position: absolute;
+ cursor: pointer;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: #ccc;
+ -webkit-transition: .4s;
+ transition: .4s;
+ }
+
+ .switch[data-disabled] .slider::before {
+ background-color: #e4e4e4;
+ }
+
+ .slider:before {
+ position: absolute;
+ content: "";
+ height: 20px;
+ width: 20px;
+ left: 0;
+ top: -3px;
+ background-color: white;
+ -webkit-transition: .4s;
+ transition: .4s;
+ box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);
+ }
+
+ input:checked + .slider:before {
+ background-color: var(--app-primary-color);
+ }
+
+ input:focus + .slider {
+ }
+
+ input:checked + .slider:before {
+ -webkit-transform: translateX(20px);
+ -ms-transform: translateX(20px);
+ transform: translateX(20px);
+ }
+
+ /* Rounded sliders */
+ .slider.round {
+ border-radius: 34px;
+ }
+
+ .slider.round:before {
+ border-radius: 50%;
}
`;
\ No newline at end of file
diff --git a/ui/component/or-rules-editor/src/or-rule-list/index.ts b/ui/component/or-rules-editor/src/or-rule-list/index.ts
index 9aea645da..0090ddde6 100644
--- a/ui/component/or-rules-editor/src/or-rule-list/index.ts
+++ b/ui/component/or-rules-editor/src/or-rule-list/index.ts
@@ -34,17 +34,24 @@ class OrRulesList extends LitElement {
.list-item {
text-decoration: none;
height: 24px;
- padding: 20px 0;
- border-bottom: 1px solid var(--app-lightgrey-color);
+ font-size: 15px;
+ padding: 17px 0;
border-left: 5px solid transparent;
color: var(--app-grey-color);
cursor: pointer;
+
+ transition: all 300ms ease-in;
}
.list-item[selected],
- .list-item:hover {
+ .list-item:hover {
border-left-color: var(--app-primary-color);
- background-color: var(--app-lightgrey-color);
+ background-color: #f7f7f7;
+ color: #000000;
+ }
+
+ .list-item:hover {
+ opacity: 0.77;
}
.list-item > span {
@@ -69,13 +76,13 @@ class OrRulesList extends LitElement {
<div class="list-container">
${this.rulesets && this.rulesets.map((ruleset: TenantRuleset, index:number) => {
return html`
- <a ?selected="${this.ruleset && ruleset.id === this.ruleset.id}" class="d-flex list-item" @click="${()=> this.setActiveRule(this.rulesets[index])}">
- <span class="rule-status ${ruleset.enabled ? 'bg-green' : 'bg-red'}"></span>
+ <a ?selected="${this.ruleset && ruleset.id === this.ruleset.id}" class="d-flex list-item" @click="${() => this.setActiveRule(this.rulesets[index])}">
+ <span class="rule-status ${ruleset.enabled ? "bg-green" : "bg-red"}"></span>
<div class="flex">
- <span>${ruleset.name}</span>
+ <span>${ruleset.name}<span style="color: var(--app-grey-color);">${!ruleset.id ? " [concept]" : ""}</span></span>
</div>
</a>
- `
+ `;
})}
</div>
`;
diff --git a/ui/component/or-rules-editor/src/or-rule-then-condition/index.ts b/ui/component/or-rules-editor/src/or-rule-then-condition/index.ts
index 6ccb020af..58f9bfff0 100644
--- a/ui/component/or-rules-editor/src/or-rule-then-condition/index.ts
+++ b/ui/component/or-rules-editor/src/or-rule-then-condition/index.ts
@@ -46,6 +46,9 @@ class OrRuleThenCondition extends LitElement {
return html`
<div class="rule-container">
${this.condition ? html`
+ <or-select-asset-action>
+ <or-icon icon="numeric-1-circle"></or-icon>
+ </or-select-asset-action>
<or-select-asset-attribute disabled type="${this.condition}" value="${this.condition.attributeName}"></or-select-asset-attribute>
<or-select-operator disabled type="${this.condition}" value="EQUAL"></or-select-operator>
${this.createInputControl(this.condition!)}
diff --git a/ui/component/or-rules-editor/src/or-rule-then-condition/style.ts b/ui/component/or-rules-editor/src/or-rule-then-condition/style.ts
index a913f29d9..0803373ec 100644
--- a/ui/component/or-rules-editor/src/or-rule-then-condition/style.ts
+++ b/ui/component/or-rules-editor/src/or-rule-then-condition/style.ts
@@ -4,14 +4,23 @@ import {css} from 'lit-element';
export const style = css`
:host {
display: block;
+ width: 100%;
}
.rule-container {
- display: flex;
- margin-bottom: 10px;
- padding: 5px 20px;
-
- border-radius: 5px;
- border: 1px solid var(--app-lightgrey-color, #F5F5F5);
+ display: flex;
+ margin: 10px 0;
+ width: 100%;
+ border-radius: 0;
+ padding: 0 0 20px 0;
+ border-bottom: 1px solid var(--app-lightgrey-color, #F5F5F5);
+ }
+
+ .rule-container > * {
+ margin-right: 20px;
+ }
+
+ .rule-container > *:last-child {
+ margin-right: 0;
}
`;
\ No newline at end of file
diff --git a/ui/component/or-rules-editor/src/or-rule-then/index.ts b/ui/component/or-rules-editor/src/or-rule-then/index.ts
index d0d69cce1..db52e9420 100644
--- a/ui/component/or-rules-editor/src/or-rule-then/index.ts
+++ b/ui/component/or-rules-editor/src/or-rule-then/index.ts
@@ -13,7 +13,7 @@ class OrRuleThen extends LitElement {
static get styles() {
return [
style
- ]
+ ];
}
@property({type: Object})
@@ -30,8 +30,9 @@ class OrRuleThen extends LitElement {
return html`
<div class="rule-content-section">
- <h3>Dan..</h3>
<div class="rule-then-container bg-white shadow">
+ <strong>Dan..</strong>
+
${this.rule && this.rule.then ? this.rule.then.map((then: RuleActionUnion) => {
return html`
<or-rule-then-condition .condition="${then}" .attributeDescriptors="${this.attributeDescriptors}"></or-rule-then-condition>
@@ -53,19 +54,19 @@ class OrRuleThen extends LitElement {
protected updated(_changedProperties: PropertyValues): void {
super.updated(_changedProperties);
if (this.rule && !this.rule.then) {
- this.rule.then = defaultThen;
+ this.rule.then = [...defaultThen];
this.requestUpdate();
}
}
- private addThenCondition () {
+ private addThenCondition() {
if (this.rule && !this.rule.then) {
- this.rule.then = defaultThen;
+ this.rule.then = [...defaultThen];
}
if (this.rule && this.rule.then) {
- this.rule.then.push(defaultThenCondition);
+ this.rule.then.push({...defaultThenCondition});
this.requestUpdate();
}
diff --git a/ui/component/or-rules-editor/src/or-rule-then/style.ts b/ui/component/or-rules-editor/src/or-rule-then/style.ts
index fa6f88819..abb732810 100644
--- a/ui/component/or-rules-editor/src/or-rule-then/style.ts
+++ b/ui/component/or-rules-editor/src/or-rule-then/style.ts
@@ -3,6 +3,8 @@ import {css} from 'lit-element';
// language=CSS
export const style = css`
+
+
.rule-content-section {
flex-grow: 1;
flex-basis: 1;
@@ -15,6 +17,7 @@ export const style = css`
flex-wrap: wrap;
background-color: var(--app-white-color, #FFF);
+ box-shadow: rgba(0, 0, 0, 0.11) 0px 1px 2px 0px;
}
.button-add {
diff --git a/ui/component/or-rules-editor/src/or-rule-when-condition/index.ts b/ui/component/or-rules-editor/src/or-rule-when-condition/index.ts
index bf114cda8..ebceba6a5 100644
--- a/ui/component/or-rules-editor/src/or-rule-when-condition/index.ts
+++ b/ui/component/or-rules-editor/src/or-rule-when-condition/index.ts
@@ -1,10 +1,11 @@
-import {html, LitElement, property, customElement} from "lit-element";
+import {html, LitElement, property, customElement, PropertyValues} from "lit-element";
import "../selects/or-select-asset-attribute";
import "../selects/or-select-operator";
import "@openremote/or-input";
import "@openremote/or-select";
import "@openremote/or-icon";
+import {AssetModelUtil} from "@openremote/core";
import {style} from "./style";
import {AttributePredicate, AttributeDescriptor, ValueType} from "@openremote/model";
@@ -31,6 +32,9 @@ class OrRuleWhenCondition extends LitElement {
@property({type: Array})
public attributeDescriptors?: AttributeDescriptor[] = attributeDescriptors;
+ @property({type: Boolean})
+ public isValidRule: boolean = false;
+
constructor() {
super();
@@ -51,24 +55,25 @@ class OrRuleWhenCondition extends LitElement {
</or-select-asset-type>
${this.predicate.name ? html`
- <or-select-asset-attribute icon="${this.predicate}" value="${this.predicate.name.value}"></or-select-asset-attribute>
+ <or-select-asset-attribute value="${this.predicate.name.value}"></or-select-asset-attribute>
${this.predicate.value && this.predicate.value.predicateType === "string" ? html`
${this.predicate.name.value ? html`
- <or-select-operator type="${this.getAttributeDescriptors(this.predicate.name.value)!.valueDescriptor!.valueType}" value="${this.predicate.value.match}"></or-select-operator>
+ <or-select-operator type="${this.getAttributeDescriptors(this.predicate.name.value)!.valueDescriptor!.valueType}" .value="${this.predicate.value.match}"></or-select-operator>
` : ``}
${this.predicate.name.value && this.predicate.value.match ? html`
${this.getAttributeConfig(this.predicate.name.value)!.options ? html`
- <or-select .options="${this.getAttributeConfig(this.predicate.name.value).options}" value="${this.predicate.value.value ? this.predicate.value.value : ""}"></or-select>
+ ${this.predicate.value.value}
+ <or-select .options="${this.getAttributeConfig(this.predicate.name.value).options}" .value="${this.predicate.value.value ? this.predicate.value.value : ""}"></or-select>
` : html`
- <or-input type="text" value="${this.predicate.value.value ? this.predicate.value.value : ""}"></or-input>
+ <or-input type="text" .value="${this.predicate.value.value ? this.predicate.value.value : null}"></or-input>
`}
` : ``}
${this.predicate.value.value ? html`
- <a @click="${this.deleteCondition}">
- <or-icon class="small-icon" icon="delete"></or-icon>
+ <a style="margin-left: auto;" @click="${this.deleteCondition}">
+ <or-icon class="small-icon" icon="close-circle"></or-icon>
</a>
` : ``}
@@ -81,6 +86,29 @@ class OrRuleWhenCondition extends LitElement {
`;
}
+ protected updated(_changedProperties: PropertyValues): void {
+ super.updated(_changedProperties);
+ if (_changedProperties.has("predicate")) {
+ this.validateRule();
+ }
+ }
+
+ private validateRule() {
+
+ if (this.predicate && this.predicate.value && this.predicate.value.predicateType === "string" && this.predicate.value.value) {
+ this.isValidRule = true;
+ } else {
+ this.isValidRule = false;
+ }
+ const event = new CustomEvent("rules:validated", {
+ detail: { isValidRule: this.isValidRule },
+ bubbles: true,
+ composed: true });
+
+ this.dispatchEvent(event);
+
+ }
+
// setAssetType(value:string) {
// const assetType = {
// "predicateType": "string",
@@ -94,8 +122,9 @@ class OrRuleWhenCondition extends LitElement {
// }
// }
- private getAttributeDescriptors(name: string) {
- return find(this.attributeDescriptors, ["name", name]);
+ private getAttributeDescriptors(attributeName: string) {
+ console.log(AssetModelUtil.getAttributeDescriptor(attributeName));
+ return AssetModelUtil.getAttributeDescriptor(attributeName);
}
private getAttributeConfig(name: string) {
@@ -111,7 +140,7 @@ class OrRuleWhenCondition extends LitElement {
private setAssetAttribute(e: any) {
const value = e.detail.value;
- if(this.predicate && this.predicate.name) {
+ if (this.predicate && this.predicate.name) {
this.predicate.name.value = value;
this.setOperator(e);
@@ -119,9 +148,9 @@ class OrRuleWhenCondition extends LitElement {
}
}
- private setOperator(e: any){
+ private setOperator(e: any) {
const value = e.detail.value;
- if(this.predicate && this.predicate.value && this.predicate.value.predicateType === "string") {
+ if (this.predicate && this.predicate.value && this.predicate.value.predicateType === "string") {
this.predicate.value.match = value;
this.requestUpdate();
}
@@ -130,8 +159,9 @@ class OrRuleWhenCondition extends LitElement {
private setValue(e: any) {
const value = e.detail.value;
- if(this.predicate && this.predicate.value && this.predicate.value.predicateType === "string") {
+ if (this.predicate && this.predicate.value && this.predicate.value.predicateType === "string") {
this.predicate.value.value = value;
+ this.validateRule();
this.requestUpdate();
}
}
diff --git a/ui/component/or-rules-editor/src/or-rule-when-condition/style.ts b/ui/component/or-rules-editor/src/or-rule-when-condition/style.ts
index 8c6f276f2..3820743b6 100644
--- a/ui/component/or-rules-editor/src/or-rule-when-condition/style.ts
+++ b/ui/component/or-rules-editor/src/or-rule-when-condition/style.ts
@@ -4,17 +4,32 @@ import {css} from 'lit-element';
export const style = css`
:host {
display: block;
+ width: 100%;
}
.rule-container {
- display: flex;
- margin-bottom: 10px;
- padding: 5px 20px;
-
- border-radius: 5px;
- border: 1px solid var(--app-lightgrey-color, #F5F5F5);
+ display: flex;
+ margin: 10px 0;
+ width: 100%;
+ border-radius: 0;
+ padding: 0 0 20px 0;
+ border-bottom: 1px solid var(--app-lightgrey-color, #F5F5F5);
}
+
+ .rule-container > * {
+ margin-right: 20px;
+ }
+
+ .rule-container > *:last-child {
+ margin-right: 0;
+ }
+
or-icon {
margin-top: 5px;
}
+
+ .small-icon {
+ cursor: pointer;
+ fill: var(--app-grey-color, #F5F5F5);
+ }
`;
\ No newline at end of file
diff --git a/ui/component/or-rules-editor/src/or-rule-when/index.ts b/ui/component/or-rules-editor/src/or-rule-when/index.ts
index d0849a279..2268520ae 100644
--- a/ui/component/or-rules-editor/src/or-rule-when/index.ts
+++ b/ui/component/or-rules-editor/src/or-rule-when/index.ts
@@ -21,6 +21,7 @@ class OrRuleWhen extends LitElement {
@property({type: Array})
public predicates?: AttributePredicate[] = [];
+
constructor() {
super();
this.addEventListener("when-condition:delete", this.deleteWhenCondition);
@@ -31,18 +32,17 @@ class OrRuleWhen extends LitElement {
return html`
<div class="rule-content-section">
- <h3>Als..</h3>
<div class="rule-when-container bg-white shadow">
+ <strong>Als..</strong>
${this.rule && this.rule.when && this.rule.when.asset && this.rule.when.asset.attributes && this.rule.when.asset.attributes.predicates ? html`
${this.rule.when.asset.attributes.predicates.map((predicate: AttributePredicate, index) => {
return html`
<or-rule-when-condition index="${index}" .predicate="${predicate}"></or-rule-when-condition>
- <span class="rule-additional">&</span>
`; })}
` : ``}
${rulesEditorConfig.controls.addWhenCondition ? html`
- <a class="button-add" @click="${this.addWhenCondition}">+</a>
+ <a class="button-add" @click="${this.addWhenCondition}">+ voeg nog een voorwaarde toe</a>
` : ``}
</div>
</div>
@@ -52,7 +52,7 @@ class OrRuleWhen extends LitElement {
protected updated(_changedProperties: PropertyValues): void {
super.updated(_changedProperties);
if (this.rule && !this.rule.when) {
- this.rule.when = defaultWhenCondition;
+ this.rule.when = {...defaultWhenCondition};
if (this.rule!.when!.asset!.attributes!.predicates!.length === 0) {
this.addPredicate();
}
@@ -62,7 +62,7 @@ class OrRuleWhen extends LitElement {
private addWhenCondition() {
if (this.rule && !this.rule.when) {
- this.rule.when = defaultWhenCondition;
+ this.rule.when = {...defaultWhenCondition};
}
this.addPredicate();
@@ -72,7 +72,7 @@ class OrRuleWhen extends LitElement {
private addPredicate() {
if (this.rule && this.rule.when && this.rule.when.asset && this.rule.when.asset.attributes && this.rule.when.asset.attributes.predicates) {
- this.rule.when.asset.attributes.predicates.push(defaultPredicate);
+ this.rule.when.asset.attributes.predicates.push({...defaultPredicate});
}
}
diff --git a/ui/component/or-rules-editor/src/or-rule-when/style.ts b/ui/component/or-rules-editor/src/or-rule-when/style.ts
index 15bb5c5fc..c33df188f 100644
--- a/ui/component/or-rules-editor/src/or-rule-when/style.ts
+++ b/ui/component/or-rules-editor/src/or-rule-when/style.ts
@@ -14,17 +14,21 @@ export const style = css`
background-color: var(--app-white-color, #FFF);
flex-wrap: wrap;
+ box-shadow: rgba(0, 0, 0, 0.11) 0px 1px 2px 0px;
}
.button-add {
display: block;
cursor: pointer;
- padding: 10px 40px;
- font-size: 20px;
font-weight: bold;
height: 32px;
box-sizing: content-box;
- border: 3px dashed var(--app-lightgrey-color, #e4e4e4);
+
+ padding: 0;
+ border: none;
+ font-size: 15px;
+ color: var(--app-primary-color);
+
}
.rule-additional {
diff --git a/ui/component/or-rules-editor/src/selects/or-select-asset-attribute/index.ts b/ui/component/or-rules-editor/src/selects/or-select-asset-attribute/index.ts
index 191d0b8bd..6e3909511 100644
--- a/ui/component/or-rules-editor/src/selects/or-select-asset-attribute/index.ts
+++ b/ui/component/or-rules-editor/src/selects/or-select-asset-attribute/index.ts
@@ -9,9 +9,6 @@ import {rulesEditorConfig} from "../../const/rule-config";
@customElement("or-select-asset-attribute")
class OrSelectAssetAttribute extends LitElement {
- @property({type: String})
- public icon: string = "";
-
@property({type: String})
public assetType: string = "";
@@ -61,7 +58,7 @@ class OrSelectAssetAttribute extends LitElement {
<select ?disabled="${this.disabled}" id="or-select-asset-attribute" @change="${this.onChange}">
${this.options ? this.options.map((attribute: AttributeDescriptor) => {
return html`
- <option ?selected="${attribute.name === this.value}" value="${attribute.name}">${attribute.name}</option>
+ <option ?selected="${attribute.attributeName === this.value}" value="${attribute.attributeName}">${attribute.attributeName}</option>
`;
}) : ``}
</select>
@@ -75,7 +72,7 @@ class OrSelectAssetAttribute extends LitElement {
}
this.options = this.attributeDescriptors.filter((obj) => {
- return obj.name && rulesEditorConfig.options.attributeValueDescriptors.hasOwnProperty(obj.name);
+ return obj.attributeName && rulesEditorConfig.options.attributeValueDescriptors.hasOwnProperty(obj.attributeName);
});
}
diff --git a/ui/component/or-rules-editor/src/selects/or-select-operator/index.ts b/ui/component/or-rules-editor/src/selects/or-select-operator/index.ts
index a7063db95..f544f621c 100644
--- a/ui/component/or-rules-editor/src/selects/or-select-operator/index.ts
+++ b/ui/component/or-rules-editor/src/selects/or-select-operator/index.ts
@@ -33,18 +33,17 @@ class OrRuleWhen extends LitElement {
<option ?selected="${this.value === BaseAssetQueryOperator.GREATER_THAN}" value="${BaseAssetQueryOperator.GREATER_THAN}" value="GREATER_THAN">></option>
<option ?selected="${this.value === BaseAssetQueryOperator.LESS_EQUALS}" value="${BaseAssetQueryOperator.LESS_EQUALS}" value="LESS_EQUALS">=<</option>
<option ?selected="${this.value === BaseAssetQueryOperator.GREATER_EQUALS}" value="${BaseAssetQueryOperator.GREATER_EQUALS}" value="GREATER_EQUALS">=></option>
- ` :``}
+ ` : ``}
</select>
- ` :``}
+ ` : ``}
`;
}
-
onChange() {
- if(this.shadowRoot){
+ if (this.shadowRoot) {
const value = (<HTMLInputElement>this.shadowRoot.getElementById('or-select-operator')).value;
- let event = new CustomEvent('operator:changed', {
+ const event = new CustomEvent('operator:changed', {
detail: { value: value },
bubbles: true,
composed: true });
@@ -57,6 +56,4 @@ class OrRuleWhen extends LitElement {
super();
}
-
}
-
diff --git a/ui/component/or-rules-editor/src/style.ts b/ui/component/or-rules-editor/src/style.ts
index abd0a3fe2..128185bbd 100644
--- a/ui/component/or-rules-editor/src/style.ts
+++ b/ui/component/or-rules-editor/src/style.ts
@@ -78,14 +78,42 @@ export const style = css`
or-rule-then,
or-rule-when {
display: flex;
- flex-grow: 1;
- padding: 0 10px;
+ flex: 1 1 0;
background-color: var(--app-lightgrey-color);
- max-width: 50%;
}
+ or-rule-when {
+ padding-left: 10px;
+ }
+
+ or-rule-then {
+ padding-right: 10px;
+ }
+
.small-icon {
--or-icon-height: 16px;
}
+
+ button {
+ padding: 0 20px;
+ font-size: 14px;
+ height: 40px;
+ border-radius: 5px;
+ background-color: var(--app-primary-color);
+ margin-left: auto;
+ color: var(--app-white-color, #FFF);
+ font-weight: bold;
+ cursor: pointer;
+ }
+
+ @media only screen
+ and (min-device-width : 768px)
+ and (max-device-width : 1024px) {
+ side-menu {
+ min-width: 150px;
+ width: 150px;
+ }
+ }
+
`;
\ No newline at end of file
diff --git a/ui/component/or-select/src/style.ts b/ui/component/or-select/src/style.ts
index 9c1d1c768..b6fac2557 100644
--- a/ui/component/or-select/src/style.ts
+++ b/ui/component/or-select/src/style.ts
@@ -12,14 +12,21 @@ export const selectStyle = css`
select {
position: relative;
font-family: inherit;
- background-color: transparent;
- padding: 10px;
+ padding: 10px 40px 10px 10px;
border-radius: 0;
border: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-size: 14px;
+
+ border-bottom: 2px solid #d5d5d5;
+ background-color: #f2f2f2;
+
+ background-image: url('https://cdn3.iconfinder.com/data/icons/google-material-design-icons/48/ic_keyboard_arrow_down_48px-128.png');
+ background-repeat: no-repeat;
+ background-size: 20px;
+ background-position: right 10px center;
}
`;
\ No newline at end of file