From 843fe81ebf7f11920a52f625bf863a1fad4d29de Mon Sep 17 00:00:00 2001 From: Daniel Malachovsky Date: Fri, 5 Feb 2016 16:24:59 +0100 Subject: UI-Grid initial commit - added angular-ui-grid library for handling expandable table - removed old service (http) and old inventory controller - fixed bridge domains page formatting - fixes bugs due to old code's css - applied Dave's comments Change-Id: Ie10d05bb0da3cb9bac666b66cf7168696c45254f Signed-off-by: Daniel Malachovsky Signed-off-by: Varun Seereeram --- .../module/src/main/resources/vpp/vpp.services.js | 375 +++------------------ 1 file changed, 45 insertions(+), 330 deletions(-) (limited to 'vbd/gui/module/src/main/resources/vpp/vpp.services.js') diff --git a/vbd/gui/module/src/main/resources/vpp/vpp.services.js b/vbd/gui/module/src/main/resources/vpp/vpp.services.js index 7f082ae1e..49337b109 100644 --- a/vbd/gui/module/src/main/resources/vpp/vpp.services.js +++ b/vbd/gui/module/src/main/resources/vpp/vpp.services.js @@ -30,344 +30,59 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) { } }); - vpp.register.service('httpService', function($http, dataService, $log, toastService, $q) { - /* - this.requestVpps = function() { - $http.get(vppsUrl, { - headers: { - 'Content-Type': 'application/json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - dataService.vpps = processVpps(response.data); - var counter = 0; - angular.forEach(dataService.vpps, function(vpp) { - counter++; - var isFinalInterfaceRequest = counter === dataService.vpps.length; - requestInterfaces(vpp, isFinalInterfaceRequest); - }); - }, function errorCallback(response) { - toastService.showToast('Error retrieving VPPs'); - $log.error(response); - }); - }; - - var requestInterfaces = function(vpp, isFinalInterfaceRequest) { - $http.get(interfacesUrl+vpp['node-id']+interfacesUri, { - headers: { - 'Content-Type': 'application/json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - vpp.interfaces = response.data.interfaces.interface; - //------ - $http.get(operationalUrl+vpp['node-id']+operationalUri, { - headers: { - 'Content-Type': 'application/json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - vpp.operational = response.data; - var interfaceStates = vpp.operational['ietf-interfaces:interfaces-state'].interface; - _.forEach(interfaceStates, function(interf) { - var matchedInterface = _.find(vpp.interfaces,{name: interf.name}); - if (matchedInterface) { - matchedInterface['oper-status'] = interf['oper-status']; - matchedInterface['admin-status'] = interf['admin-status']; - } - }); - if (isFinalInterfaceRequest) { - dataService.updateInventoryTopology(); - } - }, function errorCallback() { - $log.error('Error receiving interface states for '+vpp['node-id']); - }); - //------- - }, function errorCallback() { - $log.error('Error receiving interfaces for '+vpp['node-id']); - }); - }; - - var requestBridgeDomains = function() { - $http.get(bridgedomainsUrl, { - headers: { - 'Content-Type': 'application/json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - dataService.setBridgeDomains(response.data["v3po:vpp-state"]); - // done loading... - dataService.requestsFinished(); - }, function errorCallback(response) { - toastService.showToast('Error retrieving Bridge Domains'); - $log.error(response); - }); - }; - - this.deploy = function() { - var errorOccurred = false; - - var success = function(succeeded, lastAssignment) { - if (!errorOccurred && !succeeded) { - toastService.showToast('Error deploying configuration!'); - errorOccurred = true; - } else if (!errorOccurred && succeeded && lastAssignment){ - toastService.showToast('Deployed! Bridge Domain Validated'); - } - }; - for (var x = 0; x < dataService.changedInterfaces.length; x++) { - this.updateAssignmentInODL(dataService.changedInterfaces[x], success, x === dataService.changedInterfaces.length - 1); - } - dataService.changedInterfaces.length = 0; - }; - - this.updateAssignmentInODL = function(interf, success, lastAssignment) { - var postData = { - "interface": [ - { - "name": interf.name, - "link-up-down-trap-enable": "disabled", - "v3po:ethernet": { - "mtu": interf['v3po:ethernet']['mtu'] - }, - "v3po:l2": { - "bridge-domain": interf['v3po:l2']['bridge-domain'], - "split-horizon-group": 0, - "bridged-virtual-interface": false - }, - "type": interf.type, - "description": "", - "enabled": true - } - ] - }; - $http.put(interfacesConfigUrl + encodeURIComponent(interf.name), postData, { - headers: { - 'Content-Type': 'application/yang.data+json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - //... - success(true, lastAssignment); - }, function errorCallback(response) { - success(false, lastAssignment); - $log.error(response); - }); - }; - - - this.addBdToODL = function(bdName, isDone) { - var putData = { - "bridge-domain": [ - { - "name": bdName, - "flood": "true", - "forward": "true", - "learn": "true", - "unknown-unicast-flood": "true", - "arp-termination": "false" - } - ] - }; - $http.put(newBridgeDomainUrl+bdName, putData, - { - headers: { - 'Content-Type': 'application/yang.data+json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback() { - toastService.showToast('Bridge Domain Added!'); - isDone('success'); - }, function errorCallback(response) { - $log.error(response); - toastService.showToast('Error adding Bridge Domain.'); - isDone('failure'); - }); - }; - - this.updateInterface = function(interf, isWaiting, cancel, success) { - $http.get(interfacesOperUrl + encodeURIComponent(interf.name), { - headers: { - 'Content-Type': 'application/json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(r) { - var receivedData = r.data.interface[0]; - var postData = { - "interface": [ - { - "name": receivedData.name, - "link-up-down-trap-enable": "disabled", - "v3po:ethernet": { - "mtu": receivedData['v3po:ethernet']['mtu'] - }, - "v3po:l2": { - "bridge-domain": receivedData['v3po:l2']['bridge-domain'], - "split-horizon-group": 0, - "bridged-virtual-interface": false - }, - "type": receivedData.type, - "description": interf.description, - "enabled": interf['admin-status'] === 'up' ? true : false - } - ] - }; - $http.put(interfacesConfigUrl + encodeURIComponent(interf.name), postData, - { - headers: { - 'Content-Type': 'application/yang.data+json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback() { - toastService.showToast('Updated!'); - isWaiting = false; - success(); - }, function errorCallback(response) { - $log.error(response); - toastService.showToast('Error updating'); - isWaiting = false; - cancel(); - }); - }, function errorCallback(response) { - $log.error(response); - toastService.showToast('Error updating'); - isWaiting = false; - cancel(); - }); - }; - - this.removeBdFromOdl = function(name,success) { - $http.delete(newBridgeDomainUrl+name, { - headers: { - 'Content-Type': 'application/json', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }) - .then(function successCallback() { - success(true); - }, function errorCallback() { - success(false); - }); - }; - - this.configVpp = function(name,ip,port,un,pw,finishedSuccessfullyCallback) { - - var putData = '\ - \ - prefix:sal-netconf-connector\ - '+name+'\ -
'+ip+'
\ - '+port+'\ - '+un+'\ - '+pw+'\ - false\ - \ - prefix:netty-event-executor\ - global-event-executor\ - \ - \ - prefix:binding-broker-osgi-registry\ - binding-osgi-broker\ - \ - \ - prefix:dom-broker-osgi-registry\ - dom-broker\ - \ - \ - prefix:netconf-client-dispatcher\ - global-netconf-dispatcher\ - \ - \ - prefix:threadpool\ - global-netconf-processing-executor\ - \ -
'; - - $http.put(configVpp+name, putData, { - headers: { - "Accept": 'application/xml', - "Content-Type": 'application/xml', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - //... - finishedSuccessfullyCallback(true); - }, function errorCallback(response) { - finishedSuccessfullyCallback(false); - $log.error(response); - }); - }; - - this.deleteVpp = function(name, finishedSuccessfullyCallback) { - $http.delete(configVpp+name, { - headers: { - "Accept": 'application/xml', - "Content-Type": 'application/xml', - "Authorization": "Basic " + btoa(username + ":" + password) - } - }).then(function successCallback(response) { - //... - finishedSuccessfullyCallback(true); - }, function errorCallback(response) { - finishedSuccessfullyCallback(false); - $log.error(response); - }); */ - }); - vpp.register.service('dataService', function() { nx.graphic.Icons.registerIcon("bd", "src/app/vpp/assets/images/bd1.svg", 45, 45); nx.graphic.Icons.registerIcon("interf", "src/app/vpp/assets/images/interf.svg", 45, 45); -/* - var Topo = function() { - return new nx.graphic.Topology({ - adaptive:true, - scalable: true, - theme:'blue', - enableGradualScaling:true, - nodeConfig: { - color: '#414040', - label: 'model.label', - scale: 'model.scale', - iconType: function(vertex) { - var type = vertex.get().type; - if (type === 'bd') { - return 'bd' - } else if (type === 'vpp') { - return 'switch' - } else { - return 'interf'; - } + + this.bridgeDomainsTopo = new nx.graphic.Topology({ + height: 350, + width: 500, + scalable: true, + theme:'blue', + enableGradualScaling:true, + nodeConfig: { + color: '#414040', + label: 'model.label', + scale: 'model.scale', + iconType: function(vertex) { + var type = vertex.get().type; + if (type === 'bd') { + return 'bd' + } else if (type === 'vpp') { + return 'switch' + } else { + return 'interf'; } - }, - linkConfig: { - label: 'model.label', - linkType: 'parallel', - color: function(link) { - if (link.getData().type === 'tunnel') { - return '#00FF00'; - } else { - return '#414040'; - } - }, - width: function(link) { - if (link.getData().type === 'tunnel') { - return 5; - } + } + }, + linkConfig: { + label: 'model.label', + linkType: 'parallel', + color: function(link) { + if (link.getData().type === 'tunnel') { + return '#00FF00'; + } else { + return '#414040'; } }, - showIcon: true, - dataProcessor: 'force', - autoLayout: true, - enableSmartNode: false, - tooltipManagerConfig: { - nodeTooltipContentClass: 'TooltipNode', - linkTooltipContentClass: 'TooltipLink' + width: function(link) { + if (link.getData().type === 'tunnel') { + return 5; + } } - }); - }; + }, + showIcon: true, + dataProcessor: 'force', + autoLayout: true, + enableSmartNode: false, + tooltipManagerConfig: { + nodeTooltipContentClass: 'TooltipNode', + linkTooltipContentClass: 'TooltipLink' + } + }); + this.nextApp = new nx.ui.Application; - this.bridgeDomainsTopo = Topo(); this.vpps = []; this.tableContent = []; @@ -440,7 +155,7 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) { this.interfaces[x].assigned = true; } } - }; */ + }; }); -- cgit 1.2.3-korg