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 | f3eba31 | 2015-05-21 16:35:06 -0700 | [diff] [blame] | 20 | var url = 'http://localhost:8080/rs/bundle'; |
Bri Prebilic Cole | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 21 | |
Bri Prebilic Cole | f3eba31 | 2015-05-21 16:35:06 -0700 | [diff] [blame] | 22 | var basic = 'basic', |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 23 | family = 'family'; |
Bri Prebilic Cole | d050a4b | 2015-05-27 15:53:30 -0700 | [diff] [blame] | 24 | |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 25 | angular.module('cordBundle', []) |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 26 | .controller('CordBundleCtrl', ['$log', '$scope', '$resource', |
| 27 | function ($log, $scope, $resource) { |
| 28 | var BundleData, resource, |
| 29 | getData; |
| 30 | $scope.page = 'bundle'; |
Bri Prebilic Cole | f3eba31 | 2015-05-21 16:35:06 -0700 | [diff] [blame] | 31 | |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 32 | getData = function (id) { |
| 33 | if (!id) { id = ''; } |
| 34 | |
| 35 | BundleData = $resource(url + '/' + id); |
| 36 | resource = BundleData.get({}, |
| 37 | // success |
| 38 | function () { |
| 39 | var current, availId; |
| 40 | current = resource.bundle.id; |
| 41 | $scope.name = resource.bundle.name; |
| 42 | $scope.desc = resource.bundle.desc; |
| 43 | $scope.funcs = resource.bundle.functions; |
| 44 | |
| 45 | availId = (current === basic) ? family : basic; |
| 46 | resource.bundles.forEach(function (bundle) { |
| 47 | if (bundle.id === availId) { |
| 48 | $scope.available = bundle; |
| 49 | } |
| 50 | }); |
| 51 | }, |
| 52 | // error |
| 53 | function () { |
| 54 | $log.error('Problem with resource', resource); |
| 55 | }); |
Bri Prebilic Cole | f3eba31 | 2015-05-21 16:35:06 -0700 | [diff] [blame] | 56 | }; |
Bri Prebilic Cole | 10570eb | 2015-05-20 16:23:52 -0700 | [diff] [blame] | 57 | |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 58 | getData(); |
Bri Prebilic Cole | d050a4b | 2015-05-27 15:53:30 -0700 | [diff] [blame] | 59 | |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 60 | $scope.changeBundle = function (id) { |
| 61 | getData(id); |
| 62 | }; |
Bri Prebilic Cole | d050a4b | 2015-05-27 15:53:30 -0700 | [diff] [blame] | 63 | |
| 64 | $log.debug('Cord Bundle Ctrl has been created.'); |
| 65 | }]) |
| 66 | |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 67 | .directive('bundleAvailable', [function () { |
Bri Prebilic Cole | d050a4b | 2015-05-27 15:53:30 -0700 | [diff] [blame] | 68 | return { |
Bri Prebilic Cole | d3d7a32 | 2015-05-28 14:15:14 -0700 | [diff] [blame^] | 69 | templateUrl: 'app/view/bundle/available.html' |
Bri Prebilic Cole | d050a4b | 2015-05-27 15:53:30 -0700 | [diff] [blame] | 70 | }; |
Bri Prebilic Cole | bdd6b3b | 2015-05-22 15:44:18 -0700 | [diff] [blame] | 71 | }]); |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 72 | }()); |