blob: c02af54e805e4af4a3ae44ccec93e1e1bc1c5bf5 [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 Cole10570eb2015-05-20 16:23:52 -070020 var $log, $resource;
21
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070022 var url = 'http://localhost:8080/rs/bundle';
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070023
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070024 var basic = 'basic',
25 family = 'family',
26 current,
27 avCb;
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070028
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070029 angular.module('cordBundle', [])
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070030 .controller('CordBundleCtrl', ['$log', '$scope', '$resource',
31 function (_$log_, $scope, _$resource_) {
32 var BundleData, resource;
Bri Prebilic Cole3c3361c2015-05-19 12:07:29 -070033 $scope.page = 'bundle';
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070034 $log = _$log_;
35 $resource = _$resource_;
36
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070037 BundleData = $resource(url);
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070038 resource = BundleData.get({},
39 // success
40 function () {
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070041 current = resource.bundle.id;
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070042 $scope.name = resource.bundle.name;
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070043 $scope.desc = resource.bundle.desc;
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070044 $scope.funcs = resource.bundle.functions;
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070045 avCb(resource);
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070046 },
47 // error
48 function () {
49 $log.error('Problem with resource', resource);
50 });
Bri Prebilic Cole3c3361c2015-05-19 12:07:29 -070051
52 $log.debug('Cord Bundle Ctrl has been created.');
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070053 }])
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070054
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070055 .controller('CordAvailable', ['$scope',
56 function ($scope) {
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070057 avCb = function (resource) {
58 $scope.id = (current === basic) ? family : basic;
59 $scope.bundles = resource.bundles;
60
61 $scope.bundles.forEach(function (bundle) {
62 if (bundle.id === $scope.id) {
63 $scope.available = bundle;
64 }
65 });
66 };
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070067
68 $log.debug('Cord Available Ctrl has been created.');
69 }])
70
71 .directive('bundleAvailable', function () {
72 return {
73 templateUrl: 'app/view/bundle/available.html'
74 };
75 });
Bri Prebilic Colee0311892015-05-15 11:27:15 -070076}());