From 27fb2d06608fbb070ae2c15a5580a4f5b2423d15 Mon Sep 17 00:00:00 2001 From: demx8as6 <martin.skorupski@highstreet-technologies.com> Date: Tue, 10 Jul 2018 18:07:44 +0200 Subject: Add seed code for sdnr app based on ONF Centennial At this point in time all the Carbon code from ONF Centennial is added to ONAP. Later it needs to be refactored and modified for ODL Oxygen. Change-Id: Iff85dd940c05c3827f1c4e6f9542ecd060c58a46 Issue-ID: SDNC-374 Signed-off-by: demx8as6 <martin.skorupski@highstreet-technologies.com> --- .../ux/onapAai/onapAai-module/pom.xml | 14 ++ .../src/main/resources/onapAai/images/onapAai.png | Bin 0 -> 12931 bytes .../src/main/resources/onapAai/onapAai-custom.css | 58 ++++++++ .../main/resources/onapAai/onapAai.controller.js | 49 +++++++ .../src/main/resources/onapAai/onapAai.module.js | 56 +++++++ .../src/main/resources/onapAai/onapAai.services.js | 162 +++++++++++++++++++++ .../src/main/resources/onapAai/onapAai.tpl.html | 12 ++ 7 files changed, 351 insertions(+) create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/pom.xml create mode 100755 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/images/onapAai.png create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai-custom.css create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.controller.js create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.module.js create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.services.js create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.tpl.html (limited to 'sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module') diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/pom.xml new file mode 100644 index 00000000..6c2eef33 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/pom.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>onapAai</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + </parent> + <artifactId>onapAai-module</artifactId> + <name>${prefix} ${project.artifactId}</name> + <packaging>jar</packaging> +</project> \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/images/onapAai.png b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/images/onapAai.png new file mode 100755 index 00000000..a3724882 Binary files /dev/null and b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/images/onapAai.png differ diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai-custom.css b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai-custom.css new file mode 100644 index 00000000..fc314684 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai-custom.css @@ -0,0 +1,58 @@ +/** + * Add your application related css here + */ +.onapAaiGrid { + height: 600px; + background-color: white; +} + +.onapAaiGrid span { + color: #393939; +} +.ht-pagination span { + color: #393939; +} +.ht-pagination span.dark { + color: #393939; +} +.dark { + color: #393939; +} + + + +.onapAaiGrid div.debug { + color: #393939; + background-color: white; +} +.onapAaiGrid div.error { + color: #ff0000; + background-color: #ffeeee; + font-weight: bold; +} + +.onapAaiGrid div.info { + color: #3276b1; + background-color: #eeeeff; +} + +.onapAaiGrid div.warning { + color: #ffa500; + background-color: #ffeedd; +} + +.rotated { + transform: rotate(180deg); + -webkit-transform: rotate(180deg); + -ms-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -o-transform: rotate(180deg); +} + +h3.modal-title { + color: #393939; +} + +.modal-body span { + color: #393939; +} \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.controller.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.controller.js new file mode 100644 index 00000000..6c5685e9 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.controller.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 highstreet technologies GmbH and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +define(['app/onapAai/onapAai.module', + 'app/onapAai/onapAai.services'], + function (onapAaiApp) { + + onapAaiApp.register.controller('onapAaiCtrl', ['uiGridConstants', '$uibModal', '$scope', '$rootScope', '$window', '$timeout', '$onapAai', '$mwtnLog', + function (uiGridConstants, $uibModal, $scope, $rootScope, $window, $timeout, $onapAai, $mwtnLog) { + + var COMPONENT = 'onapAaiCtrl'; + $mwtnLog.info({ component: COMPONENT, message: 'onapAaiCtrl started!' }); + + $rootScope.section_logo = 'src/app/onapAai/images/onapAai.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif' + + $scope.highlightFilteredHeader = $onapAai.highlightFilteredHeader; + + // Grid + $scope.gridOptions = JSON.parse(JSON.stringify($onapAai.gridOptions)); + $scope.gridOptions.columnDefs = [ + { field: 'pnf-id', type: 'string', displayName: 'ID', headerCellClass: $scope.highlightFilteredHeader, width: 170 }, + { field: 'pnf-name', type: 'string', displayName: 'Name', headerCellClass: $scope.highlightFilteredHeader, width: 200 }, + { field: 'equip-type', type: 'string', displayName: 'Type', headerCellClass: $scope.highlightFilteredHeader, width: 160 }, + { field: 'equip-vendor', type: 'string', displayName: 'Vendor', headerCellClass: $scope.highlightFilteredHeader, width: 100 }, + { field: 'equip-model', type: 'string', displayName: 'Model', headerCellClass: $scope.highlightFilteredHeader, width: 160 }, + { field: 'ipaddress-v4-oam', type: 'string', displayName: 'If OAM', headerCellClass: $scope.highlightFilteredHeader, width: 140 }, + { field: 'in-maint', type: 'string', displayName: 'Maintenance', headerCellClass: $scope.highlightFilteredHeader, width: 100 }, + { field: 'interfaces', type: 'string', displayName: '#p-interfaces', headerCellClass: $scope.highlightFilteredHeader, width: 100, visible: false }, + { field: 'resourceVersion', type: 'string', displayName: 'Resource version', headerCellClass: $scope.highlightFilteredHeader, width: 100, visible: false } + ]; + + $onapAai.getAaiPnfs().then(function(success){ + $scope.gridOptions.data = success.data.pnf; + $scope.gridOptions.data.map(function(item){ + item.interfaces = 1; + }); + }, function(error) { + console.log('error'); + $scope.error = error; + }); + + }]); + + }); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.module.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.module.js new file mode 100644 index 00000000..a3deb333 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.module.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 highstreet technologies GmbH and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +define(['angularAMD', + 'app/routingConfig', + 'app/core/core.services', + 'common/config/env.module', + 'app/mwtnCommons/mwtnCommons.module'], function(ng) { + var onapAaiApp = angular.module('app.onapAai', ['ui.grid', 'ui.bootstrap', 'app.core', + 'ui.router.state', 'config', 'ui.grid.exporter', + 'ui.grid.moveColumns', 'ui.grid.pinning', 'ui.grid.selection', + 'ui.grid.resizeColumns', 'ui.grid.infiniteScroll','ui.grid.pagination' ]); + + onapAaiApp.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider) { + onapAaiApp.register = { + controller : $controllerProvider.register, + directive : $compileProvider.directive, + factory : $provide.factory, + service : $provide.service + }; + + + NavHelperProvider.addControllerUrl('app/onapAai/onapAai.controller'); + NavHelperProvider.addToMenu('onapAai', { + "link" : "#/onapAai/", + "active" : "main.onapAai", + "title" : "ONAP AAI", + "icon" : "fa fa-th", // Add navigation icon css class here + "page" : { + "title" : "ONAP AAI", + "description" : "Open Network Automation Platform (ONAP) - Active and Available Inventory (AAI)" + } + }); + + var access = routingConfig.accessLevels; + + $stateProvider.state('main.onapAai', { + url: 'onapAai/:nodeId', + access: access.admin, + views : { + 'content' : { + templateUrl: 'src/app/onapAai/onapAai.tpl.html', + controller: 'onapAaiCtrl' + } + } + }); + + }); + + return onapAaiApp; +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.services.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.services.js new file mode 100644 index 00000000..dfbbf473 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.services.js @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2017 highstreet technologies GmbH and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +define(['app/onapAai/onapAai.module', 'app/mwtnCommons/mwtnCommons.services'], function (onapAaiApp) { + + onapAaiApp.register.factory('$onapAai', function ($q, $http, Base64, $mwtnCommons, $mwtnDatabase, $mwtnLog, Device) { + + var service = {}; + + var functionId = "mwtn"; + var docType = "device"; + var from = 0; + var size = 9999; + var sort = undefined; + var deviceLookup = {}; + $mwtnDatabase.getAllData(functionId, docType, from, size, sort).then( + function successCallback(response) { + response.data.hits.hits.map(function(device){ + deviceLookup[device._id] = new Device(device._source); + }); + }, function errorCallback(response) { + deviceLookup = {}; + }); + + service.checkModules = $mwtnCommons.checkModules; + service.getMwtnWebSocketUrl = $mwtnCommons.getMwtnWebSocketUrl; + service.gridOptions = $mwtnCommons.gridOptions; + service.formatData = $mwtnCommons.formatData; + service.formatTimeStamp = $mwtnCommons.formatTimeStamp; + service.deleteDocType = $mwtnDatabase.deleteDocType; + + + var transactionId = 1; + var getHeaders = function () { + return { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-TransactionId': transactionId++ + } + }; + + // create or modify a pnf in aai + service.createPnf = function (pnfId, doc) { + var base = window.location.origin; + var getIp = function (extension) { + return extension.filter(function (item) { + return item['value-name'] === 'neIpAddress'; + }).map(function (item) { + return item.value; + })[0]; + } + + var device = deviceLookup[pnfId]; + if (!device) device = new Device({"id":pnfId,"name":pnfId,"mediator-ipv4":"127.0.0.1","netconf-port":"830","oam-ipv4":"127.0.0.1","site":"unknown","controller":"this","controller-site":"unknown","vendor":"unknown","type":"unknown","model":"unknown","version":"0.0"}); + var data = { + "pnf-name": pnfId, + "pnf-id": doc.connect.host + ':' + doc.connect.port, + "equip-type": device.getType(), + "equip-model": device.getModel(), + "equip-vendor": device.getVendor(), + "ipaddress-v4-oam": getIp(doc['core-model:network-element'].extension) | doc.connect.host, + "in-maint": false + }; + console.info('pnf', data); + var request = { + method: 'PUT', + url: base + '/aai/network/pnfs/pnf/' + pnfId, // to es config + // withCredentials: true, + headers: getHeaders(), + data: data + }; + var deferred = $q.defer(); + $http(request).then(function successCallback(response) { + deferred.resolve(response); + }, function errorCallback(response) { + deferred.reject(response); + }); + + return deferred.promise; + }; + + service.deletePnf = function (pnfId) { + // curl -X DELETE http://localhost:8282/aai/network/pnfs/pnf/Ericsson-A1 --insecure -v -u AAI:AAI -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'X-FromAppId: SDNR' -H 'X-TransactionId: 9999' + var base = window.location.origin; + var request = { + method: 'DELETE', + url: base + '/aai/network/pnfs/pnf/' + pnfId, // to es config + // withCredentials: true, + headers: getHeaders() + }; + var deferred = $q.defer(); + $http(request).then(function successCallback(response) { + deferred.resolve(response); + }, function errorCallback(response) { + deferred.reject(response); + }); + + return deferred.promise; + }; + + service.getAaiPnfs = function () { + // curl https://10.31.1.55:8443/network/pnfs -k -v -u abc:def -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'X-FromAppId: SDNR' -H 'X-TransactionId: 9999' + + var base = window.location.origin; + var request = { + method: 'GET', + url: base + '/aai/network/pnfs', // to es config + // withCredentials: true, + headers: getHeaders(), + }; + + var deferred = $q.defer(); + $http(request).then(function successCallback(response) { + deferred.resolve(response); + }, function errorCallback(response) { + deferred.reject(response); + }); + + return deferred.promise; + }; + + return service; + }); + + // Class Device + onapAaiApp.register.factory('Device', function () { + var Device = function (data) { + if (!data) { + data = {id:new Date(), type: 'unknown', name:'unknonw', model: 'unkonwn', vendor:'unknonw', version:'unkonwn'}; + } + this.data = data; + this.getData = function () { + return this.data; + }; + this.getId = function () { + return this.getData().id; + }; + this.getType = function () { + return this.getData().type; + }; + this.getName = function () { + return this.getData().name; + }; + this.getModel = function () { + return this.getData().model; + }; + this.getVendor = function () { + return this.getData().vendor; + }; + this.getVersion = function () { + return this.getData().version; + }; + }; + return Device; + }); + +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.tpl.html new file mode 100644 index 00000000..c121b6d5 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/onapAai/onapAai-module/src/main/resources/onapAai/onapAai.tpl.html @@ -0,0 +1,12 @@ +<ht-header help-link='sdnr/onapAai/0.4.0/README.md'></ht-header> +<pre ng-if="error">{{ error | json }}</pre> + + +<div id="onapAaiGrid" ui-grid="gridOptions" ui-grid-exporter ui-grid-selection ui-grid-pinning + ui-grid-resize-columns ui-grid-move-columns class="onapAaiGrid" ng-if="!error"></div> +</div> + +<hr /> +<div class="owl"> + <span class="white">ONAP SDN-R | ONF Wireless for @distversion@ - Build: @buildtime@</span> +</div> \ No newline at end of file -- cgit 1.2.3-korg