Skip to content

Commit

Permalink
Merge pull request #2495 from freenas/NAS-102362
Browse files Browse the repository at this point in the history
Nas 102362
  • Loading branch information
erincodepirate committed Jul 10, 2019
2 parents 86d628c + a38ec21 commit 0da5afa
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 24 deletions.
9 changes: 8 additions & 1 deletion src/app/helptext/storage/volumes/volume-key.ts
Expand Up @@ -4,7 +4,8 @@ import { T } from '../../../translate-marker';
export default {
// Add key form
add_key_name_validation: [Validators.required],

add_key_instructions: T('Adding a recovery key invalidates any previous recovery key.\
A dialog will open to save a backup of the new recovery key.'),
add_key_password_placeholder: T('Root password'),
add_key_password_tooltip: T('Enter the root password to authorize this operation.'),
add_key_password_validation: [Validators.required],
Expand All @@ -14,10 +15,14 @@ changekey_adminpw_placeholder: T('Root Password'),
changekey_adminpw_tooltip: T('Enter the root password.'),
changekey_adminpw_validation: [Validators.required],

changekey_instructions: T('Creating a passphrase requires the creation of a new\
recovery key. A dialog will open to save a backup of the new recovery key.'),
changekey_passphrase_placeholder: T('Passphrase'),
changekey_passphrase_tooltip: T('Enter the GELI passphrase.'),
changekey_passphrase_validation: [Validators.required],

changekey_instructions2: T('Changing the passphrase requires the creation of a new\
recovery key. A dialog will open to save a backup of the new recovery key.'),
changekey_passphrase2_placeholder: T('Verify passphrase'),
changekey_passphrase2_tooltip: T('Confirm the GELI passphrase.'),
changekey_passphrase2_validation: [Validators.required],
Expand All @@ -35,6 +40,8 @@ createkey_passphrase2_tooltip: T('Confirm the GELI passphrase.'),
createkey_passphrase2_validation: [Validators.required],

// Rekey form
rekey_instructions: T('Generate a new GELI key, replacing the old one on the disks in the pool.\
Passphrases will be removed by this operation. <br>A dialog will open to save a backup of the new recovery key.'),
rekey_password_label: T('Passphrase'),
rekey_password_placeholder: T('Root password'),
rekey_password_tooltip: T('Enter the root password to authorize this operation.'),
Expand Down
Expand Up @@ -5,17 +5,18 @@ import {
} from '@angular/core';

import { ActivatedRoute, Router } from '@angular/router';
import { MatSnackBar } from '@angular/material';
import * as _ from 'lodash';

import { RestService, WebSocketService, StorageService } from '../../../../services/';
import {
FieldConfig
} from '../../../common/entity/entity-form/models/field-config.interface';
import { DialogService } from 'app/services/dialog.service';
import { MatSnackBar, MatDialog } from '@angular/material';
import { Formconfiguration } from 'app/pages/common/entity/entity-form/entity-form.component';
import { AppLoaderService } from '../../../../services/app-loader/app-loader.service';
import { T } from '../../../../translate-marker';
import { DownloadKeyModalDialog } from '../../../../components/common/dialog/downloadkey/downloadkey-dialog.component';
import helptext from '../../../../helptext/storage/volumes/volume-key';

@Component({
Expand All @@ -36,6 +37,11 @@ export class VolumeAddkeyFormComponent implements Formconfiguration {
};

fieldConfig: FieldConfig[] = [
{
type: 'paragraph',
name: 'addkey-instructions',
paraText: helptext.add_key_instructions,
},
{
type : 'input',
name : 'name',
Expand Down Expand Up @@ -68,7 +74,8 @@ export class VolumeAddkeyFormComponent implements Formconfiguration {
protected dialogService: DialogService,
protected loader: AppLoaderService,
protected storage: StorageService,
protected snackBar: MatSnackBar
protected snackBar: MatSnackBar,
protected mdDialog: MatDialog
) {

}
Expand All @@ -90,9 +97,12 @@ export class VolumeAddkeyFormComponent implements Formconfiguration {
this.rest.post(this.resource_name + "/" + this.pk + "/recoverykey/", {}).subscribe((restPostResp) => {
this.loader.close();
this.snackBar.open(T("Recovery key added to pool ") + value.name, 'close', { duration: 5000 });
this.storage.downloadFile('geli_recovery.key', restPostResp.data.content, 'application/octet-stream');
this.router.navigate(new Array('/').concat(
this.route_success));
let dialogRef = this.mdDialog.open(DownloadKeyModalDialog, {disableClose:true});
dialogRef.componentInstance.volumeId = this.pk;
dialogRef.afterClosed().subscribe(result => {
this.router.navigate(new Array('/').concat(
this.route_success));
})
}, (res) => {
this.loader.close();
this.dialogService.errorReport(T("Error adding recovery key to pool."), res.error.error_message, res.error.traceback);
Expand Down
Expand Up @@ -12,8 +12,10 @@ import {
FieldConfig
} from '../../../common/entity/entity-form/models/field-config.interface';
import { DialogService } from 'app/services/dialog.service';
import { MatSnackBar, MatDialog } from '@angular/material';
import { Formconfiguration } from 'app/pages/common/entity/entity-form/entity-form.component';
import { AppLoaderService } from '../../../../services/app-loader/app-loader.service';
import { DownloadKeyModalDialog } from '../../../../components/common/dialog/downloadkey/downloadkey-dialog.component';
import { T } from '../../../../translate-marker';
import helptext from '../../../../helptext/storage/volumes/volume-key';

Expand All @@ -40,6 +42,10 @@ export class VolumeChangekeyFormComponent implements Formconfiguration {
type : 'input',
name : 'name',
isHidden: true
},{
type: 'paragraph',
name: 'changekey-instructions',
paraText: helptext.changekey_instructions2
},{
type : 'input',
inputType: 'password',
Expand Down Expand Up @@ -89,7 +95,9 @@ export class VolumeChangekeyFormComponent implements Formconfiguration {
protected _injector: Injector,
protected _appRef: ApplicationRef,
protected dialogService: DialogService,
protected loader: AppLoaderService
protected loader: AppLoaderService,
public mdDialog: MatDialog,
public snackBar: MatSnackBar
) {

}
Expand Down Expand Up @@ -132,10 +140,15 @@ export class VolumeChangekeyFormComponent implements Formconfiguration {
this.loader.open();
this.ws.call('pool.passphrase', params).subscribe(() => {
this.loader.close();
this.dialogService.Info(T("Change Pool Passphrase"), T("Passphrase " + success_msg + " pool ") + value.name)
.subscribe(() => {
this.router.navigate(new Array('/').concat(this.route_success));
})
this.snackBar.open(T('Passphrase changed for pool ' + value.name), T("Close"), {
duration: 5000,
});
let dialogRef = this.mdDialog.open(DownloadKeyModalDialog, {disableClose:true});
dialogRef.componentInstance.volumeId = this.pk;
dialogRef.afterClosed().subscribe(result => {
this.router.navigate(new Array('/').concat(
this.route_success));
});
},(err) => {
this.loader.close();
this.dialogService.errorReport(T("Error changing passphrase for pool ") + value.name, err.reason, err.trace.formatted);
Expand Down
Expand Up @@ -12,9 +12,11 @@ import {
FieldConfig
} from '../../../common/entity/entity-form/models/field-config.interface';
import { DialogService } from 'app/services/dialog.service';
import { MatSnackBar, MatDialog } from '@angular/material';
import { Formconfiguration } from 'app/pages/common/entity/entity-form/entity-form.component';
import { AppLoaderService } from '../../../../services/app-loader/app-loader.service';
import { T } from '../../../../translate-marker';
import { DownloadKeyModalDialog } from '../../../../components/common/dialog/downloadkey/downloadkey-dialog.component';
import helptext from '../../../../helptext/storage/volumes/volume-key';

@Component({
Expand All @@ -40,6 +42,10 @@ export class VolumeCreatekeyFormComponent implements Formconfiguration {
type : 'input',
name : 'name',
isHidden: true
},{
type: 'paragraph',
name: 'createkey-instructions',
paraText: helptext.changekey_instructions
},{
type : 'input',
inputType: 'password',
Expand Down Expand Up @@ -73,7 +79,9 @@ export class VolumeCreatekeyFormComponent implements Formconfiguration {
protected _injector: Injector,
protected _appRef: ApplicationRef,
protected dialogService: DialogService,
protected loader: AppLoaderService
protected loader: AppLoaderService,
private snackBar: MatSnackBar,
private mdDialog: MatDialog
) {

}
Expand All @@ -90,13 +98,17 @@ export class VolumeCreatekeyFormComponent implements Formconfiguration {

customSubmit(value) {
this.loader.open();

return this.rest.post(this.resource_name + "/" + this.pk + "/keypassphrase/", { body: JSON.stringify({passphrase: value.passphrase, passphrase2: value.passphrase2}) }).subscribe((restPostResp) => {
this.loader.close();
this.dialogService.Info(T("Create Pool Passphrase"), T("Passphrase created for pool ") + value.name);

this.router.navigate(new Array('/').concat(
this.route_success));
this.snackBar.open(T('Passphrase created for pool ') + value.name, T("Close"), {
duration: 5000,
});
let dialogRef = this.mdDialog.open(DownloadKeyModalDialog, {disableClose:true});
dialogRef.componentInstance.volumeId = this.pk;
dialogRef.afterClosed().subscribe(result => {
this.router.navigate(new Array('/').concat(
this.route_success));
});
}, (res) => {
this.loader.close();
this.dialogService.errorReport(T("Error creating passphrase for pool ") + value.name, res.error.message, res.error.traceback);
Expand Down
Expand Up @@ -12,8 +12,10 @@ import {
FieldConfig
} from '../../../common/entity/entity-form/models/field-config.interface';
import { DialogService } from 'app/services/dialog.service';
import { MatSnackBar, MatDialog } from '@angular/material';
import { Formconfiguration } from 'app/pages/common/entity/entity-form/entity-form.component';
import { AppLoaderService } from '../../../../services/app-loader/app-loader.service';
import { DownloadKeyModalDialog } from '../../../../components/common/dialog/downloadkey/downloadkey-dialog.component';
import { T } from '../../../../translate-marker';
import helptext from '../../../../helptext/storage/volumes/volume-key';

Expand All @@ -39,6 +41,10 @@ export class VolumeRekeyFormComponent implements Formconfiguration {
type : 'input',
name : 'name',
isHidden: true
},{
type: 'paragraph',
name: 'rekey-instructions',
paraText: helptext.rekey_instructions
},{
type : 'input',
inputType: 'password',
Expand All @@ -64,7 +70,9 @@ export class VolumeRekeyFormComponent implements Formconfiguration {
protected _injector: Injector,
protected _appRef: ApplicationRef,
protected dialogService: DialogService,
protected loader: AppLoaderService
protected loader: AppLoaderService,
protected snackBar: MatSnackBar,
protected mdDialog: MatDialog
) {

}
Expand All @@ -82,12 +90,18 @@ export class VolumeRekeyFormComponent implements Formconfiguration {
customSubmit(value) {
this.loader.open();

return this.rest.post(this.resource_name + "/" + this.pk + "/rekey/", { body: JSON.stringify({passphrase: value.passphrase}) }).subscribe((restPostResp) => {
this.loader.close();
this.dialogService.Info(T("Re-keyed Pool"), T("Successfully re-keyed pool ") + value.name);

this.router.navigate(new Array('/').concat(
this.route_success));
return this.rest.post(this.resource_name + "/" + this.pk + "/rekey/",
{ body: JSON.stringify({passphrase: value.passphrase}) }).subscribe((restPostResp) => {
this.loader.close();
this.snackBar.open(T('Successfully re-keyed pool ') + value.name, T("Close"), {
duration: 5000,
});
let dialogRef = this.mdDialog.open(DownloadKeyModalDialog, {disableClose:true});
dialogRef.componentInstance.volumeId = this.pk;
dialogRef.afterClosed().subscribe(result => {
this.router.navigate(new Array('/').concat(
this.route_success));
});
}, (res) => {
this.loader.close();
this.dialogService.errorReport(T("Error re-keying pool"), res.error, res.trace.formatted);
Expand Down

0 comments on commit 0da5afa

Please sign in to comment.