From 9319314672ddf33089a2a2c1fb493714df97daf7 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 4 Jul 2022 14:16:18 -0600 Subject: [PATCH] display bottom item in backup list and refactor for cleanliness (#1609) * display bottom item in backup list and refactor for cleanliness * fix spelling mistake * display initial toggle to deselect all, as all are selected by default * add select/deselect all to backup restore and handle backup case when no services intalled Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com> --- .../backup-drives-header.component.html | 6 +- .../backup-drives.component.html | 250 +++++++++--------- .../backup-drives/backup-drives.component.ts | 6 +- .../app-recover-select.page.html | 7 + .../app-recover-select.page.ts | 6 + .../backup-select/backup-select.page.html | 82 +++--- .../backup-select/backup-select.page.scss | 4 + .../backup-select/backup-select.page.ts | 2 +- .../restore/restore.component.html | 10 +- .../server-backup/server-backup.page.html | 14 +- .../app/services/api/embassy-api.service.ts | 4 +- 11 files changed, 212 insertions(+), 179 deletions(-) diff --git a/frontend/projects/ui/src/app/components/backup-drives/backup-drives-header.component.html b/frontend/projects/ui/src/app/components/backup-drives/backup-drives-header.component.html index 1de729022f..f59b84b1e4 100644 --- a/frontend/projects/ui/src/app/components/backup-drives/backup-drives-header.component.html +++ b/frontend/projects/ui/src/app/components/backup-drives/backup-drives-header.component.html @@ -3,7 +3,9 @@ - {{ title }} + {{ + type === 'create' ? 'Create Backup' : 'Restore From Backup' + }} Refresh @@ -11,4 +13,4 @@ - \ No newline at end of file + diff --git a/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.html b/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.html index ffa097fd18..769794fd77 100644 --- a/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.html +++ b/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.html @@ -1,137 +1,145 @@ - - + - - - - - - - {{ backupService.loadingError }} - - - + + + - - - - LAN Shared Folders - - -

- LAN Shared Folders are the recommended way to create Embassy - backups. View the - Instructions -

-
-
- - - - - Open New - - - - - + + + + + + + {{ backupService.loadingError }} + + + + + + + + LAN Shared Folders + + +

+ LAN Shared Folders are the recommended way to create Embassy + backups. View the + Instructions +

+
+
+ + -

{{ cifs.path.split('/').pop() }}

- - - -

- - Unable to connect -

-

Hostname: {{ cifs.hostname }}

-

Path: {{ cifs.path }}

+ Open New
- - -
-
+ + + + + +

{{ cifs.path.split('/').pop() }}

+ + + +

+ + Unable to connect +

+

Hostname: {{ cifs.hostname }}

+

Path: {{ cifs.path }}

+
+ + + +
+
-
+
- - Physical Drives - - - -

- - Warning! Plugging a 2nd physical drive directly into your Embassy - can lead to data corruption. - - To safely create a backup to a physical drive, view the - instructions. -

-
-

- If your drive is plugged in and does not appear, try - refreshing. -

-
-
- - + + Physical Drives + - - - -

{{ drive.label || drive.logicalname }}

- -

- {{ drive.vendor || 'Unknown Vendor' }} - - {{ drive.model || 'Unknown Model' }} -

-

Capacity: {{ drive.capacity | convertBytes }}

-
-
+ +

+ + Warning! Plugging a 2nd physical drive directly into your + Embassy can lead to data corruption. + + To safely create a backup to a physical drive, view the + instructions. +

+
+

+ If your drive is plugged in and does not appear, try + refreshing. +

+
-
-
+ + + + + + +

{{ drive.label || drive.logicalname }}

+ +

+ {{ drive.vendor || 'Unknown Vendor' }} - + {{ drive.model || 'Unknown Model' }} +

+

Capacity: {{ drive.capacity | convertBytes }}

+
+
+
+
+ +
- + diff --git a/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.ts b/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.ts index 3d73d49a62..89a9566d82 100644 --- a/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.ts +++ b/frontend/projects/ui/src/app/components/backup-drives/backup-drives.component.ts @@ -17,13 +17,15 @@ import { ApiService } from 'src/app/services/api/embassy-api.service' import { ErrorToastService } from '@start9labs/shared' import { MappedBackupTarget } from 'src/app/types/mapped-backup-target' +type BackupType = 'create' | 'restore' + @Component({ selector: 'backup-drives', templateUrl: './backup-drives.component.html', styleUrls: ['./backup-drives.component.scss'], }) export class BackupDrivesComponent { - @Input() type: 'create' | 'restore' + @Input() type: BackupType @Output() onSelect: EventEmitter< MappedBackupTarget > = new EventEmitter() @@ -232,7 +234,7 @@ export class BackupDrivesComponent { styleUrls: ['./backup-drives.component.scss'], }) export class BackupDrivesHeaderComponent { - @Input() title: string + @Input() type: BackupType @Output() onClose: EventEmitter = new EventEmitter() constructor(public readonly backupService: BackupService) {} diff --git a/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.html b/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.html index 4382b908a3..149b14cd28 100644 --- a/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.html +++ b/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.html @@ -11,6 +11,13 @@ + + + + {{ selectAll ? 'Select All' : 'Deselect All' }} + + +

{{ option.title }}

diff --git a/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.ts b/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.ts index 710afa864a..45141fb8fa 100644 --- a/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.ts +++ b/frontend/projects/ui/src/app/modals/app-recover-select/app-recover-select.page.ts @@ -27,6 +27,7 @@ export class AppRecoverSelectPage { 'newer-eos': boolean })[] hasSelection = false + selectAll = true error: string | IonicSafeString constructor( @@ -62,6 +63,11 @@ export class AppRecoverSelectPage { this.hasSelection = this.options.some(o => o.checked) } + toggleSelectAll() { + this.options.forEach(pkg => (pkg.checked = this.selectAll)) + this.selectAll = !this.selectAll + } + async restore(): Promise { const ids = this.options .filter(option => !!option.checked) diff --git a/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.html b/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.html index d684825fe1..d6f7d98fcf 100644 --- a/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.html +++ b/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.html @@ -9,44 +9,50 @@ - - - - - - {{ selectAll ? 'Select All' : 'Deselect All' }} +
+ + + + + + {{ selectAll ? 'Select All' : 'Deselect All' }} + + + + + + + + +

{{ pkg.title }}

+
+ +
+
+
+ + + + + + Back Up Selected - - - - - - -

{{ pkg.title }}

-
- -
- - +
+
+
- - - - - Back Up Selected - - - - + +

No services installed!

+
diff --git a/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.scss b/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.scss index e69de29bb2..fd648cbe63 100644 --- a/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.scss +++ b/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.scss @@ -0,0 +1,4 @@ +.center { + text-align: center; + padding: 20px; +} \ No newline at end of file diff --git a/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.ts b/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.ts index f8b2250feb..a7173a67b1 100644 --- a/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.ts +++ b/frontend/projects/ui/src/app/modals/backup-select/backup-select.page.ts @@ -11,7 +11,7 @@ import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' }) export class BackupSelectPage { hasSelection = false - selectAll = true + selectAll = false pkgs: { id: string title: string diff --git a/frontend/projects/ui/src/app/pages/server-routes/restore/restore.component.html b/frontend/projects/ui/src/app/pages/server-routes/restore/restore.component.html index 52c30d1a73..7440c9a77e 100644 --- a/frontend/projects/ui/src/app/pages/server-routes/restore/restore.component.html +++ b/frontend/projects/ui/src/app/pages/server-routes/restore/restore.component.html @@ -1,5 +1,5 @@ - - - - - + diff --git a/frontend/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.html b/frontend/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.html index c4576f3f13..16653f3da8 100644 --- a/frontend/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.html +++ b/frontend/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.html @@ -1,16 +1,14 @@ - - - - + diff --git a/frontend/projects/ui/src/app/services/api/embassy-api.service.ts b/frontend/projects/ui/src/app/services/api/embassy-api.service.ts index fd103bb3c4..922a9be6e9 100644 --- a/frontend/projects/ui/src/app/services/api/embassy-api.service.ts +++ b/frontend/projects/ui/src/app/services/api/embassy-api.service.ts @@ -78,7 +78,7 @@ export abstract class ApiService implements Source, Http { async updateServerWrapper(params: RR.UpdateServerReq) { const res = await this.updateServerRaw(params) if (res.response === 'no-updates') { - throw new Error('Could ont find a newer version of EmbassyOS') + throw new Error('Could not find a newer version of EmbassyOS') } return res } @@ -271,7 +271,7 @@ export abstract class ApiService implements Source, Http { private syncResponse< T, F extends (...args: any[]) => Promise<{ response: T; revision?: Revision }>, - >(f: F, temp?: Operation): (...args: Parameters) => Promise { + >(f: F, temp?: Operation): (...args: Parameters) => Promise { return (...a) => { // let expireId = undefined // if (temp) {