blob: ea7b4500c86cfdca54a87442ecc50a5ffeea1e22 [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 Colef3eba312015-05-21 16:35:06 -070020 var url = 'http://localhost:8080/rs/bundle';
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070021
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070022 var basic = 'basic',
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070023 family = 'family';
Bri Prebilic Coled050a4b2015-05-27 15:53:30 -070024
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070025 angular.module('cordBundle', [])
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070026 .controller('CordBundleCtrl', ['$log', '$scope', '$resource',
27 function ($log, $scope, $resource) {
28 var BundleData, resource,
29 getData;
30 $scope.page = 'bundle';
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070031
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070032 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 Colef3eba312015-05-21 16:35:06 -070056 };
Bri Prebilic Cole10570eb2015-05-20 16:23:52 -070057
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070058 getData();
Bri Prebilic Coled050a4b2015-05-27 15:53:30 -070059
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070060 $scope.changeBundle = function (id) {
61 getData(id);
62 };
Bri Prebilic Coled050a4b2015-05-27 15:53:30 -070063
64 $log.debug('Cord Bundle Ctrl has been created.');
65 }])
66
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070067 .directive('bundleAvailable', [function () {
Bri Prebilic Coled050a4b2015-05-27 15:53:30 -070068 return {
Bri Prebilic Coled3d7a322015-05-28 14:15:14 -070069 templateUrl: 'app/view/bundle/available.html'
Bri Prebilic Coled050a4b2015-05-27 15:53:30 -070070 };
Bri Prebilic Colebdd6b3b2015-05-22 15:44:18 -070071 }]);
Bri Prebilic Colee0311892015-05-15 11:27:15 -070072}());