Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 1 | /* |
| 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 Cole | e2958f2 | 2015-05-26 17:18:23 -0700 | [diff] [blame^] | 20 | 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 Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 25 | angular.module('cordUser', []) |
Bri Prebilic Cole | e2958f2 | 2015-05-26 17:18:23 -0700 | [diff] [blame^] | 26 | .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 Cole | 3c3361c | 2015-05-19 12:07:29 -0700 | [diff] [blame] | 66 | |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 67 | $log.debug('Cord User Ctrl has been created.'); |
Bri Prebilic Cole | e2958f2 | 2015-05-26 17:18:23 -0700 | [diff] [blame^] | 68 | }]) |
| 69 | .directive('editUser', [function () { |
| 70 | return { |
| 71 | link: function (scope, elem) { |
| 72 | |
| 73 | } |
| 74 | }; |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 75 | }]); |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 76 | |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 77 | }()); |