Tenant crud part 1
[groupbasedpolicy.git] / groupbasedpolicy-ui / module / src / main / resources / gbp / tenant / tenant.controller.js
1 define([
2     'app/gbp/tenant/tenant.service',
3     'app/gbp/tenant/tenant-list.service',
4 ], function () {
5     'use strict';
6
7     angular.module('app.gbp').controller('TenantController', TenantController);
8
9     TenantController.$inject = ['$mdDialog', '$scope', 'TenantListService'];
10     /* @ngInject */
11     function TenantController($mdDialog, $scope, TenantListService) {
12         /* properties */
13         $scope.tenants = TenantListService.createList();
14         $scope.tenantsTableQuery = {};
15
16         /* methods */
17         $scope.getTenantList = getTenantList;
18         $scope.openTenantDialog = openTenantDialog;
19
20         init();
21
22         /* Implementations */
23
24         /**
25          * fills $scope.tenants array with data from data store
26          */
27         function getTenantList() {
28             $scope.tenants.get('config');
29         }
30
31         /**
32          * Initializing function
33          */
34         function init() {
35             $scope.tenantsTableQuery = {
36                 order: "data.id",
37                 limit: 25,
38                 page: 1,
39                 options: [25, 50, 100],
40                 filter: ''
41             };
42
43             getTenantList();
44         }
45
46         function openTenantDialog() {
47             $mdDialog.show({
48                 clickOutsideToClose: true,
49                 controller: 'AddTenantController',
50                 preserveScope: true,
51                 templateUrl: 'src/app/gbp/tenant/dialog-add-tenant.tpl.html',
52                 parent: angular.element(document.body),
53                 scope: $scope,
54                 locals: {
55                     //policy: $scope.selectedObjects.policy
56                 }
57             });
58         }
59
60
61     }
62 });