From 27fb2d06608fbb070ae2c15a5580a4f5b2423d15 Mon Sep 17 00:00:00 2001 From: demx8as6 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 --- .../ux/odlChat/odlChat-bundle/pom.xml | 116 +++++++++++++++++++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 19 ++++ .../ux/odlChat/odlChat-module/pom.xml | 14 +++ .../src/main/resources/odlChat/logo_chat.gif | Bin 0 -> 2046 bytes .../src/main/resources/odlChat/odlChat-custom.css | 3 + .../main/resources/odlChat/odlChat.controller.js | 69 ++++++++++++ .../src/main/resources/odlChat/odlChat.module.js | 50 +++++++++ .../src/main/resources/odlChat/odlChat.png | Bin 0 -> 1862 bytes .../src/main/resources/odlChat/odlChat.services.js | 103 ++++++++++++++++++ .../src/main/resources/odlChat/odlChat.tpl.html | 102 ++++++++++++++++++ .../code-Carbon-SR1/ux/odlChat/pom.xml | 27 +++++ 11 files changed, 503 insertions(+) create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/pom.xml create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/pom.xml create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/logo_chat.gif create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat-custom.css create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.controller.js create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.module.js create mode 100755 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.png create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.services.js create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.tpl.html create mode 100644 sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/pom.xml (limited to 'sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat') diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/pom.xml new file mode 100644 index 00000000..87ebbd3c --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/pom.xml @@ -0,0 +1,116 @@ + + + 4.0.0 + + odlChat + com.highstreet.technologies.odl.dlux + 0.5.1-SNAPSHOT + + odlChat-bundle + ${prefix} ${project.artifactId} + bundle + + + org.osgi + org.osgi.core + ${osgi.core.version} + + + org.osgi + org.osgi.compendium + ${osgi.core.version} + + + org.apache.felix + org.osgi.compendium + ${apache.felix.compendium} + + + org.opendaylight.dlux + loader + ${dlux.loader.version} + + + com.highstreet.technologies.odl.dlux + odlChat-module + 0.5.1-SNAPSHOT + + + + + + target/generated-resources + + + src/main/resources + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + + unpack-loader-resources + + unpack-dependencies + + generate-resources + + ${project.build.directory}/generated-resources + com.highstreet.technologies.odl.dlux + odlChat-module + META-INF\/** + true + false + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.osgi.service.http, + org.osgi.framework;version="1.0.0", + org.opendaylight.dlux.loader + + + + + + + + + + diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 00000000..ad015bd2 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + src/app/odlChat/odlChat-custom.css + + + + \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/pom.xml new file mode 100644 index 00000000..730c40b1 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + odlChat + com.highstreet.technologies.odl.dlux + 0.5.1-SNAPSHOT + + odlChat-module + ${prefix} ${project.artifactId} + jar + \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/logo_chat.gif b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/logo_chat.gif new file mode 100644 index 00000000..deb44fd2 Binary files /dev/null and b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/logo_chat.gif differ diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat-custom.css b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat-custom.css new file mode 100644 index 00000000..4d9f8d24 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat-custom.css @@ -0,0 +1,3 @@ +/** + * Add your application related css here + */ \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.controller.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.controller.js new file mode 100644 index 00000000..310e05d5 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.controller.js @@ -0,0 +1,69 @@ +/* + * 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( + [ 'app/odlChat/odlChat.module', 'app/odlChat/odlChat.services' ], + function(odlChatApp) { + + var main = function($scope, $rootScope, $odlChat) { + + $rootScope.section_logo = 'src/app/odlChat/odlChat.png'; + + $scope.collection = []; + $scope.chat = { + nickname : 'anonymous', + message : "Hey, what's up?!" + }; + + var listenToNotifications = function(socketLocation) { + try { + var notificatinSocket = new WebSocket(socketLocation); + + notificatinSocket.onmessage = function(event) { + // we process our received event here + $odlChat.getData(event, function(info, tweet) { + $scope.collection.push(tweet); + if ($scope.collection.length > 20) { + $scope.collection.shift(); + } + + $scope.chat.message = info; + }); + }; + notificatinSocket.onerror = function(error) { + console.log("Socket error: " + JSON.stringify(error)); + }; + notificatinSocket.onopen = function(event) { + console.log("Socket connection opened."); + }; + notificatinSocket.onclose = function(event) { + console.log("Socket connection closed."); + }; + // if there is a problem on socket creation we get + // exception (i.e. when socket address is incorrect) + } catch (e) { + alert("Error when creating WebSocket" + e); + } + }; + + $scope.send = function(chat) { + $odlChat.send(chat, function(info) { + console.log(info); + }); + }; + + var path = "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='odlChat']"; + $odlChat.register(path, function(socketLocation) { + listenToNotifications(socketLocation); + }); + }; + + odlChatApp.register.controller('odlChatCtrl', [ '$scope', '$rootScope', + '$odlChat', main ]); + + }); \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.module.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.module.js new file mode 100644 index 00000000..6bd5387f --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.module.js @@ -0,0 +1,50 @@ +/* + * 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'], function(ng) { + var odlChatApp = angular.module('app.odlChat', ['app.core', 'ui.router.state','config']); + + odlChatApp.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider) { + odlChatApp.register = { + controller : $controllerProvider.register, + directive : $compileProvider.directive, + factory : $provide.factory, + service : $provide.service + + }; + + + NavHelperProvider.addControllerUrl('app/odlChat/odlChat.controller'); + NavHelperProvider.addToMenu('odlChat', { + "link" : "#/odlChat", + "active" : "main.odlChat", + "title" : "Chat", + "icon" : "fa-comments", // Add navigation icon css class here + "page" : { + "title" : "Chat", + "description" : "odlChat" + } + }); + + var access = routingConfig.accessLevels; + + $stateProvider.state('main.odlChat', { + url: 'odlChat', + access: access.admin, + views : { + 'content' : { + templateUrl: 'src/app/odlChat/odlChat.tpl.html', + controller: 'odlChatCtrl' + } + } + }); + + }); + + return odlChatApp; +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.png b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.png new file mode 100755 index 00000000..3b79097e Binary files /dev/null and b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.png differ diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.services.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.services.js new file mode 100644 index 00000000..1a137f5c --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.services.js @@ -0,0 +1,103 @@ +/* + * 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(['app/mwtnCommons/mwtnCommons.module', 'app/odlChat/odlChat.module'],function(odlChatApp) { + + odlChatApp.register.factory('$odlChat', function($http, $mwtnCommons) { + + var createStream = function(streamName, callback) { + var request = { + method : 'GET', + url : [ service.base, 'streams/stream/', streamName ].join('') + }; + $http(request).then(function successCallback(response) { + console.log(response.headers('Location')); + callback(response.headers('Location')); + }, function errorCallback(response) { + console.error(JSON.stringify(response)); + callback(); + }); + }; + + var service = { + base : window.location.origin + "/restconf/", + }; + + + service.getData = function(event, callback) { + + var request = { + method : 'GET', + url : [ service.base, + 'config/opendaylight-inventory:nodes/node/odlChat/' ].join('') + }; + $http(request).then(function successCallback(response) { + tweet = { + nickname : response.data.node[0]['flow-node-inventory:manufacturer'], + message : response.data.node[0]['flow-node-inventory:description'], + time : JSON.stringify(new Date()).split('T')[1].substring(0, 5) + }; + callback('', tweet); + }, function errorCallback(response) { + console.error(JSON.stringify(response)); + callback('ERROR while sending ;('); + }); + + }; + + service.register = function(path, callback) { + var request = { + method : 'POST', + url : [ service.base, + 'operations/sal-remote:create-data-change-event-subscription' ] + .join(''), + data : { + "input" : { + "path" : path, + "sal-remote-augment:datastore" : "CONFIGURATION", + "sal-remote-augment:scope" : "SUBTREE" + } + } + }; + $http(request).then( + function successCallback(response) { + createStream(response.data.output['stream-name'], function( + socketLocation) { + callback(socketLocation); + }); + }, function errorCallback(response) { + console.error(JSON.stringify(response)); + }); + }; + + service.send = function(chat, callback) { + var request = { + method : 'PUT', + url : [ service.base, + 'config/opendaylight-inventory:nodes/node/odlChat' ].join(''), + data : { + "node" : [ { + "id" : "odlChat", + "flow-node-inventory:manufacturer" : chat.nickname, + "flow-node-inventory:software" : "", + "flow-node-inventory:serial-number" : "", + "flow-node-inventory:hardware" : "", + "flow-node-inventory:description" : chat.message + } ] + } + }; + $http(request).then(function successCallback(response) { + callback('send successfully'); + }, function errorCallback(response) { + console.error(JSON.stringify(response)); + callback('ERROR while sending ;('); + }); + }; + return service; + }); +}); \ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.tpl.html new file mode 100644 index 00000000..c3d90ae3 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/odlChat-module/src/main/resources/odlChat/odlChat.tpl.html @@ -0,0 +1,102 @@ + +
+ +
+
+

Simple chat application based on (ODL) WebSockets

+
+
+ +
+
+
+
+
+ + + +
+
+
+
+
+ +
+
+ {{tweet.nickname}}: +
+
+ + {{tweet.message}} + +
+
+ {{tweet.time}} +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ {{'MWTN_NICKNAME' | translate}} +
+
+ {{'MWTN_MESSAGE' | translate}} +
+
+
+
+
+
+ ONAP SDN-R | ONF Wireless for @distversion@ - Build: @buildtime@ +
diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/pom.xml new file mode 100644 index 00000000..f81b02ed --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/odlChat/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + mwtn + com.highstreet.technologies.odl.dlux + 0.5.1-SNAPSHOT + .. + + + pom + com.highstreet.technologies.odl.dlux + odlChat + 0.5.1-SNAPSHOT + ${prefix} ${project.artifactId} + + + 3.0 + + + + odlChat-module + odlChat-bundle + + \ No newline at end of file -- cgit 1.2.3-korg