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: various minor component updates

Rich Turner161b834ace74
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index 4269269ea..bcebc1413 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -62,5 +62,12 @@
"timer": "Timer",
"rulesEditorAddCondition": "Add condition",
"rulesEditorAddGroup": "Add group",
- "rulesEditorAddAction": "Add action"
+ "rulesEditorAddAction": "Add action",
+ "sortBy": "Sort by",
+ "assetType": "Asset type",
+ "creationDate": "Creation date",
+ "status": "Status",
+ "name": "Name",
+ "deleteAssetsNoChildrenAllowed": "Only assets that have no descendants can be deleted, please remove descendents first.",
+ "confirmDeleteAssets": "Remove assets?"
}
\ No newline at end of file
diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.json
index 3ae3316df..81125edf6 100644
--- a/deployment/manager/shared/locales/nl/or.json
+++ b/deployment/manager/shared/locales/nl/or.json
@@ -62,5 +62,12 @@
"timer": "Timer",
"rulesEditorAddCondition": "Voorwaarde",
"rulesEditorAddGroup": "Groep",
- "rulesEditorAddAction": "Actie"
+ "rulesEditorAddAction": "Actie",
+ "sortBy": "Sorteren op",
+ "assetType": "Asset type",
+ "creationDate": "Creation date",
+ "status": "Status",
+ "name": "Naam",
+ "deleteAssetsNoChildrenAllowed": "Only assets that have no descendants can be deleted, please remove descendents first.",
+ "confirmDeleteAssets": "Asset verwijderen?"
}
\ No newline at end of file
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 38168a9ed..5d1822b50 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -9,14 +9,36 @@ import i18nextXhr from "i18next-xhr-backend";
import {AssetDescriptor, AttributeDescriptor, AttributeValueDescriptor, MetaItemDescriptor} from "@openremote/model";
import * as Util from "./util";
+export declare type KeycloakPromise<T> = {
+ success<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | KeycloakPromise<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | KeycloakPromise<TResult2>) | undefined | null): KeycloakPromise<TResult1 | TResult2>;
+ error<TResult = never>(onrejected?: ((reason: any) => TResult | KeycloakPromise<TResult>) | undefined | null): Promise<T | TResult>;
+}
+
+export declare type Keycloak = {
+ token: string;
+ refreshToken: string;
+ tokenParsed: any;
+ refreshTokenParsed: any;
+ resourceAccess: any;
+ onAuthSuccess: () => void;
+ onAuthError: () => void;
+ init(options?: any): KeycloakPromise<boolean>;
+ login(options?: any): void;
+ hasRealmRole(role: string): boolean;
+ logout(options?: any): void;
+ updateToken(expiry: number): KeycloakPromise<boolean>;
+ clearToken(): void;
+}
+
export {Util};
-export const DefaultColor1: string = "#FFF"; // Header and panels
+export const DefaultColor1: string = "#FFF"; // Header
export const DefaultColor2: string = "#F9F9F9"; // Background
-export const DefaultColor3: string = "#202020"; // Text
+export const DefaultColor3: string = "#4c4c4c"; // Text
export const DefaultColor4: string = "#1B5630"; // Buttons
export const DefaultColor5: string = "#CCC"; // Borders and lines
export const DefaultColor6: string = "#be0000"; // Invalid/Error
+export const DefaultColor7: string = "#FFF"; // Panels
export const DefaultBoxShadowBottom: string = "0 5px 5px -5px rgba(0,0,0,0.57)";
export const DefaultBoxShadow: string = "0 1px 3px 0 rgba(0,0,0,0.21)";
export const DefaultHeaderHeight: string = "60px";
@@ -70,6 +92,7 @@ export interface ManagerConfig {
appVersion?: string;
auth?: Auth;
realm: string;
+ clientId?: string;
autoLogin?: boolean;
credentials?: Credentials;
consoleAutoEnable?: boolean;
@@ -233,7 +256,17 @@ export class Manager implements EventProviderFactory {
}
get roles() {
- return this._roles;
+ if (!this._keycloak || !this._keycloak.resourceAccess) {
+ return [];
+ }
+
+ let roles: String[];
+ if (this._config.clientId && this._keycloak!.resourceAccess.hasOwnProperty(this._config.clientId)) {
+ roles = this._keycloak!.resourceAccess[this._config.clientId].roles;
+ } else {
+ roles = this._keycloak!.resourceAccess.account.roles;
+ }
+ return roles || [];
}
get managerVersion() {
@@ -323,6 +356,10 @@ export class Manager implements EventProviderFactory {
normalisedConfig.loadDescriptors = true;
}
+ if (normalisedConfig.clientId === undefined) {
+ normalisedConfig.clientId = "openremote";
+ }
+
return normalisedConfig;
}
@@ -332,8 +369,7 @@ export class Manager implements EventProviderFactory {
private _ready: boolean = false;
private _name: string = "";
private _username: string = "";
- private _keycloak: any = null;
- private _roles: string[] = [];
+ private _keycloak?: Keycloak;
private _keycloakUpdateTokenInterval?: number = undefined;
private _managerVersion: string = "";
private _listeners: EventCallback[] = [];
@@ -648,7 +684,7 @@ export class Manager implements EventProviderFactory {
}
public isSuperUser() {
- return this.hasRole("admin");
+ return this.getRealm() && this.getRealm() === "master" && this.hasRealmRole("admin");
}
public getApiBaseUrl() {
@@ -662,8 +698,12 @@ export class Manager implements EventProviderFactory {
return pathArr.length >= 1 ? pathArr[1] : "";
}
+ public hasRealmRole(role: string) {
+ return this._keycloak && this._keycloak.hasRealmRole(role);
+ }
+
public hasRole(role: string) {
- return this._roles && this._roles.indexOf(role) >= 0;
+ return this.roles && this.roles.indexOf(role) >= 0;
}
public getAuthorizationHeader(): string | undefined {
@@ -696,9 +736,9 @@ export class Manager implements EventProviderFactory {
// If native shell is enabled, we need an offline refresh token
if (this.console && this.console.isMobile && this.config.auth === Auth.KEYCLOAK) {
- if (this._keycloak.refreshTokenParsed.typ === "Offline") {
+ if (this._keycloak && this._keycloak.refreshTokenParsed.typ === "Offline") {
console.debug("Storing offline refresh token");
- this.console.storeData("REFRESH_TOKEN", this._keycloak.refreshToken);
+ this.console.storeData("REFRESH_TOKEN", this._keycloak!.refreshToken);
} else {
this.login();
}
@@ -730,18 +770,18 @@ export class Manager implements EventProviderFactory {
// Initialise keycloak
this._keycloak = (window as any).Keycloak({
- clientId: "openremote",
+ clientId: this._config.clientId,
realm: this._config.realm,
url: this._config.keycloakUrl
});
- this._keycloak.onAuthSuccess = () => {
+ this._keycloak!.onAuthSuccess = () => {
if (keycloakPromise) {
keycloakPromise(true);
}
};
- this._keycloak.onAuthError = () => {
+ this._keycloak!.onAuthError = () => {
this._setAuthenticated(false);
};
@@ -754,7 +794,7 @@ export class Manager implements EventProviderFactory {
const authenticated = await new Promise<boolean>(((resolve, reject) => {
keycloakPromise = resolve;
- this._keycloak.init({
+ this._keycloak!.init({
checkLoginIframe: false, // Doesn't work well with offline tokens or periodic token updates
onLoad: this._config.autoLogin ? "login-required" : "check-sso",
refreshToken: offlineToken
@@ -769,13 +809,8 @@ export class Manager implements EventProviderFactory {
if (authenticated) {
- this._name = this._keycloak.tokenParsed.name;
- this._username = this._keycloak.tokenParsed.preferred_username;
- if (this._keycloak.resourceAccess.openremote) {
- this._roles = this._keycloak.resourceAccess.openremote.roles;
- } else {
- this._roles = this._keycloak.resourceAccess.account.roles;
- }
+ this._name = this._keycloak!.tokenParsed.name;
+ this._username = this._keycloak!.tokenParsed.preferred_username;
// Update the access token every 10s (note keycloak will only update if expiring within configured
// time period.
@@ -805,7 +840,7 @@ export class Manager implements EventProviderFactory {
protected updateKeycloakAccessToken(): Promise<boolean> {
// Access token must be good for X more seconds, should be half of Constants.ACCESS_TOKEN_LIFESPAN_SECONDS
return new Promise<boolean>(() => {
- this._keycloak.updateToken(30)
+ this._keycloak!.updateToken(30)
.success((tokenRefreshed: boolean) => {
// If refreshed from server, it means the refresh token was still good for another access token
console.debug("Access token update success, refreshed from server: " + tokenRefreshed);
@@ -815,8 +850,8 @@ export class Manager implements EventProviderFactory {
// Refresh token expired (either SSO max session duration or offline idle timeout), see
// IDENTITY_SESSION_MAX_MINUTES and IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES server config
console.info("Access token update failed, refresh token expired, login required");
- this._keycloak.clearToken();
- this._keycloak.login();
+ this._keycloak!.clearToken();
+ this._keycloak!.login();
});
});
}
diff --git a/ui/component/or-icon/package.json b/ui/component/or-icon/package.json
index 43d3cba90..9d1813bd4 100644
--- a/ui/component/or-icon/package.json
+++ b/ui/component/or-icon/package.json
@@ -4,6 +4,9 @@
"description": "Displays s vector or raster map",
"main": "dist/index.js",
"types": "src/index.ts",
+ "exports": {
+ "./": "./dist/"
+ },
"scripts": {
"generate": "node mdi-iconset-generator.js",
"build": "node mdi-iconset-generator.js && npx tsc -b",
diff --git a/ui/component/or-icon/src/index.ts b/ui/component/or-icon/src/index.ts
index 0ff835ce8..065293b96 100644
--- a/ui/component/or-icon/src/index.ts
+++ b/ui/component/or-icon/src/index.ts
@@ -37,13 +37,21 @@ export class OrIcon extends LitElement {
static styles = css`
:host {
+
+ --internal-or-icon-width: var(--or-icon-width, 24px);
+ --internal-or-icon-height: var(--or-icon-height, 24px);
+ --internal-or-icon-fill: var(--or-icon-fill, currentColor);
+ --internal-or-icon-stroke: var(--or-icon-fill, none);
+ --internal-or-icon-stroke-width: var(--or-icon-stroke-width, 0);
+
display: inline-block;
position: relative;
vertical-align: middle;
- fill: var(--or-icon-fill, currentcolor);
- stroke: var(--or-icon-stroke, none);
- width: var(--or-icon-width, 24px);
- height: var(--or-icon-height, 24px);
+ fill: var(--internal-or-icon-fill);
+ stroke: var(--internal-or-icon-stroke);
+ stroke-width: var(--internal-or-icon-stroke-width);
+ width: var(--internal-or-icon-width);
+ height: var(--internal-or-icon-height);
}
:host([hidden]) {
diff --git a/ui/component/or-rules-editor/src/style.ts b/ui/component/or-rules-editor/src/style.ts
index d44e7211b..cb0c91725 100644
--- a/ui/component/or-rules-editor/src/style.ts
+++ b/ui/component/or-rules-editor/src/style.ts
@@ -1,5 +1,5 @@
import {css, unsafeCSS} from "lit-element";
-import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultBoxShadow, DefaultColor4, DefaultColor6, DefaultDisabledOpacity} from "@openremote/core";
+import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultBoxShadow, DefaultColor4, DefaultColor6, DefaultColor7, DefaultDisabledOpacity} from "@openremote/core";
// language=CSS
export const rulesEditorStyle = css`
@@ -11,10 +11,9 @@ export const rulesEditorStyle = css`
--internal-or-rules-editor-background-color: var(--or-rules-editor-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));
--internal-or-rules-editor-text-color: var(--or-rules-editor-text-color, inherit);
- --internal-or-rules-editor-panel-color: var(--or-rules-editor-panel-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
--internal-or-rules-editor-button-color: var(--or-rules-editor-button-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
--internal-or-rules-editor-invalid-color: var(--or-rules-editor-invalid-color, var(--or-app-color6, ${unsafeCSS(DefaultColor6)}));
- --internal-or-rules-editor-panel-color: var(--or-rules-editor-panel-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
+ --internal-or-rules-editor-panel-color: var(--or-rules-editor-panel-color, var(--or-app-color7, ${unsafeCSS(DefaultColor7)}));
--internal-or-rules-editor-line-color: var(--or-rules-editor-line-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));
--internal-or-rules-editor-list-selected-color: var(--or-rules-editor-list-selected-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));
diff --git a/ui/component/or-select/package.json b/ui/component/or-select/package.json
index 85f725eca..6078f90c0 100644
--- a/ui/component/or-select/package.json
+++ b/ui/component/or-select/package.json
@@ -11,6 +11,9 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
+ "@openremote/core": "^1.0.0",
+ "@openremote/rest": "^1.0.0",
+ "@openremote/or-icon": "^1.0.0",
"@material/list": "^1.0.1",
"@material/menu": "^1.0.1",
"@material/menu-surface": "^1.0.1",
diff --git a/ui/component/or-select/src/index.ts b/ui/component/or-select/src/index.ts
index 3f5e57d03..cf7ea3def 100644
--- a/ui/component/or-select/src/index.ts
+++ b/ui/component/or-select/src/index.ts
@@ -1,5 +1,5 @@
import {html, LitElement, property, customElement, PropertyValues, query} from "lit-element";
-import {selectStyle} from "./style";
+import {optionColorVar, selectStyle} from "./style";
export class OrSelectChangedEvent extends CustomEvent<OrSelectChangedEventDetail> {
@@ -41,64 +41,120 @@ export class OrSelect extends LitElement {
public value?: string;
@property({type: Boolean})
- public readonly: boolean = false;
+ public readonly?: boolean;
@property({type: Boolean})
- public required: boolean = true;
+ public required?: boolean;
@property({type: Boolean})
- public addEmpty: boolean = true;
+ public autoSize?: boolean = true;
+
+ @property({type: Boolean, attribute: true})
+ public noEmpty?: boolean = false;
@property({type: Array})
- public options: string[] | [string, string][] = [];
+ public options!: string[] | [string, string][];
@query("#or-select")
protected _select!: HTMLSelectElement;
+ @query("#width_tmp_select")
+ protected _tmpSelect!: HTMLSelectElement;
+
+ protected _optColor?: string;
+
+ connectedCallback(): void {
+ super.connectedCallback();
+
+ // Take color from host as select will override color inheritance otherwise
+ const style = window.getComputedStyle(this);
+
+ if(style.getPropertyValue("--internal-or-select-option-text-color").indexOf("inherit") >= 0) {
+ this._optColor = style.getPropertyValue("color");
+ }
+ }
+
protected onChange() {
+ if (this._select.value == this.value) {
+ return;
+ }
+
+ if (this.autoSize) {
+ this._resize();
+ }
const previousValue = this.value;
this.value = this._select.value && this._select.value.length > 0 ? this._select.value : undefined;
this.dispatchEvent(new OrSelectChangedEvent(this.value, previousValue));
}
- protected firstUpdated(_changedProperties: PropertyValues) {
- super.firstUpdated(_changedProperties);
- if (this.options.length === 1) {
- const opt = this.options[0];
- const val = Array.isArray(opt) ? opt[0] : opt;
- if (this.value !== val) {
- window.setTimeout(() => {
- if (this._select) {
- this._select.value = val;
- }
+ protected updated(_changedProperties: PropertyValues): void {
+ super.updated(_changedProperties);
+
+ if (_changedProperties.has("options") || _changedProperties.has("value")) {
+ let val = this.value;
+
+ if (this.options.length === 1 || (this.noEmpty && !val)) {
+ const opt = this.options[0];
+ const firstValue = Array.isArray(opt) ? opt[0] : opt;
+ if (this.value !== firstValue) {
+ val = firstValue;
+ }
+ }
+
+ let index: number;
+ if (this.options.length === 1 || (this.noEmpty && !val)) {
+ index = 0;
+ } else {
+ index = this.options.findIndex((opt: string | [string, string]) => {
+ const value = Array.isArray(opt) ? opt[0] : opt;
+ return value == val;
});
}
+
+ const indexChanged = this._select.selectedIndex != index;
+ this._select.selectedIndex = index;
+ if (indexChanged) {
+ this.onChange();
+ } else {
+ if (this.autoSize) {
+ this._resize();
+ }
+ }
}
}
protected render() {
- if (this._select) {
- // If we don't do this then selected attribute on option is not respected when a select is updated
- if (!this.value) {
- this._select.selectedIndex = this.addEmpty ? 0 : -1;
- }
- }
const isSingular = this.options.length === 1;
return html`
<div class="mdc-select">
<select id="or-select" ?required="${this.required}" @change="${this.onChange}" ?disabled="${this.readonly || isSingular}">
- ${this.addEmpty && !isSingular ? html`<option value="" ?selected="${!this.value}"></option>` : ``};
+ ${!this.noEmpty && !isSingular ? html`<option value=""></option>` : ``};
${this.options.length > 0 && Array.isArray(this.options[0]) ?
(this.options as [string, string][]).map((option: [string, string]) => {
- return html`<option ?selected="${this.value === option[0]}" value="${option[0]}">${option[1]}</option>`;
+ return html`<option style="color: ${this._optColor || optionColorVar};" value="${option[0]}">${option[1]}</option>`;
}) :
(this.options as string[]).map((option: string) => {
- return html`<option ?selected="${this.value === option}" value="${option}">${option}</option>`;
+ return html`<option style="color: ${this._optColor || optionColorVar};" value="${option}">${option}</option>`;
})
}
</select>
+ <svg viewBox="0 0 24 24">
+ <path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" />
+ </svg>
+ <select id="width_tmp_select">
+ <option id="width_tmp_option"></option>
+ </select>
</div>
`;
}
+
+ protected _resize() {
+ let width = 20;
+ if (this._select.selectedOptions.length > 0) {
+ (this._tmpSelect.options.item(0)! as HTMLOptionElement).innerHTML = this._select.selectedOptions.item(0)!.text;
+ width = this._tmpSelect.offsetWidth;
+ }
+ this._select.style.setProperty("width", width + "px");
+ }
}
diff --git a/ui/component/or-select/src/style.ts b/ui/component/or-select/src/style.ts
index caac90ace..2c83254e1 100644
--- a/ui/component/or-select/src/style.ts
+++ b/ui/component/or-select/src/style.ts
@@ -1,38 +1,69 @@
-import {css} from "lit-element";
+import {css, unsafeCSS} from "lit-element";
+import {DefaultColor2, DefaultColor5, DefaultColor7} from "@openremote/core";
// TODO this is temp work, should be replaced with material design components / styling
+
+export const optionColorVar = "--internal-or-select-option-text-color";
+
// language=CSS
export const selectStyle = css`
+ :host {
+ display: inline-block;
+
+ --internal-or-select-background-color: var(--or-select-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor2)}));
+ --internal-or-select-border-color: var(--or-select-border-color, var(--or-app-color1, ${unsafeCSS(DefaultColor5)}));
+ --internal-or-select-text-color: var(--or-select-text-color, inherit);
+ --internal-or-select-padding: var(--or-select-padding, 10px 40px 10px 10px);
+ --internal-or-select-option-text-color: var(--or-select-option-text-color, inherit);
+ --internal-or-select-option-background-color: var(--or-select-option-background-color, var(--or-app-color7, ${unsafeCSS(DefaultColor7)}));
+ }
+
select:invalid {
border-bottom: 2px solid red;
}
.mdc-select {
- font-family:
- 'Roboto','Helvetica','Arial',sans-serif;
+ font-family: 'Roboto','Helvetica','Arial',sans-serif;
position: relative;
display: inline-block;
+ fill: var(--internal-or-select-text-color);
}
select {
+ cursor: pointer;
position: relative;
font-family: inherit;
- padding: 10px 40px 10px 10px;
+ padding: var(--internal-or-select-padding);
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("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M7.41 7.84L12 12.42l4.59-4.58L18 9.25l-6 6-6-6z'/%3E%3C/svg%3E");
- background-repeat: no-repeat;
- background-size: 20px;
- background-position: right 10px center;
+ outline: none;
+ color: var(--internal-or-select-text-color);
+ border-bottom: 2px solid var(--internal-or-select-border-color);
+ background-color: var(--internal-or-select-background-color);
+ }
+
+ #width_tmp_select {
+ position: absolute;
+ visibility: hidden;
+ pointer-events: none;
+ }
+
+ select > option {
+ background-color: var(--internal-or-select-option-background-color);
+ }
+
+ svg {
+ width: 20px;
+ height: 100%;
+ position: absolute;
+ right: 0;
+ top: 0;
+ pointer-events: none;
}
`;
\ No newline at end of file
diff --git a/ui/component/or-select/tsconfig.json b/ui/component/or-select/tsconfig.json
index 0191a5e16..1e51a2601 100644
--- a/ui/component/or-select/tsconfig.json
+++ b/ui/component/or-select/tsconfig.json
@@ -10,6 +10,7 @@
],
"references": [
{ "path": "../core" },
- { "path": "../rest" }
+ { "path": "../rest" },
+ { "path": "../or-icon" }
]
}
\ No newline at end of file
diff --git a/ui/component/rest/package.json b/ui/component/rest/package.json
index 366e211c7..08427f84f 100644
--- a/ui/component/rest/package.json
+++ b/ui/component/rest/package.json
@@ -12,9 +12,11 @@
"license": "AGPL-3.0-or-later",
"dependencies": {
"@openremote/model": "^1.0.0",
- "axios": "0.18.1"
+ "axios": "0.18.1",
+ "qs": "^6.8.0"
},
"devDependencies": {
+ "@types/qs": "^6.5.3",
"tslint": "^5.11.0",
"typescript": "^3.4.5"
},
diff --git a/ui/component/rest/src/index.ts b/ui/component/rest/src/index.ts
index e7e8eed12..c7017f6cd 100644
--- a/ui/component/rest/src/index.ts
+++ b/ui/component/rest/src/index.ts
@@ -1,5 +1,6 @@
import axios, {AxiosInstance, AxiosRequestConfig} from "axios";
import {ApiClient} from "./restclient";
+import Qs from "qs";
export class RestApi {
@@ -12,6 +13,10 @@ export class RestApi {
constructor() {
this._axiosInstance = axios.create();
+ this._axiosInstance.interceptors.request.use((config) => {
+ config.paramsSerializer = params => Qs.stringify(params, {arrayFormat: 'repeat'});
+ return config;
+ })
}
get axiosInstance() {
diff --git a/ui/demo/demo-core/src/util.ts b/ui/demo/demo-core/src/util.ts
index 679bd5700..afb4065b8 100644
--- a/ui/demo/demo-core/src/util.ts
+++ b/ui/demo/demo-core/src/util.ts
@@ -1,20 +1,23 @@
-import {Asset, AssetQuery, AssetQueryMatch, AssetQueryInclude} from "@openremote/model";
+import {Asset, AssetQuery, AssetQueryMatch} from "@openremote/model";
import rest from "@openremote/rest";
export async function getApartment1Asset(): Promise<Asset | undefined> {
const query: AssetQuery = {
- name: {
+ names: [{
predicateType: "string",
match: AssetQueryMatch.EXACT,
value: "Apartment 1"
- },
- type: {
+ }],
+ types: [{
predicateType: "string",
match: AssetQueryMatch.EXACT,
value: "urn:openremote:asset:residence"
- },
+ }],
select: {
- include: AssetQueryInclude.ONLY_ID_AND_NAME
+ excludeRealm: true,
+ excludePath: true,
+ excludeAttributes: true,
+ excludeParentInfo: true
}
};
diff --git a/yarn.lock b/yarn.lock
index 8d40d0ab9..79cb2eb5f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1087,6 +1087,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.2.tgz#c4e63af5e8823ce9cc3f0b34f7b998c2171f0c44"
integrity sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg==
+"@types/qs@^6.5.3":
+ version "6.5.3"
+ resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.5.3.tgz#1c3b71b091eaeaf5924538006b7f70603ce63d38"
+ integrity sha512-Jugo5V/1bS0fRhy2z8+cUAHEyWOATaz4rbyLVvcFs7+dXp5HfwpEwzF1Q11bB10ApUqHf+yTauxI0UXQDwGrbA==
+
"@webassemblyjs/[email protected]":
version "1.8.5"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"
@@ -5132,6 +5137,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
+qs@^6.8.0:
+ version "6.8.0"
+ resolved "https://registry.yarnpkg.com/qs/-/qs-6.8.0.tgz#87b763f0d37ca54200334cd57bb2ef8f68a1d081"
+ integrity sha512-tPSkj8y92PfZVbinY1n84i1Qdx75lZjMQYx9WZhnkofyxzw2r7Ho39G3/aEvSUdebxpnnM4LZJCtvE/Aq3+s9w==
+
querystring-es3@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"