Sending event from table to groups controller

This commit is contained in:
Jesús Ángel 2018-12-10 17:47:18 +01:00
parent f77b06d726
commit 895d960cdd
2 changed files with 27 additions and 15 deletions

View File

@ -128,6 +128,10 @@ export function GroupsController(
return $scope.showFile(parameters.groupName, parameters.fileName);
});
$scope.$on('updateGroupInformation', (event, parameters) => {
console.log('Event updateGroupInformation received');
});
$scope.goBackToAgents = () => {
$scope.groupsSelectedTab = 'agents';
$scope.file = false;

View File

@ -256,21 +256,29 @@ app.directive('wzTable', function() {
$scope.showConfirm = function(ev, agent) {
const group = instance.path.split('/').pop();
// Appending dialog to document.body to cover sidenav in docs app
var confirm = $mdDialog.confirm()
const confirm = $mdDialog
.confirm()
.title(`Delete agent ${agent.id} from group ${group}?`)
.targetEvent(ev)
.ok('Agree')
.cancel('Cancel');
$mdDialog.show(confirm).then(() => {
groupHandler.removeAgentFromGroup(group, agent.id).then(()=> init()).catch(error => errorHandler.handle(
$mdDialog.show(confirm).then(
() => {
groupHandler
.removeAgentFromGroup(group, agent.id)
.then(() => init())
.then(() => $scope.$emit('updateGroupInformation', { group }))
.catch(error =>
errorHandler.handle(
error.message || error,
'Error removing agent from group'
))
}, () => {
});
)
);
},
() => {}
);
};
},
template