yangUI changes
[dlux.git] / modules / yangui-resources / src / main / resources / yangui / cf / checkFlow.services.js
1 define(['app/yangui/yangui.module', 'common/yangutils/yangutils.services'], function(yangui, yangutils) {
2
3   yangui.register.factory('checkFlow', function($http, reqBuilder, apiConnector, yangUtils) {
4
5       var fnc = function($scope) {
6           var requestPath = $scope.selApi.basePath+'/'+$scope.selSubApi.buildApiRequestString().replace('config','operational'),
7               requestData = {},
8               identifiers,
9               getPathIdentifierData = function(pathArray){
10                   var data = '';
11                       pathArray.forEach(function(item){
12                       if( item.hasIdentifier() ) {
13                           data += item.name + ': ' + item.identifierValue + '\n ';
14                       }
15                   });
16                   return data;
17               };
18
19           $http({method: "GET", url: requestPath}).success(function(data) {
20               if(data) {
21                   identifiers = getPathIdentifierData($scope.selSubApi.pathArray);
22                   alert('Flow: \n\n' + identifiers + '\n\n is in controller.');
23               }
24           }).error(function(data, status) {
25               console.info('error sending request to',requestPath,'got',status,'data',data);
26               identifiers = getPathIdentifierData($scope.selSubApi.pathArray);
27               alert('Flow: \n\n' + identifiers + '\n\n isn\'t in controller.');
28           });
29       };
30
31       return {
32         module: 'opendaylight-inventory',
33         revision: null,
34         pathString: '/config/opendaylight-inventory:nodes/node/{id}/table/{id}/flow/{id}/',
35         label: 'Verify operational flow', 
36         getCallback: fnc
37       };
38     });
39 });