Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [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 () { |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 18 | 'use strict'; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 19 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 20 | var urlSuffix = '/rs/bundle'; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 21 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 22 | var basic = 'basic', |
| 23 | family = 'family'; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 24 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 25 | angular.module('cordBundle', []) |
| 26 | .controller('CordBundleCtrl', function ($log, $scope, $resource, cordConfig) { |
| 27 | var BundleData, resource, |
| 28 | getData; |
| 29 | $scope.page.curr = 'bundle'; |
| 30 | $scope.show = false; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 31 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 32 | // set the current bundle |
| 33 | $scope.name = cordConfig.bundles[cordConfig.activeBundle].name; |
| 34 | $scope.desc = cordConfig.bundles[cordConfig.activeBundle].desc; |
| 35 | $scope.funcs = cordConfig.bundles[cordConfig.activeBundle].functions; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 36 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 37 | // set the available bundle |
| 38 | if(cordConfig.activeBundle === 0) { |
| 39 | $scope.available = cordConfig.bundles[1]; |
| 40 | } |
| 41 | else{ |
| 42 | $scope.available = cordConfig.bundles[0]; |
| 43 | } |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 44 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 45 | // switching the bundles |
| 46 | $scope.changeBundle = function (id) { |
| 47 | if(cordConfig.activeBundle === 0){ |
| 48 | cordConfig.activeBundle = 1; |
| 49 | $scope.available = cordConfig.bundles[0]; |
| 50 | } |
| 51 | else{ |
| 52 | cordConfig.activeBundle = 0; |
| 53 | $scope.available = cordConfig.bundles[1]; |
| 54 | } |
| 55 | $scope.name = cordConfig.bundles[cordConfig.activeBundle].name; |
| 56 | $scope.desc = cordConfig.bundles[cordConfig.activeBundle].desc; |
| 57 | $scope.funcs = cordConfig.bundles[cordConfig.activeBundle].functions; |
| 58 | }; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 59 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 60 | // hiding and showing bundles |
| 61 | $scope.showBundles = function () { |
| 62 | $scope.show = !$scope.show; |
| 63 | }; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 64 | |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 65 | $log.debug('Cord Bundle Ctrl has been created.'); |
| 66 | }) |
Matteo Scandolo | e062850 | 2016-01-27 14:42:42 -0800 | [diff] [blame] | 67 | .directive('bundleAvailable', function () { |
Matteo Scandolo | 10fb87c | 2016-01-27 14:30:22 -0800 | [diff] [blame] | 68 | return { |
| 69 | templateUrl: 'app/view/bundle/available.html' |
| 70 | }; |
Matteo Scandolo | e062850 | 2016-01-27 14:42:42 -0800 | [diff] [blame] | 71 | }); |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 72 | }()); |