Fixes for dlux
[unimgr.git] / dlux / cpeui / cpeui-module / src / main / resources / cpeui / tenantsTable.controller.js
1 define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
2
3   cpeui.register.controller('TenantTableCtrl', function($scope, CpeuiSvc, CpeuiDialogs, $mdDialog, $mdMedia) {
4
5     // Tenants
6
7     $scope.updateTenantView = function() {
8       CpeuiSvc.getTenantList(function(tenant_list) {
9         $scope.tenantArray = tenant_list;
10       });
11     }
12
13     $scope.AddTenant = function() {
14       CpeuiSvc.addTenant($scope.tenantId, function() {
15         $scope.updateTenantView();
16       });
17     };
18
19     $scope.tenantDialog = new CpeuiDialogs.Dialog('AddTenant', {},
20         function(obj) {
21           CpeuiSvc.addTenant(obj.id, function() {
22             $scope.updateTenantView();
23           });
24         });
25
26     $scope.OpenTenantPortal = function(tenant) {
27       $scope.currentTenent = tenant;
28       window.location = "#cpeui/tenant/" + tenant.name;
29     };
30
31     $scope.DeleteTenant = function(tenantID) {
32       CpeuiDialogs.confirm(function() {
33         CpeuiSvc.deleteTenant(tenantID, function() {
34           $scope.updateTenantView();
35         });
36       });
37     };
38
39     $scope.updateTenantView();
40   });
41 });