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
Agent import timeout and styling improvements (Fixes #757) (#758)
Rich Turnerb57de06016b8
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex dfb87a602..a0036ed3e 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -43,8 +43,7 @@ import "./or-edit-asset-panel";import {OrEditAssetModifiedEvent, OrEditAssetPanel, ValidatorResult} from "./or-edit-asset-panel";import "@openremote/or-mwc-components/or-mwc-snackbar";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";-import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/or-mwc-menu";-import {ListItem} from "@openremote/or-mwc-components/or-mwc-list";+import { progressCircular } from "@openremote/or-mwc-components/style";export interface PanelConfig {type: "info" | "setup" | "history" | "group" | "survey" | "survey-results" | "linkedUsers";@@ -366,10 +365,10 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitEleme}const updateFileName = () => {- const fileInputElem = hostElement.shadowRoot!.getElementById('fileupload-elem') as HTMLInputElement,- fileNameElem = hostElement.shadowRoot!.getElementById('filename-elem') as HTMLInputElement,- fileUploadBtn: OrMwcInput = hostElement.shadowRoot!.getElementById("fileupload-btn") as OrMwcInput,- str = fileInputElem.value;+ const fileInputElem = hostElement.shadowRoot!.getElementById('fileupload-elem') as HTMLInputElement;+ const fileNameElem = hostElement.shadowRoot!.getElementById('filename-elem') as HTMLInputElement;+ const fileUploadBtn: OrMwcInput = hostElement.shadowRoot!.getElementById("fileupload-btn") as OrMwcInput;+ const str = fileInputElem.value;if (!str) {return;@@ -429,14 +428,18 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitEleme// TODO: cancel the request to the manager}- const fileToBase64 = () => {- const fileUploadBtn: OrMwcInput = hostElement.shadowRoot!.getElementById("fileupload-btn") as OrMwcInput;+ const doImport = () => {+ const fileNameElem = hostElement.shadowRoot!.getElementById('filename-elem') as HTMLInputElement;+ const fileUploadBtn = hostElement.shadowRoot!.getElementById("fileupload-btn") as OrMwcInput;+ const progressElement = hostElement.shadowRoot!.getElementById("progress-circular") as HTMLProgressElement;- if (!fileUploadBtn) {+ if (!fileUploadBtn || !progressElement) {return false;}fileUploadBtn.disabled = true;+ fileUploadBtn.classList.add("hidden");+ progressElement.classList.remove("hidden");const fileInputElem = hostElement.shadowRoot!.getElementById('fileupload-elem') as HTMLInputElement;if (fileInputElem) {@@ -460,13 +463,13 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitElemebinary: true} as FileInfo- manager.rest.api.AgentResource.doProtocolAssetImport(asset.id!, fileInfo) //todo: this doesn't work yet+ manager.rest.api.AgentResource.doProtocolAssetImport(asset.id!, fileInfo, undefined, {timeout: 30000}).then(response => {if (response.status !== 200) {showSnackbar(undefined, "Something went wrong, please try again", i18next.t("dismiss"));} else {showSnackbar(undefined, "Import successful! Added "+response.data.length+" assets!", i18next.t("dismiss"));- console.info(response.data, response) //todo: do something with this response+ console.info(response.data, response)}}).catch((err) => {@@ -474,7 +477,10 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitElemeconsole.error(err);}).finally(() => {- fileUploadBtn.disabled = false;+ fileNameElem.value = "";+ fileUploadBtn.disabled = true;+ fileUploadBtn.classList.remove("hidden");+ progressElement.classList.add("hidden");});}@@ -486,12 +492,13 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitElemeif (descriptor.assetImport) {content = html`- <div id="fileupload">+ <div id="fileupload"><or-mwc-input outlined .label="${i18next.t("selectFile")}" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => hostElement.shadowRoot!.getElementById('fileupload-elem')!.click()}">- <input id="fileupload-elem" name="configfile" type="file" accept=".json, .knxproj, .vlp" @change="${() => updateFileName()}"/>+ <input id="fileupload-elem" name="configfile" type="file" accept=".*" @change="${() => updateFileName()}"/></or-mwc-input><or-mwc-input id="filename-elem" .type="${InputType.TEXT}" disabled></or-mwc-input>- <or-mwc-input id="fileupload-btn" icon="upload" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => fileToBase64()}" disabled></or-mwc-input>+ <or-mwc-input id="fileupload-btn" icon="upload" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => doImport()}" disabled></or-mwc-input>+ <progress id="progress-circular" class="hidden pure-material-progress-circular"></progress></div>`;}@@ -1043,6 +1050,7 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElemstatic get styles() {return [unsafeCSS(tableStyle),+ progressCircular,panelStyles,style];diff --git a/ui/component/or-asset-viewer/src/style.ts b/ui/component/or-asset-viewer/src/style.tsindex a544ab60c..9c49df757 100644--- a/ui/component/or-asset-viewer/src/style.ts+++ b/ui/component/or-asset-viewer/src/style.ts@@ -253,6 +253,20 @@ export const style = css`cursor: pointer;}+ #fileupload {+ display: flex;+ align-items: center;+ }++ #fileupload > * {+ flex: 1 auto;+ margin-right: 5px;+ }++ .hidden {+ display: none;+ }+@media screen and (max-width: 1200px) {#name-input {width: 150px;diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.tsindex bd4c7ba1b..7dd028e43 100644--- a/ui/component/or-attribute-input/src/index.ts+++ b/ui/component/or-attribute-input/src/index.ts@@ -1,4 +1,4 @@-import {css, html, LitElement, PropertyValues, TemplateResult, unsafeCSS} from "lit";+import {css, html, LitElement, PropertyValues, TemplateResult} from "lit";import {customElement, property, query} from "lit/decorators.js";import {ifDefined} from "lit/directives/if-defined.js";import {until} from "lit/directives/until.js";@@ -19,8 +19,9 @@ import {AssetModelUtil,ClientRole} from "@openremote/model";-import manager, {DefaultColor4, subscribe, Util} from "@openremote/core";+import manager, {subscribe, Util} from "@openremote/core";import "@openremote/or-mwc-components/or-mwc-input";+import {progressCircular} from "@openremote/or-mwc-components/style";import "@openremote/or-components/or-loading-wrapper";import {OrLoadingWrapper} from "@openremote/or-components/or-loading-wrapper";import {@@ -274,7 +275,9 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE// language=CSSstatic get styles() {- return css`+ return [+ progressCircular,+ css`:host {display: inline-block;}@@ -352,126 +355,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEmargin-left: 4px;margin-top: 4px;}-- /* https://codepen.io/finnhvman/pen/bmNdNr */- .pure-material-progress-circular {- -webkit-appearance: none;- -moz-appearance: none;- appearance: none;- box-sizing: border-box;- border: none;- border-radius: 50%;- padding: 0.25em;- width: 3em;- height: 3em;- color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});- background-color: transparent;- font-size: 16px;- overflow: hidden;- }-- .pure-material-progress-circular::-webkit-progress-bar {- background-color: transparent;- }-- /* Indeterminate */- .pure-material-progress-circular:indeterminate {- -webkit-mask-image: linear-gradient(transparent 50%, black 50%), linear-gradient(to right, transparent 50%, black 50%);- mask-image: linear-gradient(transparent 50%, black 50%), linear-gradient(to right, transparent 50%, black 50%);- animation: pure-material-progress-circular 6s infinite cubic-bezier(0.3, 0.6, 1, 1);- }-- :-ms-lang(x), .pure-material-progress-circular:indeterminate {- animation: none;- }-- .pure-material-progress-circular:indeterminate::before,- .pure-material-progress-circular:indeterminate::-webkit-progress-value {- content: "";- display: block;- box-sizing: border-box;- margin-bottom: 0.25em;- border: solid 0.25em transparent;- border-top-color: currentColor;- border-radius: 50%;- width: 100% !important;- height: 100%;- background-color: transparent;- animation: pure-material-progress-circular-pseudo 0.75s infinite linear alternate;- }-- .pure-material-progress-circular:indeterminate::-moz-progress-bar {- box-sizing: border-box;- border: solid 0.25em transparent;- border-top-color: currentColor;- border-radius: 50%;- width: 100%;- height: 100%;- background-color: transparent;- animation: pure-material-progress-circular-pseudo 0.75s infinite linear alternate;- }-- .pure-material-progress-circular:indeterminate::-ms-fill {- animation-name: -ms-ring;- }-- @keyframes pure-material-progress-circular {- 0% {- transform: rotate(0deg);- }- 12.5% {- transform: rotate(180deg);- animation-timing-function: linear;- }- 25% {- transform: rotate(630deg);- }- 37.5% {- transform: rotate(810deg);- animation-timing-function: linear;- }- 50% {- transform: rotate(1260deg);- }- 62.5% {- transform: rotate(1440deg);- animation-timing-function: linear;- }- 75% {- transform: rotate(1890deg);- }- 87.5% {- transform: rotate(2070deg);- animation-timing-function: linear;- }- 100% {- transform: rotate(2520deg);- }- }-- @keyframes pure-material-progress-circular-pseudo {- 0% {- transform: rotate(-30deg);- }- 29.4% {- border-left-color: transparent;- }- 29.41% {- border-left-color: currentColor;- }- 64.7% {- border-bottom-color: transparent;- }- 64.71% {- border-bottom-color: currentColor;- }- 100% {- border-left-color: currentColor;- border-bottom-color: currentColor;- transform: rotate(225deg);- }- }- `;+ `];}@property({type: Object, reflect: false})@@ -537,11 +421,6 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE@property()protected _writeTimeoutHandler?: number;- @query("#send-btn")- protected _sendButton!: OrMwcInput;- @query("#scrim")- protected _scrimElem!: HTMLDivElement;-public customProvider?: ValueInputProviderGenerator;public writeTimeout?: number = DEFAULT_TIMEOUT;protected _requestFocus = false;diff --git a/ui/component/or-mwc-components/src/style.ts b/ui/component/or-mwc-components/src/style.tsnew file mode 100644index 000000000..6e8525c0f--- /dev/null+++ b/ui/component/or-mwc-components/src/style.ts@@ -0,0 +1,125 @@+import {css, unsafeCSS} from "lit";+import {DefaultColor4} from "@openremote/core";++// language=CSS+export const progressCircular = css`++ /* https://codepen.io/finnhvman/pen/bmNdNr */+ .pure-material-progress-circular {+ -webkit-appearance: none;+ -moz-appearance: none;+ appearance: none;+ box-sizing: border-box;+ border: none;+ border-radius: 50%;+ padding: 0.25em;+ width: 3em;+ height: 3em;+ color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});+ background-color: transparent;+ font-size: 16px;+ overflow: hidden;+ }++ .pure-material-progress-circular::-webkit-progress-bar {+ background-color: transparent;+ }++ /* Indeterminate */+ .pure-material-progress-circular:indeterminate {+ -webkit-mask-image: linear-gradient(transparent 50%, black 50%), linear-gradient(to right, transparent 50%, black 50%);+ mask-image: linear-gradient(transparent 50%, black 50%), linear-gradient(to right, transparent 50%, black 50%);+ animation: pure-material-progress-circular 6s infinite cubic-bezier(0.3, 0.6, 1, 1);+ }++ :-ms-lang(x), .pure-material-progress-circular:indeterminate {+ animation: none;+ }++ .pure-material-progress-circular:indeterminate::before,+ .pure-material-progress-circular:indeterminate::-webkit-progress-value {+ content: "";+ display: block;+ box-sizing: border-box;+ margin-bottom: 0.25em;+ border: solid 0.25em transparent;+ border-top-color: currentColor;+ border-radius: 50%;+ width: 100% !important;+ height: 100%;+ background-color: transparent;+ animation: pure-material-progress-circular-pseudo 0.75s infinite linear alternate;+ }++ .pure-material-progress-circular:indeterminate::-moz-progress-bar {+ box-sizing: border-box;+ border: solid 0.25em transparent;+ border-top-color: currentColor;+ border-radius: 50%;+ width: 100%;+ height: 100%;+ background-color: transparent;+ animation: pure-material-progress-circular-pseudo 0.75s infinite linear alternate;+ }++ .pure-material-progress-circular:indeterminate::-ms-fill {+ animation-name: -ms-ring;+ }++ @keyframes pure-material-progress-circular {+ 0% {+ transform: rotate(0deg);+ }+ 12.5% {+ transform: rotate(180deg);+ animation-timing-function: linear;+ }+ 25% {+ transform: rotate(630deg);+ }+ 37.5% {+ transform: rotate(810deg);+ animation-timing-function: linear;+ }+ 50% {+ transform: rotate(1260deg);+ }+ 62.5% {+ transform: rotate(1440deg);+ animation-timing-function: linear;+ }+ 75% {+ transform: rotate(1890deg);+ }+ 87.5% {+ transform: rotate(2070deg);+ animation-timing-function: linear;+ }+ 100% {+ transform: rotate(2520deg);+ }+ }++ @keyframes pure-material-progress-circular-pseudo {+ 0% {+ transform: rotate(-30deg);+ }+ 29.4% {+ border-left-color: transparent;+ }+ 29.41% {+ border-left-color: currentColor;+ }+ 64.7% {+ border-bottom-color: transparent;+ }+ 64.71% {+ border-bottom-color: currentColor;+ }+ 100% {+ border-left-color: currentColor;+ border-bottom-color: currentColor;+ transform: rotate(225deg);+ }+ }+`;