mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
* cifs for cloud backups on lan * password spelling fix * fix spelling and fix rpc method * fix other methods * remove old code and rename method * add support for cifs backup targets wip cifs api simplify idiom add doc comment wip wip should work™ * add password hash to server info * fix type * fix types for cifs * minor fixes for cifs feature * fix rpc structure * fix copy, address some TODOs * add subcommand * backup path and navigation * wizard edits * rebased success page * wiz conflicts resolved * current change actually * only unsub if done * no fileter if necessary * fix copy for cifs old password * setup complete (#913) * setup complete * minor fixes * setup.complete * complete bool * setup-wizard: complete boolean Co-authored-by: Matt Hill <matthewonthemoon@gmail.com> Co-authored-by: Drew Ansbacher <drew.ansbacher@spiredigital.com> Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import { Component } from '@angular/core'
|
|
import { AlertController, LoadingController, ModalController } from '@ionic/angular'
|
|
import { ApiService, BackupTarget, CifsBackupTarget, EmbassyOSRecoveryInfo } from 'src/app/services/api/api.service'
|
|
import { PasswordPage } from '../password/password.page'
|
|
|
|
@Component({
|
|
selector: 'cifs-modal',
|
|
templateUrl: 'cifs-modal.page.html',
|
|
styleUrls: ['cifs-modal.page.scss'],
|
|
})
|
|
export class CifsModal {
|
|
cifs = {
|
|
hostname: '',
|
|
path: '',
|
|
username: '',
|
|
password: '',
|
|
}
|
|
|
|
constructor (
|
|
private readonly modalController: ModalController,
|
|
private readonly apiService: ApiService,
|
|
private readonly loadingCtrl: LoadingController,
|
|
private readonly alertCtrl: AlertController,
|
|
) { }
|
|
|
|
cancel () {
|
|
this.modalController.dismiss()
|
|
}
|
|
|
|
async submit (): Promise<void> {
|
|
const loader = await this.loadingCtrl.create({
|
|
spinner: 'lines',
|
|
message: 'Connecting to shared folder...',
|
|
cssClass: 'loader',
|
|
})
|
|
await loader.present()
|
|
|
|
try {
|
|
const embassyOS = await this.apiService.verifyCifs(this.cifs)
|
|
this.presentModalPassword(embassyOS)
|
|
} catch (e) {
|
|
this.presentAlertFailed()
|
|
} finally {
|
|
loader.dismiss()
|
|
}
|
|
}
|
|
|
|
private async presentModalPassword (embassyOS: EmbassyOSRecoveryInfo): Promise<void> {
|
|
const target: CifsBackupTarget = {
|
|
type: 'cifs',
|
|
...this.cifs,
|
|
mountable: true,
|
|
'embassy-os': embassyOS,
|
|
}
|
|
|
|
const modal = await this.modalController.create({
|
|
component: PasswordPage,
|
|
componentProps: { target },
|
|
cssClass: 'alertlike-modal',
|
|
})
|
|
modal.onDidDismiss().then(res => {
|
|
if (res.role === 'success') {
|
|
this.modalController.dismiss({
|
|
cifs: this.cifs,
|
|
recoveryPassword: res.data.password,
|
|
}, 'success')
|
|
}
|
|
})
|
|
await modal.present()
|
|
}
|
|
|
|
private async presentAlertFailed (): Promise<void> {
|
|
const alert = await this.alertCtrl.create({
|
|
header: 'Connection Failed',
|
|
message: 'Unable to connect to shared folder. Ensure (1) target computer is connected to LAN, (2) target folder is being shared, and (3) hostname, path, and credentials are accurate.',
|
|
buttons: ['OK'],
|
|
})
|
|
alert.present()
|
|
}
|
|
}
|
|
|
|
interface MappedCifs {
|
|
hasValidBackup: boolean
|
|
cifs: CifsBackupTarget
|
|
}
|