mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-22 20:55:03 +03:00
feat: add button to delete remote config sync
This commit is contained in:
parent
9ceb6b4416
commit
ce6ed5267c
@ -77,6 +77,12 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
||||
)
|
||||
i.fas.fa-arrow-down
|
||||
span.ml-2(translate) Download
|
||||
button.btn.btn-link.ml-1(
|
||||
(click)='delete(cfg)',
|
||||
[class.hover-reveal]='!isActiveConfig(cfg)'
|
||||
)
|
||||
i.fas.fa-trash
|
||||
span.ml-2(translate) Delete
|
||||
a.list-group-item.list-group-item-action.d-flex.align-items-center(
|
||||
href='#',
|
||||
(click)='uploadAsNew()'
|
||||
|
@ -108,6 +108,24 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
|
||||
this.notifications.info(this.translate.instant('Config downloaded'))
|
||||
}
|
||||
|
||||
async delete (cfg: Config) {
|
||||
if ((await this.platform.showMessageBox({
|
||||
type: 'warning',
|
||||
message: this.translate.instant('Delete the config on the remote side?'),
|
||||
buttons: [
|
||||
this.translate.instant('Delete'),
|
||||
this.translate.instant('Cancel'),
|
||||
],
|
||||
defaultId: 1,
|
||||
cancelId: 1,
|
||||
})).response === 1) {
|
||||
return
|
||||
}
|
||||
await this.configSync.delete(cfg)
|
||||
this.loadConfigs()
|
||||
this.notifications.info(this.translate.instant('Config deleted'))
|
||||
}
|
||||
|
||||
hasMatchingRemoteConfig () {
|
||||
return !!this.configs?.find(c => this.isActiveConfig(c))
|
||||
}
|
||||
|
@ -75,6 +75,10 @@ export class ConfigSyncService {
|
||||
})
|
||||
}
|
||||
|
||||
async deleteConfig (id: number): Promise<any> {
|
||||
return this.request('DELETE', `/api/1/configs/${id}`)
|
||||
}
|
||||
|
||||
setConfig (config: Config): void {
|
||||
this.config.store.configSync.configID = config.id
|
||||
this.config.save()
|
||||
@ -133,6 +137,16 @@ export class ConfigSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
async delete (config: Config): Promise<void> {
|
||||
try {
|
||||
await this.deleteConfig(config.id)
|
||||
this.logger.debug('Config deleted')
|
||||
} catch (error) {
|
||||
this.logger.error('Delete failed:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
private async readConfigDataForSync (): Promise<any> {
|
||||
const data = yaml.load(await this.platform.loadConfig()) as any
|
||||
delete data.configSync
|
||||
@ -145,7 +159,7 @@ export class ConfigSyncService {
|
||||
await this.config.save()
|
||||
}
|
||||
|
||||
private async request (method: 'GET'|'POST'|'PATCH', url: string, params = {}) {
|
||||
private async request (method: 'GET'|'POST'|'PATCH'|'DELETE', url: string, params = {}) {
|
||||
if (this.config.store.configSync.host.endsWith('/')) {
|
||||
this.config.store.configSync.host = this.config.store.configSync.host.slice(0, -1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user