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: minor enhancements and fixes

Rich Turner8ed91bb8337a
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index c78cc465c..6a8c95126 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -65,7 +65,6 @@
"deleteRulesetsConfirm": "Remove ruleset(s)?",
"deleteRulesetsFailed": "Failed to delete one or more requested rulesets(s)",
"saveRulesetFailed": "Failed to save ruleset",
- "rulesetModified": "Ruleset modified",
"confirmContinueRulesetModified": "Ruleset has been modified, discard changes?",
"when": "When",
"then": "Then",
@@ -322,7 +321,7 @@
"urn:openremote:asset:meta:protocolConfiguration": "Protocol configuration"
},
"addMetaItems": "Add configuration items",
- "assetModified": "Asset modified",
+ "loseChanges": "Discard changes?",
"confirmContinueAssetModified": "Asset has been modified, discard changes?",
"saveAssetFailed": "Failed to save asset",
"noCommand": "No command",
diff --git a/ui/app/or-app/src/pages/page-assets.ts b/ui/app/or-app/src/pages/page-assets.ts
index 0dbc657c5..1a44b5821 100644
--- a/ui/app/or-app/src/pages/page-assets.ts
+++ b/ui/app/or-app/src/pages/page-assets.ts
@@ -169,10 +169,6 @@ class PageAssets<S extends AppStateKeyed> extends Page<S> {
protected _onAssetSelectionChanged(event: OrAssetTreeSelectionEvent) {
const nodes = event.detail.newNodes;
const newIds = event.detail.newNodes.map((node) => node.asset.id!);
- if (Util.objectsEqual(newIds, this._assetIds)) {
- return;
- }
-
this._assetIds = newIds;
this._viewer.assetId = nodes.length === 1 ? nodes[0].asset!.id : undefined;
this._updateRoute(true);
@@ -200,7 +196,7 @@ class PageAssets<S extends AppStateKeyed> extends Page<S> {
protected _confirmContinue(action: () => void) {
if (this._viewer.isModified()) {
- showOkCancelDialog(i18next.t("assetModified"), i18next.t("confirmContinueAssetModified"))
+ showOkCancelDialog(i18next.t("loseChanges"), i18next.t("confirmContinueAssetModified"))
.then((ok) => {
if (ok) {
action();
@@ -225,6 +221,8 @@ class PageAssets<S extends AppStateKeyed> extends Page<S> {
protected _onAssetSave(result: SaveResult) {
if (result.success && result.isNew) {
this._addedAssetId = result.assetId!;
+ } else {
+ this._viewer.assetId = result.assetId;
}
}
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 9386763a7..e26518caf 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -523,7 +523,7 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
const parent = this._selectedNodes && this._selectedNodes.length === 1 ? this._selectedNodes[0].asset : undefined;
const onAddChanged = (ev: OrAddChangedEvent) => {
- const nameValid = ev.detail.name && ev.detail.name.trim().length > 0 && ev.detail.name.trim().length < 1024;
+ const nameValid = !!ev.detail.name && ev.detail.name.trim().length > 0 && ev.detail.name.trim().length < 1024;
const addBtn = dialog.shadowRoot!.getElementById("add-btn") as OrInput;
addBtn.disabled = !ev.detail.descriptor || !nameValid;
};
@@ -537,17 +537,19 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
actions: [
{
actionName: "cancel",
- content: i18next.t("cancel")
+ content: i18next.t("cancel"),
+ action: () => {
+ console.log("CLOSED");
+ }
},
{
actionName: "add",
- default: true,
content: html`<or-input id="add-btn" class="button" .type="${InputType.BUTTON}" label="${i18next.t("add")}" disabled></or-input>`,
action: () => {
const addAssetDialog = dialog.shadowRoot!.getElementById("add-panel") as OrAddAssetDialog;
const descriptor = addAssetDialog.selectedType;
- const name = addAssetDialog.name;
+ const name = addAssetDialog.name.trim();
if (!descriptor) {
return;
diff --git a/ui/component/or-asset-tree/src/or-add-asset-dialog.ts b/ui/component/or-asset-tree/src/or-add-asset-dialog.ts
index e51892788..08a2c6d05 100644
--- a/ui/component/or-asset-tree/src/or-add-asset-dialog.ts
+++ b/ui/component/or-asset-tree/src/or-add-asset-dialog.ts
@@ -69,9 +69,16 @@ export class OrAddAssetDialog extends LitElement {
public static get styles() {
// language=CSS
return css`
- #name-input {
- margin: 10px;
+ #name-wrapper {
+ display: flex;
+ padding: 10px;
+ }
+
+ #name-wrapper > * {
+ margin: 0 5px;
+ flex: 1 1 auto;
}
+
#mdc-dialog-form-add {
display: flex;
height: 600px;
@@ -92,9 +99,6 @@ export class OrAddAssetDialog extends LitElement {
text-transform: capitalize;
border-right: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
}
- #name-input {
- width: 400px;
- }
`;
}
@@ -135,8 +139,13 @@ export class OrAddAssetDialog extends LitElement {
);
}
+ const parentStr = this.parent ? this.parent.name + " (" + this.parent.id + ")" : i18next.t("none");
+
return html`
- <or-input id="name-input" .type="${InputType.TEXT}" min="1" max="1023" comfortable required outlined .label="${i18next.t("name")}" .value="${this.name}" @or-input-changed="${(e: OrInputChangedEvent) => this.onNameChanged(e.detail.value)}"></or-input>
+ <div id="name-wrapper">
+ <or-input id="name-input" .type="${InputType.TEXT}" min="1" max="1023" comfortable required outlined .label="${i18next.t("name")}" .value="${this.name}" @or-input-changed="${(e: OrInputChangedEvent) => this.onNameChanged(e.detail.value)}"></or-input>
+ <or-input id="parent" .type="${InputType.TEXT}" comfortable readonly outlined .label="${i18next.t("parent")}" .value="${parentStr}"></or-input>
+ </div>
<form id="mdc-dialog-form-add">
<div id="type-list">
${createListGroup(lists)}
@@ -169,11 +178,9 @@ export class OrAddAssetDialog extends LitElement {
}
protected onModified() {
- if (this.nameInput.valid && this.selectedType) {
- this.dispatchEvent(new OrAddChangedEvent({
- name: this.name,
- descriptor: this.selectedType
- }));
- }
+ this.dispatchEvent(new OrAddChangedEvent({
+ name: this.name,
+ descriptor: this.selectedType
+ }));
}
}
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 134439fd6..08bc74f45 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -703,8 +703,9 @@ async function getAssetChildren(id: string, childAssetType: string): Promise<Ass
return response.data.filter((asset) => asset.type === childAssetType);
}
-export async function saveAsset(asset: Asset, isUpdate: boolean = false): Promise<SaveResult> {
+export async function saveAsset(asset: Asset): Promise<SaveResult> {
+ const isUpdate = !!asset.id && asset.version !== undefined;
let success: boolean;
let id: string = "";
@@ -1029,11 +1030,10 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
return;
}
- const isUpdate = !!asset.version;
this.saveBtnElem.disabled = true;
this.wrapperElem.classList.add("saving");
- const result = await saveAsset(asset, isUpdate);
+ const result = await saveAsset(asset);
this.wrapperElem.classList.remove("saving");
this.saveBtnElem.disabled = false;
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index 114b977b5..256b5de1b 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -154,7 +154,7 @@ const style = css`
}
.mdc-text-field, .mdc-text-field-helper-line {
- width: inherit;
+ width: 100%;
}
.mdc-text-field.dense-comfortable {
diff --git a/ui/component/or-rules/src/index.ts b/ui/component/or-rules/src/index.ts
index b46e00566..aacc93f24 100644
--- a/ui/component/or-rules/src/index.ts
+++ b/ui/component/or-rules/src/index.ts
@@ -645,7 +645,7 @@ export class OrRules extends translate(i18next)(LitElement) {
protected _confirmContinue(action: () => void) {
if (this._viewer.modified) {
- showOkCancelDialog(i18next.t("rulesetModified"), i18next.t("confirmContinueRulesetModified"))
+ showOkCancelDialog(i18next.t("loseChanges"), i18next.t("confirmContinueRulesetModified"))
.then((ok) => {
if (ok) {
action();
diff --git a/ui/component/or-translate/src/index.ts b/ui/component/or-translate/src/index.ts
index 4b1d77d00..339759f67 100644
--- a/ui/component/or-translate/src/index.ts
+++ b/ui/component/or-translate/src/index.ts
@@ -11,7 +11,7 @@ export class OrTranslate extends translate(i18next)(LitElement) {
public static styles = css`
:host {
- display: inline;
+ display: inline-block;
}
:host([hidden]) {