diff --git a/ui/src/app/modals/app-config-value/app-config-value.page.html b/ui/src/app/modals/app-config-value/app-config-value.page.html index 0f014b1dd..182c29ac0 100644 --- a/ui/src/app/modals/app-config-value/app-config-value.page.html +++ b/ui/src/app/modals/app-config-value/app-config-value.page.html @@ -8,9 +8,9 @@ {{ spec.name }} - - - {{ saveFn ? 'Save' : 'Done' }} + + + Save diff --git a/ui/src/app/modals/app-config-value/app-config-value.page.ts b/ui/src/app/modals/app-config-value/app-config-value.page.ts index 6742b05b0..72f1db502 100644 --- a/ui/src/app/modals/app-config-value/app-config-value.page.ts +++ b/ui/src/app/modals/app-config-value/app-config-value.page.ts @@ -49,31 +49,32 @@ export class AppConfigValuePage { } async dismiss () { - if (this.edited) { - await this.presentAlertUnsaved() + if (this.value === '') this.value = null + + if (this.spec.type === 'number' && this.value !== null) { + this.value = Number(this.value) + } + + if ((!!this.saveFn && this.edited) || (!this.saveFn && this.error)) { + await this.presentAlert() } else { await this.trackingModalCtrl.dismiss() } } - async done () { - if (!this.validate()) { return } + async save () { + if (this.value === '') this.value = null - if (this.spec.type !== 'boolean') { - this.value = this.value || null - } - if (this.spec.type === 'number' && this.value) { + if (this.spec.type === 'number' && this.value !== null) { this.value = Number(this.value) } - if (this.saveFn) { - this.loader.displayDuringP( - this.saveFn(this.value).catch(e => { - console.error(e) - this.error = e.message - }), - ) - } + this.loader.displayDuringP( + this.saveFn(this.value).catch(e => { + console.error(e) + this.error = e.message + }), + ) await this.trackingModalCtrl.dismiss(this.value) } @@ -84,7 +85,7 @@ export class AppConfigValuePage { } handleInput () { - this.error = '' + this.validate() this.edited = true } @@ -114,7 +115,7 @@ export class AppConfigValuePage { if (this.spec.type === 'boolean') return true // test blank - if (!this.value && !(this.spec as any).nullable) { + if (this.value === '' && !(this.spec as any).nullable) { this.error = 'Value cannot be blank' return false } @@ -145,14 +146,23 @@ export class AppConfigValuePage { } } + this.error = '' return true } - private async presentAlertUnsaved () { + private async presentAlert () { + const header = this.error ? + 'Invalid Entry' : + 'Unsaved Changes' + + const message = this.error ? + 'Value will not be saved' : + 'You have unsaved changes. Are you sure you want to leave?' + const alert = await this.alertCtrl.create({ backdropDismiss: false, - header: 'Unsaved Changes', - message: 'You have unsaved changes. Are you sure you want to leave?', + header, + message, buttons: [ { text: 'Cancel', diff --git a/ui/src/app/pages/apps-routes/app-config/app-config.page.html b/ui/src/app/pages/apps-routes/app-config/app-config.page.html index ed4130cd0..cef07e8c4 100644 --- a/ui/src/app/pages/apps-routes/app-config/app-config.page.html +++ b/ui/src/app/pages/apps-routes/app-config/app-config.page.html @@ -49,7 +49,7 @@ Initial Config -

To use the default config for {{ app.title | ngrxPush }}, click "Save" below.

+

To use the default config for {{ pkg.manifest.title }}, click "Save" below.

@@ -65,7 +65,7 @@ {{ rec.dependentTitle }}
-

{{app.title | ngrxPush}} config has been modified to satisfy {{ rec.dependentTitle }}. +

{{ pkg.manifest.title }} config has been modified to satisfy {{ rec.dependentTitle }}. To accept the changes, click “Save” below.

More Info @@ -92,13 +92,13 @@ -

No config options for {{ app.title | ngrxPush }} {{ app.versionInstalled | ngrxPush }}.

+

No config options for {{ pkg.manifest.title }} {{ pkg.manifest.version }}.

Auto Check for Updates {{ ui['auto-check-updates'] }} - diff --git a/ui/src/app/services/api/mock-api.service.ts b/ui/src/app/services/api/mock-api.service.ts index bc4a8d40b..41072bb66 100644 --- a/ui/src/app/services/api/mock-api.service.ts +++ b/ui/src/app/services/api/mock-api.service.ts @@ -36,15 +36,40 @@ export class MockApiService extends ApiService { // db async getRevisions (since: number): Promise { - return this.http.rpcRequest({ method: 'db.revisions', params: { since } }) + await pauseFor(2000) + return { + ...Mock.DbDump, + id: this.nextSequence(), + } + // return this.http.rpcRequest({ method: 'db.revisions', params: { since } }) } async getDump (): Promise { - return this.http.rpcRequest({ method: 'db.dump' }) + await pauseFor(2000) + return { + ...Mock.DbDump, + id: this.nextSequence(), + } + // return this.http.rpcRequest({ method: 'db.dump' }) } async setDbValueRaw (params: RR.SetDBValueReq): Promise { - return this.http.rpcRequest({ method: 'db.put.ui', params }) + await pauseFor(2000) + return { + response: null, + revision: { + id: this.nextSequence(), + patch: [ + { + op: PatchOp.REPLACE, + path: params.pointer, + value: params.value, + }, + ], + expireId: null, + }, + } + // return this.http.rpcRequest({ method: 'db.put.ui', params }) } // auth diff --git a/ui/src/app/services/server-config.service.ts b/ui/src/app/services/server-config.service.ts index d37d7783b..bf5bb5b5d 100644 --- a/ui/src/app/services/server-config.service.ts +++ b/ui/src/app/services/server-config.service.ts @@ -58,8 +58,7 @@ const serverConfig: ConfigSpec = { name: 'Device Name', description: 'A unique label for this device.', nullable: false, - // @TODO determine regex - // pattern: '', + pattern: '^.{1,40}$', patternDescription: 'Must be less than 40 characters', masked: false, copyable: false, @@ -67,7 +66,7 @@ const serverConfig: ConfigSpec = { autoCheckUpdates: { type: 'boolean', name: 'Auto Check for Updates', - description: 'On launch, EmabssyOS will automatically check for updates of itself and your installed services. Updating still requires user approval and action. No updates will ever be performed automatically.', + description: 'On launch, EmbassyOS will automatically check for updates of itself and your installed services. Updating still requires user approval and action. No updates will ever be performed automatically.', default: true, }, ssh: { diff --git a/ui/ui-config.json b/ui/ui-config.json index ead6dafdc..afee30e0f 100644 --- a/ui/ui-config.json +++ b/ui/ui-config.json @@ -12,7 +12,8 @@ "mocks": { "enabled": true, "connection": "poll", - "websocketUrl": "", + "rpcPort": "5959", + "wsPort": "5960", "maskAs": "tor", "skipStartupAlerts": true }