From 99e6372708041261adab16f3267d9ccc2c92672a Mon Sep 17 00:00:00 2001 From: Yakir Dorani Date: Wed, 2 Nov 2016 20:37:13 +0200 Subject: [PATCH] Fixes for dlux Change-Id: I87f62bd688b202d38548c03172c528edbcefe8ce Signed-off-by: Yakir Dorani --- .../main/resources/cpeui/admin.controller.js | 71 ++++++++++++++-- .../src/main/resources/cpeui/admin.tpl.html | 47 ++++++++-- .../main/resources/cpeui/cpeui.controller.js | 3 +- .../cpeui/dialogs/AddTenant.tpl.html | 16 ++-- .../cpeui/services/cpeui.services.js | 78 +++++++++++++++-- .../resources/cpeui/static/cpeui-custom.css | 9 +- .../main/resources/cpeui/tenant.controller.js | 44 ++++++++-- .../src/main/resources/cpeui/tenant.tpl.html | 85 +++++++++++++++++-- .../cpeui/tenantsTable.controller.js | 6 +- .../resources/cpeui/tenantsTable.tpl.html | 2 - impl/pom.xml | 10 +-- legato-api/src/main/yang/mef-global.yang | 10 --- 12 files changed, 313 insertions(+), 68 deletions(-) diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.controller.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.controller.js index 4c8eea4e..baa0a699 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.controller.js +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.controller.js @@ -13,15 +13,15 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }); } - $scope.AddTenant = function(serviceType) { - CpeuiSvc.addTenant($scope.tenantId, serviceType, function() { + $scope.AddTenant = function() { + CpeuiSvc.addTenant($scope.tenantId, function() { $scope.updateView(); }); }; $scope.tenantDialog = new CpeuiDialogs.Dialog('AddTenant', {}, function(obj) { - CpeuiSvc.addTenant(obj.id, obj.service_type, function() { + CpeuiSvc.addTenant(obj.id, function() { $scope.updateView(); }); }); @@ -75,6 +75,20 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }); } + $scope.assignNetworkToTenant = function(svc) { + CpeuiDialogs.customConfirm("Are You Sure?", + "Are you sure you want to assign service "+ svc['svc-id'] +" to tenant " + $scope.selectedTenant[svc['svc-id']] +"?", + function() { + CpeuiSvc.addTenantToService(svc['svc-id'], $scope.selectedTenant[svc['svc-id']], function(){ + svc['tenant-id'] = $scope.selectedTenant[svc['svc-id']]; + },function(){ + $scope.selectedTenant[svc['svc-id']] = undefined; + }); + }, function() { + $scope.selectedTenant[svc['svc-id']] = undefined; + }); + }; + function updateCpeTenants(unis) { // update tenant cpe tenant column var hasMultipleTenants = []; @@ -111,11 +125,7 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { // UNIs $scope.updateUniView = function() { CpeuiSvc.getUnis(function(unis) { - $scope.unis = unis; - $scope.unis.forEach(function(u) { - u.prettyID = u['uni-id'].split(":")[u['uni-id'] - .split(":").length - 1]; - }); + $scope.unis = unis; updateCpeTenants(unis); }); }; @@ -135,8 +145,53 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }); }; + $scope.addCEName = function(ce){ + ce._naming = true; + var input = $('#INPUT_' +ce['dev-id']); + // hack to focus input after show is complete + setTimeout(function(){input.focus();},20); + input.parent().on('blur',function(){ + setTimeout(function(){ + ce._naming = false; + delete ce._new_name; + },20); + }); + + input.bind("keyup", function (eventSubmit) { + if(eventSubmit.which === 13) { + $('#OK_' +ce['dev-id']).click(); + } else if(eventSubmit.which === 27) { + input.parent().blur(); + } + }); + } + + $scope.renameCE = function(ce){ + CpeuiSvc.addCeName(ce, ce._new_name, function(){ + ce['device-name'] = ce._new_name; + }); + ce._naming = false; + } + + $scope.services = []; + $scope.networkNames = {}; + + $scope.updateNetworksView = function() { + CpeuiSvc.getAllServices(function(services) { + $scope.services = services; + }); + CpeuiSvc.getNetworkNames(function(networks){ + networks.forEach(function(net){ + $scope.networkNames[net.uuid] = net.name; + }); + }); + }; + // General $scope.updateView = function() { + if ($scope.isTabSet('admin',4)){ + $scope.updateNetworksView(); + } $scope.updateTenantView(); $scope.updateCesView(); $scope.updateUniView(); diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.tpl.html b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.tpl.html index 19b98de8..75bbd0b5 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.tpl.html +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.tpl.html @@ -10,7 +10,12 @@ CPEs (Devices)
  • - UNIs
  • + UNIs + +
  • + Networks +
  • @@ -32,11 +37,16 @@ {{ item['dev-id'] }} - {{ item['device-name'] }} + {{ item['device-name'] }} + + + + + + + + - @@ -78,4 +88,31 @@ +
    +
    Networks
    + + + + + + + + + + + + + + + + +
    Network IDNetwork nameTenant
    {{ svc['svc-id'] }}{{ networkNames[svc['svc-id']] }}{{ svc['tenant-id'] }} + + + + {{ tenant.name }} + + +
    +
    diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/cpeui.controller.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/cpeui.controller.js index 5ef55005..b747c79e 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/cpeui.controller.js +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/cpeui.controller.js @@ -20,7 +20,8 @@ define([].concat(modules).concat(services).concat(directives).concat(controllers var mainTabIndexs = { "tenants" : 1, "cpes" : 2, - "unis" : 3 + "unis" : 3, + "networks" : 4 } $scope.tab = { diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/dialogs/AddTenant.tpl.html b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/dialogs/AddTenant.tpl.html index 8d144366..2afdbec9 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/dialogs/AddTenant.tpl.html +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/dialogs/AddTenant.tpl.html @@ -20,16 +20,12 @@
    name must be only numbers and English characters
    The name has to be less than 30 characters long.
    -
    - - - - Layer 2 VPN - Layer 3 VPN - - - - + + + + + + diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/cpeui.services.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/cpeui.services.js index c8b59254..2daea7ba 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/cpeui.services.js +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/cpeui.services.js @@ -19,13 +19,12 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { }); }; - svc.addTenant = function(name, serviceType, callback){ + svc.addTenant = function(name, callback){ $http({ method:'POST', url:baseUrl + "tenants-instances/", data: {"tenant-list":[{ - "name": name, - "service_type": serviceType + "name": name }]} }).then(function successCallback(response) { if (callback != undefined) { @@ -64,6 +63,26 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { } }); }; + + svc.addCeName = function(ce, new_name, callback) { + $http({ + method:'POST', + url:"/restconf/config/mef-topology:mef-topology/devices/device/" + ce['dev-id'], + data: {"device-name": new_name} + }).then(function successCallback(response) { + if (callback != undefined) { + callback(); + } + }, function errorCallback(response) { + console.log(response); + $http({ + method:'GET', + url:"/restconf/config/mef-topology:mef-topology/devices/device/" + ce['dev-id'] + }).then(function successCallback(response) { + ce["device-name"] = response.data["device"][0]["device-name"]; + }); + }); + }; svc.getCes = function(callback) { var ces; @@ -153,7 +172,9 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { } } } - + unis.forEach(function(u) { + u.prettyID = u['uni-id'].split(":")[u['uni-id'].split(":").length - 1]; + }); if (callback != undefined) { callback(unis); } @@ -232,7 +253,7 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { }); }; - svc.getEvc = function(tenantid, callback) { + svc.getServices = function(tenantid, callback) { var evcs; $http({ method:'GET', @@ -243,8 +264,8 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { if (evcs != undefined) { evcs = evcs.filter(function(evc){return evc["tenant-id"] == tenantid;}); for (i=0; i < evcs.length; i++) { - var unis = evcs[i].evc.unis.uni; - if (unis != undefined) { + if ((evcs[i].evc != undefined) && (evcs[i].evc.unis.uni != undefined)) { + var unis = evcs[i].evc.unis.uni; for (j=0; j < unis.length; j++) { if ((unis[j]['evc-uni-ce-vlans'] != undefined) && (unis[j]['evc-uni-ce-vlans']['evc-uni-ce-vlan'] != undefined)){ unis[j].vlans = unis[j]['evc-uni-ce-vlans']['evc-uni-ce-vlan'].map(function(u){return u.vid;}).sort(); @@ -264,6 +285,38 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { return evcs; }; + + svc.getAllServices = function(callback) { + $http({ + method:'GET', + url:"/restconf/config/mef-services:mef-services/" + }).then(function successCallback(response) { + if (callback != undefined) { + callback(response.data["mef-services"]["mef-service"]); + } + }, function errorCallback(response) { + console.log(response); + }); + }; + + svc.addTenantToService = function(svcId, tenantName, callbackSuccess, callbackFailure){ + $http({ + method:'POST', + url:"/restconf/config/mef-services:mef-services/mef-service/" + svcId, + data:{"tenant-id":tenantName} + }).then(function() { + if (callbackSuccess != undefined) { + callbackSuccess(); + } + }, function() { + if (callbackFailure != undefined) { + callbackFailure(); + } else { + console.log(response); + } + }); + }; + svc.removeEvc = function(svcid, callback) { $http({ method:'DELETE', @@ -351,6 +404,17 @@ define(['app/cpeui/cpeui.module'],function(cpeui) { }); }; + svc.getNetworkNames = function(callback){ + $http({ + method:'GET', + url:"/restconf/config/neutron:neutron/networks/" + }).then(function successCallback(response) { + if (callback != undefined) { + callback(response.data.networks.network); + } + }); + }; + return svc; }); diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/static/cpeui-custom.css b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/static/cpeui-custom.css index 6c306a0b..d5a0f09d 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/static/cpeui-custom.css +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/static/cpeui-custom.css @@ -105,6 +105,11 @@ MD-DIALOG { min-width: 30% !important; } +.no-error-spacer .md-errors-spacer { + display: none; +} + + MD-TOOLBAR { cursor: move; /* fallback if grab cursor is unsupported */ cursor: grab; @@ -145,7 +150,7 @@ MD-TOOLBAR:active { .showmm label, .showmm input, .showmm div{ height:inherit; } -.hidemm label, .hidemm input, .hidemm div{{ +.hidemm label, .hidemm input, .hidemm div{ height:0; } @@ -158,4 +163,4 @@ MD-TOOLBAR:active { .animate-if.ng-leave, .animate-if.ng-enter.ng-enter-active { height:0; -} +} \ No newline at end of file diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.controller.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.controller.js index 53bf797f..53da2fbf 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.controller.js +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.controller.js @@ -6,15 +6,22 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { $scope.unisTables = {}; $scope.unis = []; $scope.ces = []; + $scope.ipvcs = [] $scope.cesDisplayNames = {}; $scope.unisMap = {}; + $scope.networkNames = {}; function init(){ $scope.updateUnis(function(unis){ CpeuiSvc.getCes(function(ces) { $scope.ces = ces.filter(function(item) { - return (unis.filterByField('device', item["dev-id"]).length); + + var filteredUnis = unis.filterByField('device', item["dev-id"]); + filteredUnis = filteredUnis.filterByField('prettyID', 'br-int', true); + filteredUnis = filteredUnis.filter(function(i){return !(i.prettyID && i.prettyID.startsWith('tun'));}); + + return (filteredUnis.length); }); ces.forEach(function(ce){ $scope.cesDisplayNames[ce['dev-id']] = ce['device-name'] ? ce['device-name'] : ce['dev-id']; @@ -22,6 +29,12 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { $scope.updateEvcView(); }); }); + + CpeuiSvc.getNetworkNames(function(networks){ + networks.forEach(function(net){ + $scope.networkNames[net.uuid] = net.name; + }); + }); } $scope.updateUnis = function(callback) { @@ -39,11 +52,17 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }; $scope.updateEvcView = function() { - CpeuiSvc.getEvc($scope.curTenant, function(evcs) { - $scope.evcs = evcs; + CpeuiSvc.getServices($scope.curTenant, function(services) { + + $scope.evcs = services.filter(function(svc){ return svc.evc != undefined;}); + $scope.ipvcs = services.filter(function(svc){ return svc.ipvc != undefined;}); $scope.updateUnis(); + $scope.ipvcs.forEach(function(e){ + e.isTree = (e.ipvc['ipvc-type'] == 'rooted-multipoint'); + }); + $scope.evcs.forEach(function(e){ e.isTree = (e.evc['evc-type'] == 'rooted-multipoint'); e.device2unis = {}; @@ -52,6 +71,7 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { if (e.device2unis[$scope.unisMap[u['uni-id']].device] == undefined){ e.device2unis[$scope.unisMap[u['uni-id']].device] = []; } + u.prettyID = u['uni-id'].split(":")[u['uni-id'].split(":").length - 1]; e.device2unis[$scope.unisMap[u['uni-id']].device].push(u); }); } @@ -60,6 +80,9 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }; $scope.title = function(str) { + if (!str) { + return str; + } return str.split('-').map(function(s) { return s[0].toUpperCase() + s.slice(1); }).join(' '); @@ -122,9 +145,15 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }; $scope.filterUsedUnis = function(evc){ - return function(u) { - if (evc.evc.unis.uni == undefined) { - evc.evc.unis.uni = []; + return function(u) { + if (u.prettyID == 'br-int') { + return false; + } + if (u.prettyID && u.prettyID.startsWith('tun')) { + return false; + } + if (evc.evc.unis.uni == undefined){ + evc.evc.unis.uni = []; } return evc.evc.unis.uni.filterByField('uni-id',u['uni-id']).length == 0; }; @@ -171,6 +200,9 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { $scope.sortUni = function(uni) { return uni['uni-id']; }; + $scope.sortIpvc = function(ipvc) { + return ipvc['ipvc-id']; + }; init(); }); diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.tpl.html b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.tpl.html index 18458712..df5de4d5 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.tpl.html +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenant.tpl.html @@ -3,11 +3,13 @@ +
    diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.controller.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.controller.js index f4fee413..72775516 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.controller.js +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.controller.js @@ -10,15 +10,15 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) { }); } - $scope.AddTenant = function(serviceType) { - CpeuiSvc.addTenant($scope.tenantId, serviceType, function() { + $scope.AddTenant = function() { + CpeuiSvc.addTenant($scope.tenantId, function() { $scope.updateTenantView(); }); }; $scope.tenantDialog = new CpeuiDialogs.Dialog('AddTenant', {}, function(obj) { - CpeuiSvc.addTenant(obj.id, obj.service_type, function() { + CpeuiSvc.addTenant(obj.id, function() { $scope.updateTenantView(); }); }); diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.tpl.html b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.tpl.html index 9084cf82..530b6a72 100644 --- a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.tpl.html +++ b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/tenantsTable.tpl.html @@ -4,14 +4,12 @@ Tenant name - Service Type Open ... {{ item.name }} - {{ item.service_type }} diff --git a/impl/pom.xml b/impl/pom.xml index 41ea0c4e..8449913c 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -40,11 +40,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL maven-bundle-plugin - - org.opendaylight.unimgr.mef.nrp.common, - org.opendaylight.unimgr.mef.nrp.api, - org.opendaylight.unimgr.api - + + + + + diff --git a/legato-api/src/main/yang/mef-global.yang b/legato-api/src/main/yang/mef-global.yang index e86a7bd3..92e3ce9b 100644 --- a/legato-api/src/main/yang/mef-global.yang +++ b/legato-api/src/main/yang/mef-global.yang @@ -1505,16 +1505,6 @@ module mef-global { type string; description "Tenant Name"; } - leaf service_type { - type enumeration { - enum L2 { - description "Layer 2 VPN"; - } - enum L3 { - description "Layer 3 VPN"; - } - } - } } container tenants-instances { -- 2.36.6