config sync ui updates

This commit is contained in:
Eugene Pankov 2021-07-29 21:07:22 +02:00
parent c5dbccf807
commit 61ea2c77c8
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
3 changed files with 27 additions and 14 deletions

View File

@ -8,11 +8,15 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
.header .header
.title Sync host .title Sync host
.input-group.w-50
input.form-control( input.form-control(
type='text', type='text',
[(ngModel)]='config.store.configSync.host', [(ngModel)]='config.store.configSync.host',
(ngModelChange)='config.save()', (ngModelChange)='config.save()',
) )
.input-group-append(*ngIf='config.store.configSync.host')
button.btn.btn-secondary((click)='platform.openExternal("http://" + config.store.configSync.host)')
i.fas.fa-external-link-alt
.form-line .form-line
.header .header
@ -49,23 +53,24 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
.list-group-light .list-group-light
.list-group-item.d-flex.align-items-center( .list-group-item.d-flex.align-items-center(
*ngFor='let cfg of configs', *ngFor='let cfg of configs',
[class.active]='cfg.id === config.store.configSync.configID', [class.active]='isActiveConfig(cfg)',
) )
i.fas.fa-fw.fa-file i.fas.fa-fw.fa-file
.ml-2.d-flex.flex-column.align-items-start .ml-2.d-flex.flex-column.align-items-start
div {{cfg.name}} div {{cfg.name}}
small.text-muted Modified on {{cfg.modified_at|date:'medium'}} small.text-muted Modified on {{cfg.modified_at|date:'medium'}}
.badge.badge-info(*ngIf='cfg.id === config.store.configSync.configID') ACTIVE .badge.badge-info(*ngIf='isActiveConfig(cfg)') ACTIVE
.mr-auto .mr-auto
button.btn.btn-link.ml-1( button.btn.btn-link.ml-1(
(click)='uploadAndSync(cfg)', (click)='uploadAndSync(cfg)',
[class.hover-reveal]='cfg.id !== config.store.configSync.configID' [class.hover-reveal]='!isActiveConfig(cfg)'
) )
i.fas.fa-arrow-up i.fas.fa-arrow-up
span.ml-2 Upload span.ml-2(*ngIf='isActiveConfig(cfg)') Upload
span.ml-2(*ngIf='!isActiveConfig(cfg)') Replace
button.btn.btn-link.ml-1( button.btn.btn-link.ml-1(
(click)='downloadAndSync(cfg)', (click)='downloadAndSync(cfg)',
[class.hover-reveal]='cfg.id !== config.store.configSync.configID' [class.hover-reveal]='!isActiveConfig(cfg)'
) )
i.fas.fa-arrow-down i.fas.fa-arrow-down
span.ml-2 Download span.ml-2 Download
@ -76,7 +81,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
i.fas.fa-fw.fa-cloud-upload-alt i.fas.fa-fw.fa-cloud-upload-alt
.ml-2 Upload as a new config .ml-2 Upload as a new config
ng-container(*ngIf='config.store.configSync.configID') ng-container(*ngIf='hasMatchingRemoteConfig()')
.form-line .form-line
.header .header
.title Sync automatically .title Sync automatically

View File

@ -17,10 +17,10 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
constructor ( constructor (
public config: ConfigService, public config: ConfigService,
public platform: PlatformService,
private configSync: ConfigSyncService, private configSync: ConfigSyncService,
private hostApp: HostAppService, private hostApp: HostAppService,
private ngbModal: NgbModal, private ngbModal: NgbModal,
private platform: PlatformService,
private notifications: NotificationsService, private notifications: NotificationsService,
) { ) {
super() super()
@ -96,4 +96,12 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
await this.configSync.download() await this.configSync.download()
this.notifications.info('Config downloaded') this.notifications.info('Config downloaded')
} }
hasMatchingRemoteConfig () {
return !!this.configs?.find(c => this.isActiveConfig(c))
}
isActiveConfig (c: Config) {
return c.id === this.config.store.configSync.configID
}
} }

View File

@ -29,7 +29,7 @@ button.btn.btn-warning.btn-block(*ngIf='config.restartRequested', '(click)'='res
i.fas.fa-book i.fas.fa-book
span What's new span What's new
button.btn.btn-secondary( button.btn.btn-secondary.mr-3.mb-2(
*ngIf='!updateAvailable && hostApp.platform !== Platform.Web', *ngIf='!updateAvailable && hostApp.platform !== Platform.Web',
(click)='checkForUpdates()', (click)='checkForUpdates()',
[disabled]='checkingForUpdate' [disabled]='checkingForUpdate'
@ -39,7 +39,7 @@ button.btn.btn-warning.btn-block(*ngIf='config.restartRequested', '(click)'='res
) )
span Check for updates span Check for updates
button.btn.btn-info( button.btn.btn-info.mr-3.mb-2(
*ngIf='updateAvailable', *ngIf='updateAvailable',
(click)='updater.update()', (click)='updater.update()',
) )