Skip to content

Instantly share code, notes, and snippets.

@xirdneh
Last active June 21, 2018 21:40
Show Gist options
  • Save xirdneh/2b4f62125525ef65e9293d10b8e4070b to your computer and use it in GitHub Desktop.
Save xirdneh/2b4f62125525ef65e9293d10b8e4070b to your computer and use it in GitHub Desktop.
import template from './../../templates/components/push-keys.modal.html';
class SystemPushKeysController {
constructor(SystemsService){
this.SystemsService = SystemsService;
this.form = {};
this.ui = {};
//this.ok.bind(this);
}
ok(){
this.ui.loading = true;
this.SystemsService.pushKeys(
this.resolve.sys.id,
this.form
).
then((resp)=>{
this.ui.error = false;
this.ui.message = "Public Key added successfully";
return;
}, (err)=>{
this.ui.error = true;
this.ui.message = err.data.message;
}).
finally(()=>{
this.ui.loading = false;
if ( !this.ui.error ){
this.close({
$value: {
sys: this.sys,
form: this.form
}
});
}
});
}
cancel(){
this.dismiss({$value:'cancel'});
}
$onInit(){
this.form = {
password: '',
token: '',
hostname: this.resolve.sys.storage.host,
name: this.resolve.sys.name
};
}
}
SystemPushKeysController.$inject = [
'SystemsService'
];
const systemPushKeysModal = {
template: template,
bindings: {
resolve: '<',
close: '&',
dismiss: '&'
},
controller: SystemPushKeysController,
};
export default systemPushKeysModal;
$scope.openPushPublicKeyForm = ()=>{
$scope.browser.ui.pushKeyModalOpening = true;
SystemsService.get(options.system)
.then((sys)=>{
return $uibModal.open({
component: 'SystemPushKeysModal',
resolve: {
sys: ()=>{
return sys;
},
},
}).result;
}, (err)=>{
$scope.browser.error.message = err.data;
$scope.browser.error.status = err.status;
}).then(()=>{
$scope.browser = DataBrowserService.state();
$scope.browser.error = null;
$scope.browser.ui.message.class = 'alert-success';
$scope.browser.ui.message.show = true;
$scope.browser.ui.message.content = 'Public key pushed ' +
'successfully. Please click on My Data again';
}).finally(()=>{
$scope.browser.ui.pushKeyModalOpening = false;
});
};
import angular from 'angular';
import SystemPushKeysModal from './systems/push-keys.modal.js';
let mod = angular.module('portal.workbench.components', []);
mod.component('systemPushKeysModal', SystemPushKeysModal);
export default mod;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment