-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backup restore / cleanup - resolve #77
- Loading branch information
Showing
10 changed files
with
188 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Restore Homebridge Config Backup</h5> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="activeModal.dismiss('Cross click')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
<table class="table table-borderless table-hover" *ngIf="backupList.length"> | ||
<tbody> | ||
<tr *ngFor="let backup of backupList"> | ||
<td class="w-100">{{ backup.timestamp | date:'full' }}</td> | ||
<td nowrap> | ||
<a class="card-link" (click)="restore(backup.id)">Copy To Editor <i class="fas fa-arrow-right"></i></a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<div *ngIf="!backupList.length"> | ||
<h3 class="text-center">No Backups</h3> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-elegant mr-auto" (click)="deleteAllBackups()">Remove All Backups</button> | ||
<button type="button" class="btn btn-primary" data-dismiss="modal" (click)="activeModal.dismiss('Cross click')">Cancel</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { ApiService } from '../_services/api.service'; | ||
import { ToastsManager } from 'ng2-toastr/ng2-toastr'; | ||
import { createTimelineInstruction } from '@angular/animations/browser/src/dsl/animation_timeline_instruction'; | ||
|
||
@Component({ | ||
selector: 'app-config.restore-backup', | ||
templateUrl: './config.restore-backup.component.html' | ||
}) | ||
export class ConfigRestoreBackupComponent implements OnInit { | ||
public backupList: { | ||
id: string, | ||
timestamp: string, | ||
file: string | ||
}[]; | ||
|
||
constructor( | ||
public activeModal: NgbActiveModal, | ||
public toastr: ToastsManager, | ||
private $api: ApiService, | ||
) { } | ||
|
||
ngOnInit() { | ||
this.$api.getConfigBackupList().subscribe( | ||
(data: any[]) => this.backupList = data, | ||
(err) => this.toastr.error(err.error.message, 'Failed To Load Backups') | ||
); | ||
} | ||
|
||
restore(backupId) { | ||
return this.activeModal.close(backupId); | ||
} | ||
|
||
deleteAllBackups() { | ||
return this.$api.deleteConfigBackups().subscribe( | ||
(data) => { | ||
this.activeModal.dismiss(); | ||
this.toastr.success('All Backups Deleted', 'Success!'); | ||
}, | ||
(err) => this.toastr.error(err.error.message, 'Failed To Delete Backups') | ||
); | ||
} | ||
|
||
} |