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 | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 20 | var $log, $resource; |
| 21 | |
| 22 | var before = 'http://localhost:8080/rs/bundle/0', |
| 23 | after = 'http://localhost:8080/rs/bundle/1'; |
| 24 | |
| 25 | var basic = 'Basic Bundle', |
| 26 | family = 'Family Bundle', |
| 27 | current, which, |
| 28 | avScope; |
| 29 | |
| 30 | function getAvailable(scope) { |
| 31 | var AvailableData, resource; |
| 32 | |
| 33 | AvailableData = $resource(which); |
| 34 | resource = AvailableData.get({}, |
| 35 | // success |
| 36 | function () { |
| 37 | scope.name = resource.bundle.name; |
| 38 | scope.funcs = resource.bundle.functions; |
| 39 | }, |
| 40 | // error |
| 41 | function () { |
| 42 | $log.error('Problem with resource', resource); |
| 43 | }); |
| 44 | $log.debug('Resource received:', resource); |
| 45 | } |
| 46 | |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 47 | angular.module('cordBundle', []) |
Bri Prebilic Cole | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 48 | .controller('CordBundleCtrl', ['$log', '$scope', '$resource', |
| 49 | function (_$log_, $scope, _$resource_) { |
| 50 | var BundleData, resource; |
Bri Prebilic Cole | 3c3361c | 2015-05-19 12:07:29 -0700 | [diff] [blame] | 51 | $scope.page = 'bundle'; |
Bri Prebilic Cole | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 52 | $log = _$log_; |
| 53 | $resource = _$resource_; |
| 54 | |
| 55 | BundleData = $resource(after); |
| 56 | resource = BundleData.get({}, |
| 57 | // success |
| 58 | function () { |
| 59 | $scope.name = resource.bundle.name; |
| 60 | current = $scope.name; |
| 61 | $scope.funcs = resource.bundle.functions; |
| 62 | |
| 63 | which = (current === basic) ? after : before; |
| 64 | getAvailable(avScope); |
| 65 | }, |
| 66 | // error |
| 67 | function () { |
| 68 | $log.error('Problem with resource', resource); |
| 69 | }); |
| 70 | $log.debug('Resource received:', resource); |
Bri Prebilic Cole | 3c3361c | 2015-05-19 12:07:29 -0700 | [diff] [blame] | 71 | |
| 72 | $log.debug('Cord Bundle Ctrl has been created.'); |
Bri Prebilic Cole | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 73 | }]) |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 74 | |
Bri Prebilic Cole | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 75 | .controller('CordAvailable', ['$scope', |
| 76 | function ($scope) { |
| 77 | avScope = $scope; |
| 78 | |
| 79 | $log.debug('Cord Available Ctrl has been created.'); |
| 80 | }]) |
| 81 | |
| 82 | .directive('bundleAvailable', function () { |
| 83 | return { |
| 84 | templateUrl: 'app/view/bundle/available.html' |
| 85 | }; |
| 86 | }); |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 87 | }()); |