blob: a65214bdd35195235e6ba85558ab8b110c90bafa [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
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 Cole8db16402015-05-18 13:50:31 -070047 angular.module('cordBundle', [])
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070048 .controller('CordBundleCtrl', ['$log', '$scope', '$resource',
49 function (_$log_, $scope, _$resource_) {
50 var BundleData, resource;
Bri Prebilic Cole3c3361c2015-05-19 12:07:29 -070051 $scope.page = 'bundle';
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070052 $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 Cole3c3361c2015-05-19 12:07:29 -070071
72 $log.debug('Cord Bundle Ctrl has been created.');
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070073 }])
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070074
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070075 .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 Colee0311892015-05-15 11:27:15 -070087}());