Skip to content

armgit / core

Public Imported from GitHub
0

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

Improve user page, readonly for insight assettree

Robin Dekkers659813089c68
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
index 4b8b4b7fa..455910a04 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
@@ -1526,7 +1526,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
false,
ConsoleAppConfig.MenuPosition.BOTTOM_LEFT,
null,
- "#FAFAFA",
+ "#4D9D2A",
"#AFAFAF",
new ConsoleAppConfig.AppLink[]{
new ConsoleAppConfig.AppLink("Map", "https://demo.openremote.io/mobile/?realm=smartcity&consoleProviders=geofence push storage&consoleAutoEnable=true#!geofences")
diff --git a/ui/app/or-app/src/pages/page-users.ts b/ui/app/or-app/src/pages/page-users.ts
index a8e7bf664..49aa1fe8f 100644
--- a/ui/app/or-app/src/pages/page-users.ts
+++ b/ui/app/or-app/src/pages/page-users.ts
@@ -249,7 +249,6 @@ class PageUsers<S extends AppStateKeyed> extends Page<S> {
this.requestUpdate()
})
})
-
}
);
}
@@ -299,8 +298,6 @@ class PageUsers<S extends AppStateKeyed> extends Page<S> {
this.getUsers()
})
this._userRoleMapper[user.id] = role;
- } else {
- this.getUsers();
}
}
@@ -310,10 +307,14 @@ class PageUsers<S extends AppStateKeyed> extends Page<S> {
const credentials = {value: password}
manager.rest.api.UserResource.resetPassword(manager.displayRealm, user.id, credentials);
}
- if(this._userRoleMapper[user.id]) {
- this._updateRole(user, this._userRoleMapper[user.id])
- }
- manager.rest.api.UserResource.update(manager.displayRealm, user.id, user);
+ if(this._userRoleMapper[user.id]) {
+ this._updateRole(user, this._userRoleMapper[user.id])
+ }
+
+ manager.rest.api.UserResource.update(manager.displayRealm, user.id, user).then(respoonse => {
+ this.getUsers();
+
+ });
}
private _deleteUser(user) {
@@ -395,7 +396,7 @@ class PageUsers<S extends AppStateKeyed> extends Page<S> {
${userRole ? userRole.name : null}
</td>
<td class="padded-cell mdc-data-table__cell hide-mobile">
- ${user.enabled ? "Active" : "In active"}
+ ${user.enabled ? "Active" : "Inactive"}
</td>
</tr>
<tr id="attribute-meta-row-${index}" class="attribute-meta-row${!user.id ? " expanded" : ""}">
@@ -410,10 +411,10 @@ class PageUsers<S extends AppStateKeyed> extends Page<S> {
</div>
<div class="column">
- ${user.id ? html`
- <or-input ?readonly="${readonly}" ?disabled="${isSameUser}" .value="${ifDefined(userRole.id)}" .type="${InputType.SELECT}" .options="${selectOptions}" .label="${i18next.t("role")}" @or-input-changed="${(e: OrInputChangedEvent) => {this._userRoleMapper[user.id] = e.detail.value;}}"></or-input>
+ ${user.id && this._userRoleMapper[user.id] ? html`
+ <or-input ?readonly="${readonly}" ?disabled="${isSameUser}" .value="${userRole ? ifDefined(userRole.id) : ifDefined(null)}" .type="${InputType.SELECT}" .options="${selectOptions}" .label="${i18next.t("role")}" @or-input-changed="${(e: OrInputChangedEvent) => this._userRoleMapper[user.id] = e.detail.value}"></or-input>
` : html`
- <or-input ?readonly="${readonly}" ?disabled="${isSameUser}" .type="${InputType.SELECT}" .options="${selectOptions}" .label="${i18next.t("role")}" @or-input-changed="${(e: OrInputChangedEvent) => {this._userRoleMapper["newUser"] = e.detail.value;}}"></or-input>
+ <or-input ?readonly="${readonly}" ?disabled="${isSameUser}" .type="${InputType.SELECT}" .options="${selectOptions}" .label="${i18next.t("role")}" @or-input-changed="${(e: OrInputChangedEvent) => {console.log(e.detail.value); this._userRoleMapper["newUser"] = e.detail.value;}}"></or-input>
`}
<or-input id="password-${index}" ?readonly="${readonly}" .label="${i18next.t("password")}" .type="${InputType.PASSWORD}" min="1" @or-input-changed="${(e: OrInputChangedEvent) => { this.checkPassword(index) }}"></or-input>
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 3da7a30f4..6f238b652 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -426,7 +426,7 @@ export class OrAttributeCard extends LitElement {
];
this._dialog.dialogContent = html`
- <or-asset-tree id="chart-asset-tree"
+ <or-asset-tree id="chart-asset-tree" readonly
.selectedIds="${this.asset ? [this.asset.id] : null}"></or-asset-tree>
${this.asset && this.asset.attributes ? html`
<or-input id="attribute-picker"
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 03e7784dd..c991aa025 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -533,6 +533,11 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
}
public isReadonly(): boolean {
+ if(!manager.hasRole("write:attributes")) {
+ this.readonly = !manager.hasRole("write:attributes");
+ return this.readonly;
+ }
+
return this.readonly !== undefined ? this.readonly : Util.getMetaValue(WellknownMetaItems.READONLY, this.attribute, this._attributeDescriptor);
}
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index cdb63e191..62b616a62 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -510,7 +510,7 @@ export class OrChart extends translate(i18next)(LitElement) {
<div class="mdc-dialog__surface">
<h2 class="mdc-dialog__title" id="my-dialog-title">${i18next.t("addAttribute")}</h2>
<div class="dialog-container mdc-dialog__content" id="my-dialog-content">
- <or-asset-tree id="chart-asset-tree" .selectedIds="${this.activeAsset ? [this.activeAsset.id] : undefined}"></or-asset-tree>
+ <or-asset-tree id="chart-asset-tree" readonly .selectedIds="${this.activeAsset ? [this.activeAsset.id] : undefined}"></or-asset-tree>
${this.activeAsset && this.activeAsset.attributes ? html`
<or-input id="chart-attribute-picker"
style="display:flex;"