blob: f31e1d60c3015fcbdb3ac3da07f48cf02a925e8d [file] [log] [blame]
Bri Prebilic Colee0311892015-05-15 11:27:15 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17(function () {
18 'use strict';
19
Bri Prebilic Colee2958f22015-05-26 17:18:23 -070020 var bundleUrl = 'http://localhost:8080/rs/bundle',
21 userUrl = 'http://localhost:8080/rs/users',
22 family = 'family',
23 url_filter = 'url_filter';
24
Bri Prebilic Colee0311892015-05-15 11:27:15 -070025 angular.module('cordUser', [])
Bri Prebilic Colee2958f22015-05-26 17:18:23 -070026 .controller('CordUserCtrl', ['$log', '$scope', '$resource',
27 function ($log, $scope, $resource) {
28 var BundleData, bundleResource, UserData, userResource;
29 $scope.page = 'user';
30 $scope.isFamily = false;
31 $scope.newLevels = {};
32
33 BundleData = $resource(bundleUrl);
34 bundleResource = BundleData.get({},
35 // success
36 function () {
37 var result;
38 $scope.isFamily = (bundleResource.bundle.id === family);
39 if ($scope.isFamily) {
40 result = $.grep(
41 bundleResource.bundle.functions,
42 function (elem) {
43 if (elem.id === url_filter) { return true; }
44 }
45 );
46 $scope.levels = result[0].params.levels;
47 }
48 },
49 // error
50 function () {
51 $log.error('Problem with resource', bundleResource);
52 }
53 );
54
55 UserData = $resource(userUrl);
56 userResource = UserData.get({},
57 // success
58 function () {
59 $scope.users = userResource.users;
60 },
61 // error
62 function () {
63 $log.error('Problem with resource', userResource);
64 }
65 );
Bri Prebilic Cole3c3361c2015-05-19 12:07:29 -070066
Bri Prebilic Colee0311892015-05-15 11:27:15 -070067 $log.debug('Cord User Ctrl has been created.');
Bri Prebilic Colee2958f22015-05-26 17:18:23 -070068 }])
69 .directive('editUser', [function () {
70 return {
71 link: function (scope, elem) {
72
73 }
74 };
Bri Prebilic Colee0311892015-05-15 11:27:15 -070075 }]);
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070076
Bri Prebilic Colee0311892015-05-15 11:27:15 -070077}());