|
|
|
@ -6,7 +6,7 @@ import _ from 'lodash'; |
|
|
|
|
|
|
|
|
|
export class AclCtrl { |
|
|
|
|
dashboard: any; |
|
|
|
|
aclItems: DashboardAcl[]; |
|
|
|
|
items: DashboardAcl[]; |
|
|
|
|
permissionOptions = [ |
|
|
|
|
{value: 1, text: 'View'}, |
|
|
|
|
{value: 2, text: 'Edit'}, |
|
|
|
@ -19,12 +19,13 @@ export class AclCtrl { |
|
|
|
|
{value: 'Editor', text: 'Everyone With Editor Role'} |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
dismiss: () => void; |
|
|
|
|
newType: string; |
|
|
|
|
canUpdate: boolean; |
|
|
|
|
|
|
|
|
|
/** @ngInject */ |
|
|
|
|
constructor(private backendSrv, private dashboardSrv, private $sce, private $scope) { |
|
|
|
|
this.aclItems = []; |
|
|
|
|
this.items = []; |
|
|
|
|
this.resetNewType(); |
|
|
|
|
this.dashboard = dashboardSrv.getCurrent(); |
|
|
|
|
this.get(this.dashboard.id); |
|
|
|
@ -37,7 +38,7 @@ export class AclCtrl { |
|
|
|
|
get(dashboardId: number) { |
|
|
|
|
return this.backendSrv.get(`/api/dashboards/id/${dashboardId}/acl`) |
|
|
|
|
.then(result => { |
|
|
|
|
this.aclItems = _.map(result, this.prepareViewModel.bind(this)); |
|
|
|
|
this.items = _.map(result, this.prepareViewModel.bind(this)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -58,7 +59,7 @@ export class AclCtrl { |
|
|
|
|
|
|
|
|
|
update() { |
|
|
|
|
return this.backendSrv.post(`/api/dashboards/id/${this.dashboard.id}/acl`, { |
|
|
|
|
acl: this.aclItems.map(item => { |
|
|
|
|
items: this.items.map(item => { |
|
|
|
|
return { |
|
|
|
|
id: item.id, |
|
|
|
|
userId: item.userId, |
|
|
|
@ -67,12 +68,14 @@ export class AclCtrl { |
|
|
|
|
permission: item.permission, |
|
|
|
|
}; |
|
|
|
|
}) |
|
|
|
|
}).then(() => { |
|
|
|
|
this.dismiss(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
typeChanged() { |
|
|
|
|
if (this.newType === 'Viewer' || this.newType === 'Editor') { |
|
|
|
|
this.aclItems.push(this.prepareViewModel({ |
|
|
|
|
this.items.push(this.prepareViewModel({ |
|
|
|
|
permission: 1, |
|
|
|
|
role: this.newType |
|
|
|
|
})); |
|
|
|
@ -87,7 +90,7 @@ export class AclCtrl { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
userPicked(user) { |
|
|
|
|
this.aclItems.push(this.prepareViewModel({ |
|
|
|
|
this.items.push(this.prepareViewModel({ |
|
|
|
|
userId: user.id, |
|
|
|
|
userLogin: user.login, |
|
|
|
|
permission: 1, |
|
|
|
@ -99,7 +102,7 @@ export class AclCtrl { |
|
|
|
|
|
|
|
|
|
groupPicked(group) { |
|
|
|
|
console.log(group); |
|
|
|
|
this.aclItems.push(this.prepareViewModel({ |
|
|
|
|
this.items.push(this.prepareViewModel({ |
|
|
|
|
userGroupId: group.id, |
|
|
|
|
userGroup: group.name, |
|
|
|
|
permission: 1, |
|
|
|
@ -110,7 +113,7 @@ export class AclCtrl { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removeItem(index) { |
|
|
|
|
this.aclItems.splice(index, 1); |
|
|
|
|
this.items.splice(index, 1); |
|
|
|
|
this.canUpdate = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|