Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/automated backups #2142

Merged
merged 25 commits into from
May 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
initial restructuring
MattDHill committed May 9, 2023
commit 1f39d4839d373a29db5b96a3f175e430ea1e920f
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { ServerBackupPage } from './server-backup.page'
import { BackupCreatePage } from './backup-create.page'
import { BackingUpComponent } from './backing-up/backing-up.component'
import { RouterModule, Routes } from '@angular/router'
import { BackupDrivesComponentModule } from 'src/app/components/backup-drives/backup-drives.component.module'
import { BackupDrivesComponentModule } from 'src/app/pages/server-routes/backup-routes/backup-drives/backup-drives.component.module'
import { SharedPipesModule } from '@start9labs/shared'
import { BackupSelectPageModule } from 'src/app/modals/backup-select/backup-select.module'
import { PkgMainStatusPipe } from './backing-up/backing-up.component'

const routes: Routes = [
{
path: '',
component: ServerBackupPage,
component: BackupCreatePage,
},
]

@@ -25,6 +25,6 @@ const routes: Routes = [
BackupDrivesComponentModule,
BackupSelectPageModule,
],
declarations: [ServerBackupPage, BackingUpComponent, PkgMainStatusPipe],
declarations: [BackupCreatePage, BackingUpComponent, PkgMainStatusPipe],
})
export class ServerBackupPageModule {}
export class BackupCreatePageModule {}
Original file line number Diff line number Diff line change
@@ -24,12 +24,12 @@ import { getServerInfo } from 'src/app/util/get-server-info'
import { DataModel } from 'src/app/services/patch-db/data-model'

@Component({
selector: 'server-backup',
templateUrl: './server-backup.page.html',
styleUrls: ['./server-backup.page.scss'],
selector: 'backup-create',
templateUrl: './backup-create.page.html',
styleUrls: ['./backup-create.page.scss'],
providers: [TuiDestroyService],
})
export class ServerBackupPage {
export class BackupCreatePage {
serviceIds: string[] = []

readonly backingUp$ = this.eosService.backingUp$
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="system"></ion-back-button>
<ion-back-button defaultHref="backups"></ion-back-button>
</ion-buttons>
<ion-title>{{
type === 'create' ? 'Create Backup' : 'Restore From Backup'
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<div class="inline">
<h2 *ngIf="type === 'create'; else restore">
<ion-icon name="cloud-outline" color="success"></ion-icon>
{{ hasValidBackup ? 'Available, contains existing backup' : 'Available for fresh backup' }}
{{
hasValidBackup
? 'Available, contains existing backup'
: 'Available for fresh backup'
}}
</h2>
<ng-template #restore>
<h2 *ngIf="hasValidBackup">
@@ -13,4 +17,4 @@ <h2 *ngIf="!hasValidBackup">
No Embassy backup
</h2>
</ng-template>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { BackupJobsPage } from './backup-jobs.page'

const routes: Routes = [
{
path: '',
component: BackupJobsPage,
},
]

@NgModule({
imports: [CommonModule, IonicModule, RouterModule.forChild(routes)],
declarations: [BackupJobsPage],
})
export class BackupJobsPageModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="backups"></ion-back-button>
</ion-buttons>
<ion-title>Backup Jobs</ion-title>
</ion-toolbar>
</ion-header>

<ion-content class="ion-padding"> </ion-content>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core'

@Component({
selector: 'backup-jobs',
templateUrl: './backup-jobs.page.html',
styleUrls: ['./backup-jobs.page.scss'],
})
export class BackupJobsPage {
constructor() {}
}
Original file line number Diff line number Diff line change
@@ -2,15 +2,15 @@ import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { RestorePage } from './restore.component'
import { BackupRestorePage } from './backup-restore.page'
import { SharedPipesModule } from '@start9labs/shared'
import { BackupDrivesComponentModule } from 'src/app/components/backup-drives/backup-drives.component.module'
import { BackupDrivesComponentModule } from 'src/app/pages/server-routes/backup-routes/backup-drives/backup-drives.component.module'
import { AppRecoverSelectPageModule } from 'src/app/modals/app-recover-select/app-recover-select.module'

const routes: Routes = [
{
path: '',
component: RestorePage,
component: BackupRestorePage,
},
]

@@ -23,6 +23,6 @@ const routes: Routes = [
BackupDrivesComponentModule,
AppRecoverSelectPageModule,
],
declarations: [RestorePage],
declarations: [BackupRestorePage],
})
export class RestorePageModule {}
export class BackupRestorePageModule {}
Original file line number Diff line number Diff line change
@@ -19,11 +19,11 @@ import { AppRecoverSelectPage } from 'src/app/modals/app-recover-select/app-reco
import * as argon2 from '@start9labs/argon2'

@Component({
selector: 'restore',
templateUrl: './restore.component.html',
styleUrls: ['./restore.component.scss'],
selector: 'backup-restore',
templateUrl: './backup-restore.page.html',
styleUrls: ['./backup-restore.page.scss'],
})
export class RestorePage {
export class BackupRestorePage {
constructor(
private readonly modalCtrl: ModalController,
private readonly navCtrl: NavController,
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'

const routes: Routes = [
{
path: '',
loadChildren: () =>
import('./backups/backups.module').then(m => m.BackupsPageModule),
},
{
path: 'create',
loadChildren: () =>
import('./backup-create/backup-create.module').then(
m => m.BackupCreatePageModule,
),
},
{
path: 'restore',
loadChildren: () =>
import('./backup-restore/backup-restore.module').then(
m => m.BackupRestorePageModule,
),
},
{
path: 'jobs',
loadChildren: () =>
import('./backup-jobs/backup-jobs.module').then(
m => m.BackupJobsPageModule,
),
},
]

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class BackupRoutingModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { BackupsPage } from './backups.page'

const routes: Routes = [
{
path: '',
component: BackupsPage,
},
]

@NgModule({
imports: [CommonModule, IonicModule, RouterModule.forChild(routes)],
declarations: [BackupsPage],
})
export class BackupsPageModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="system"></ion-back-button>
</ion-buttons>
<ion-title>Backups</ion-title>
</ion-toolbar>
</ion-header>

<ion-content class="ion-padding">
<ion-item-group>
<ion-item button routerLink="create">
<ion-icon slot="start" name="duplicate-outline"></ion-icon>
<ion-label>
<h2>Create Backup</h2>
<p>Back up your Embassy and service data</p>
</ion-label>
</ion-item>
<ion-item button routerLink="restore">
<ion-icon slot="start" name="color-wand-outline"></ion-icon>
<ion-label>
<h2>Restore From Backup</h2>
<p>Restore one or more services from backup</p>
</ion-label>
</ion-item>
<ion-item button routerLink="jobs">
<ion-icon slot="start" name="time-outline"></ion-icon>
<ion-label>
<h2>Automated Backups</h2>
<p>Schedule jobs to perform automatic backups</p>
</ion-label>
</ion-item>
</ion-item-group>
</ion-content>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core'
import { ConfigService } from 'src/app/services/config.service'

@Component({
selector: 'backups',
templateUrl: './backups.page.html',
styleUrls: ['./backups.page.scss'],
})
export class BackupsPage {
readonly secure = this.config.isSecure()

constructor(private readonly config: ConfigService) {}
}
Original file line number Diff line number Diff line change
@@ -10,10 +10,10 @@ const routes: Routes = [
),
},
{
path: 'backup',
path: 'backups',
loadChildren: () =>
import('./server-backup/server-backup.module').then(
m => m.ServerBackupPageModule,
import('./backup-routes/backup-routing.module').then(
m => m.BackupRoutingModule,
),
},
{
@@ -41,13 +41,6 @@ const routes: Routes = [
m => m.ServerMetricsPageModule,
),
},
{
path: 'restore',
loadChildren: () =>
import('./restore/restore.component.module').then(
m => m.RestorePageModule,
),
},
{
path: 'sessions',
loadChildren: () =>
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ <h2 style="font-weight: bold">You are using unencrypted http</h2>
<h2>{{ button.title }}</h2>
<p *ngIf="button.description">{{ button.description }}</p>

<!-- "Create Backup" button only -->
<p *ngIf="button.title === 'Create Backup'">
<!-- "Backups" button only -->
<p *ngIf="button.title === 'Backups'">
<ng-container *ngIf="server['status-info'] as statusInfo">
<ion-text
[color]="server['last-backup'] | backupColor"
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import {
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { ActivatedRoute } from '@angular/router'
import { PatchDB } from 'patch-db-client'
import { combineLatest, firstValueFrom, map, Observable, of } from 'rxjs'
import { firstValueFrom, Observable, of } from 'rxjs'
import { ErrorToastService } from '@start9labs/shared'
import { EOSService } from 'src/app/services/eos.service'
import { ClientStorageService } from 'src/app/services/client-storage.service'
@@ -354,29 +354,6 @@ export class ServerShowPage {
}

settings: ServerSettings = {
Backups: [
{
title: 'Create Backup',
description: 'Back up your Embassy and service data',
icon: 'duplicate-outline',
action: () =>
this.navCtrl.navigateForward(['backup'], { relativeTo: this.route }),
detail: true,
disabled$: of(!this.secure),
},
{
title: 'Restore From Backup',
description: 'Restore one or more services from backup',
icon: 'color-wand-outline',
action: () =>
this.navCtrl.navigateForward(['restore'], { relativeTo: this.route }),
detail: true,
disabled$: combineLatest([
this.eosService.updatingOrBackingUp$,
of(this.secure),
]).pipe(map(([updating, secure]) => updating || !secure)),
},
],
Manage: [
{
title: 'Software Update',