diff options
Diffstat (limited to 'sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator')
14 files changed, 1849 insertions, 0 deletions
diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-bundle/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-bundle/pom.xml new file mode 100644 index 00000000..0d668ac1 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-bundle/pom.xml @@ -0,0 +1,89 @@ +<?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>mwtnMediator</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + </parent> + <artifactId>mwtnMediator-bundle</artifactId> + <name>${prefix} ${project.artifactId}</name> + <packaging>bundle</packaging> + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>${osgi.core.version}</version> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${osgi.core.version}</version> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${apache.felix.compendium}</version> + </dependency> + <dependency> + <groupId>org.opendaylight.dlux</groupId> + <artifactId>loader</artifactId> + <version>${dlux.loader.version}</version> + </dependency> + <dependency> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <artifactId>mwtnMediator-module</artifactId> + <version>0.5.1-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <resources> + <resource> + <directory>target/generated-resources</directory> + </resource> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.6</version> + <executions> + <!--loader Resources --> + <execution> + <id>unpack-loader-resources</id> + <goals> + <goal>unpack-dependencies</goal> + </goals> + <phase>generate-resources</phase> + <configuration> + <outputDirectory>${project.build.directory}/generated-resources</outputDirectory> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <includeArtifactIds>mwtnMediator-module</includeArtifactIds> + <excludes>META-INF\/**</excludes> + <excludeTransitive>true</excludeTransitive> + <ignorePermissions>false</ignorePermissions> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package>org.osgi.service.http, + org.osgi.framework;version="1.0.0", + org.opendaylight.dlux.loader + </Import-Package> + <Export-Package></Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 00000000..100f6e7c --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,19 @@ +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> + <reference id="httpService" availability="mandatory" activation="eager" interface="org.osgi.service.http.HttpService"/> + <reference id="loader" availability="mandatory" activation="eager" interface="org.opendaylight.dlux.loader.DluxModuleLoader"/> + + <bean id="bundle" init-method="initialize" destroy-method="clean" class="org.opendaylight.dlux.loader.DluxModule"> + <property name="httpService" ref="httpService"/> + <property name="loader" ref="loader"/> + <property name="moduleName" value="mwtnMediator"/> + <property name="url" value="/src/app/mwtnMediator"/> + <property name="directory" value="/mwtnMediator"/> + <property name="requireJs" value="app/mwtnMediator/mwtnMediator.module"/> + <property name="angularJs" value="app.mwtnMediator"/> + <property name="cssDependencies"> + <list> + <value>src/app/mwtnMediator/mwtnMediator-custom.css</value> + </list> + </property> + </bean> +</blueprint>
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/pom.xml new file mode 100644 index 00000000..9269bf11 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-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>mwtnMediator</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + </parent> + <artifactId>mwtnMediator-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/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/class.mediator.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/class.mediator.js new file mode 100644 index 00000000..b87a465b --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/class.mediator.js @@ -0,0 +1,569 @@ +function MediatorConfig(obj) {
+ if (obj !== undefined) {
+ this.Name = obj.Name;
+ this.DeviceType = obj.DeviceType;
+ this.DeviceIp = obj.DeviceIp;
+ this.DevicePort = 'DevicePort' in obj?obj.DevicePort:161;
+ this.TrapsPort = obj.TrapPort;
+ this.IsNetConfConnected = obj.IsNCConnected;
+ this.IsNetworkElementConnected = obj.IsNeConnected;
+ this.NeModel = obj.NeXMLFile;
+ this.NetconfPort = obj.NcPort;
+ this.PID = obj.pid;
+ this.IsLocked = obj.islocked;
+ this.Autorun = obj.autorun;
+ this.FirewallRuleActive = obj.fwactive;
+ this.OpenDaylightConfigs = obj.ODLConfig;
+ } else {
+ this.Name ="";
+ this.DeviceType = -1;
+ this.DeviceIp = "";
+ this.DevicePort = 161;
+ this.TrapsPort = 0;
+ this.IsNetConfConnected = false;
+ this.IsNetworkElementConnected = false;
+ this.NeModel = "";
+ this.NetconfPort = 0;
+ this.PID =0;
+ this.IsLocked = false;
+ this.Autorun = false;
+ this.FirewallRuleActive = false;
+ this.OpenDaylightConfigs=[];
+ }
+ this.DeviceTypeString = this.getDeviceTypeString();
+ this.ConnectionStatus = {Netconf:this.IsNetConfConnected,NetworkElement:this.IsNetworkElementConnected}
+
+}
+MediatorConfig.prototype.refreshData = function(obj)
+{
+ if(obj!==undefined)
+ {
+ //this.Name = obj.Name;
+ this.DeviceType = obj.DeviceType;
+ this.DeviceIp = obj.DeviceIp;
+ this.DevicePort = 'DevicePort' in obj?obj.DevicePort:161;
+ this.TrapsPort = obj.TrapPort;
+ this.IsNetConfConnected = obj.IsNCConnected;
+ this.IsNetworkElementConnected = obj.IsNeConnected;
+ this.NeModel = obj.NeXMLFile;
+ this.NetconfPort = obj.NcPort;
+ this.PID = obj.pid;
+ this.IsLocked = obj.islocked;
+ this.Autorun = false;
+ this.FirewallRuleActive = obj.fwactive;
+ this.OpenDaylightConfigs = obj.ODLConfig;
+ }
+ this.DeviceTypeString = this.getDeviceTypeString();
+ this.ConnectionStatus = {Netconf:this.IsNetConfConnected,NetworkElement:this.IsNetworkElementConnected}
+
+}
+MediatorConfig.prototype.getDeviceTypeString = function()
+{
+ var i;
+ for(i=0;i<MediatorConfig.DeviceTypes.length;i++)
+ {
+ if(MediatorConfig.DeviceTypes[i].Value==this.DeviceType)
+ return MediatorConfig.DeviceTypes[i].Name;
+ }
+ return "unknown";
+}
+/* enum for devicetypes */
+MediatorConfig.DEVICETYPE_SIMULATOR =0;
+
+
+function MediatorConfigStatus(obj){
+ this.Status=obj.Status;
+ this.Name=obj.Name;
+};
+MediatorConfigStatus.STATUS_OKAY = 1;
+MediatorConfigStatus.STATUS_CORRUPTED = 2;
+MediatorConfigStatus.STATUS_LOCKED = 3;
+MediatorConfigStatus.STATUS_REPAIRED = 4;
+MediatorConfigStatus.StatusTypes=[
+ {Value:MediatorConfigStatus.STATUS_OKAY,Name:"Okay"},
+ {Value:MediatorConfigStatus.STATUS_CORRUPTED,Name:"Corrupted"},
+ {Value:MediatorConfigStatus.STATUS_LOCKED,Name:"Locked"},
+ {Value:MediatorConfigStatus.STATUS_REPAIRED,Name:"Repaired"}
+];
+
+/* Names for enum for devicetypes */
+MediatorConfig.DeviceTypes=[
+{Value:MediatorConfig.DEVICETYPE_SIMULATOR,Name:"Simulator"}];
+
+MediatorConfig.prototype.IsRunning = function() {
+ return this.PID > 0;
+}
+MediatorConfig.prototype.TestParams = function() {
+ if(this.Name===undefined || this.Name.length<=0)
+ throw "Name is not given";
+ // Name without spaces
+ var inValidName = /\s/;
+ if(inValidName.test(this.Name))
+ throw "Name cannot have whitespaces";
+ // DeviceType: int from 0 to ...
+ if(this.DeviceType<0 || this.DeviceType>MediatorConfig.DeviceTypes[MediatorConfig.DeviceTypes.length-1].Value)
+ throw "DeviceType is not set";
+ // DeviceIp: valid IP-Address
+ var validIpTest =/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
+ if(!validIpTest.test(this.DeviceIp))
+ throw "IP-Address is not valid";
+ // TrapsPort: valid Port
+ if(this.TrapsPort<=0 || this.TrapsPort>65535)
+ throw "TrapsPort is not valid";
+ // NeModel: valid XMLFilename
+ if(this.NeModel===undefined || this.NeModel.length<=0)
+ throw "NE XML Filename is not valid";
+ // NetconfPort: valid Port
+ if(this.NetconfPort<=0 || this.NetconfPort>65535)
+ throw "Netconf Port is not valid";
+
+ return true;
+}
+function PortRange(a)
+{
+ if(a!==undefined)
+ {
+ this.Min=a[0];
+ this.Max=a[1];
+ }
+ else
+ {
+ this.Min=0;
+ this.Max=0;
+ }
+}
+function JavaMemParam(str)
+{
+ if(str!==undefined)
+ {
+
+
+ }
+}
+function ServerConfig(obj){
+ if (obj !== undefined) {
+ this.HomeDir = obj.home;
+ this.Host = obj.host;
+ this.Port = obj.port;
+ this.NetconfRange=new PortRange(obj.ncrange);
+ this.SnmpRange = new PortRange(obj.snmprange);
+ this.JmxRange = new PortRange(obj.jmxrange);
+ this.LogLevel = obj.loglevel;
+ this.LogFile = obj.logfile;
+ this.MediatorLogLevel = obj.mediator-loglevel;
+ this.MediatorDevicePingTimeout=obj.mediator-devicepingtimeout;
+ this.MediatorSnmpLatency = obj.mediator-snmplatency;
+ this.MediatorMemory = new JavaMemParam(obj.mediator-memory);
+ }
+ else
+ {
+ this.HomeDir = "";
+ this.Host = "";
+ this.Port = 0;
+ this.NetconfRange=new PortRange();
+ this.SnmpRange = new PortRange();
+ this.JmxRange = new PortRange();
+ this.LogLevel = "";
+ this.LogFile = "";
+ this.MediatorLogLevel = "";
+ this.MediatorDevicePingTimeout=0;
+ this.MediatorSnmpLatency = 0;
+ this.MediatorMemory = new JavaMemParam();
+ }
+}
+function MediatorServer(url) {
+ this._root = url;
+ // if(this._root.endsWith("/"))
+ this._root = this._root + "/";
+ this._mediatorConfigs = [];
+ this._neXMLFilenames = undefined;
+ this.defaultODLConfig = {Server:"sendateodl5.fritz.box",Port:8181,User:"admin",Password:"admin"};
+
+}
+MediatorServer.prototype.getConfigs = function(){return this._mediatorConfigs;}
+
+MediatorServer.prototype.SetDefaultODLConfig = function(cfg)
+{
+ this.defaultODLConfig = cfg;
+}
+MediatorServer.prototype.GetDefaultODLConfig = function()
+{
+ return this.defaultODLConfig;
+}
+MediatorServer.prototype.refreshConfig = function(configs,cb)
+{
+ var changed = [];
+ if(this._mediatorConfigs===undefined)
+ {
+ if(cb!==undefined)
+ cb(changed);
+ return;
+ }
+ if(configs!==undefined && configs.length>0)
+ {
+ var i,j;
+ for(i=0;i<configs.length;i++)
+ {
+ //find config in array by name
+ for(j=0;j<this._mediatorConfigs.length;j++)
+ {
+ if(this._mediatorConfigs[j].Name==configs[i].Name)
+ {
+ //refresh data
+ this._mediatorConfigs[j].refreshData(configs[i]);
+ changed.push(configs[i]);
+ break;
+ }
+ }
+ }
+ }
+ if(cb!==undefined)
+ cb(changed);
+}
+MediatorServer.prototype.onConfigsReceived = function(configJSONArray) {
+ this._mediatorConfigs = [];
+ for (var i = 0; i < configJSONArray.length; i++) {
+ var c = new MediatorConfig(configJSONArray[i]);
+ this._mediatorConfigs.push(c);
+ }
+}
+MediatorServer.prototype.onNeXMLReceived = function(neXMLFilenamesArray) {
+ this._neXMLFilenames = neXMLFilenamesArray;
+}
+
+MediatorServer.prototype.LoadNetworkElementXMLFiles = function(cb,cbError) {
+ var _self = this;
+ this.post("getnemodels", function(response) {
+ if (response.code == 1) {
+ _self.onNeXMLReceived(response.data);
+ if (cb !== undefined)
+ cb(_self._neXMLFilenames);
+ } else
+ {
+ _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.LoadLogs = function(name,cb,cbError)
+{
+ var _self = this;
+ this.post("getlog&name="+name,function(response){
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ } else
+ { _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.LoadAvailableNCPorts = function(cb,cbError)
+{
+ var _self = this;
+ this.post("getncports",function(response){
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ } else
+ { _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.LoadAvailableSnmpPorts = function(cb,cbError)
+{
+ var _self = this;
+ this.post("getsnmpports",function(response){
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ }
+ else
+ {
+ _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.StartMediator = function(name, cb, cbError) {
+ var _self = this;
+ this.post("start",{name:name}, function(response) {
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ } else {
+ _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.StopMediator = function(name, cb, cbError) {
+ var _self = this;
+ this.post("stop",{name:name}, function(response) {
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ } else {
+ _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.ReloadConfig = function(name,cb,cbError)
+{
+ var _self = this;
+ this.post("getconfig",{name:name},function(response){
+ if (response.code == 1) {
+ _self.refreshConfig(response.data,function(changes){
+ if (cb !== undefined)
+ cb(changes);
+ });
+ } else {
+ _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+
+}
+MediatorServer.prototype.LoadConfigs = function(cb,cbError) {
+ var _self = this;
+ this.post("getconfig", function(response) {
+ if (response.code == 1) {
+ _self.onConfigsReceived(response.data);
+ if (cb !== undefined)
+ cb(_self._mediatorConfigs);
+ } else {
+ _self.log(response.data);
+ }
+
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.Repair = function(cb,cbError)
+{
+ var _self = this;
+ this.post("repair", function(response) {
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ } else {
+ _self.log(response.data);
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.LoadVersion = function(cb,cbError)
+{
+ var _self = this;
+ this.post("version", function(response) {
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(response.data);
+ } else {
+ _self.log(response.data);
+ }
+
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+/*
+ * name: <String> deviceType: <int> deviceip: <Ipv4-String> trapsPort:<int>
+ * nexml:<String> ncport:<int> cb: callback-function
+ */
+MediatorServer.prototype.CreateMediator = function(name,devicetype,deviceip,deviceport,trapsPort,nexml,ncport, cb, cbError) {
+
+ var obj;
+ try
+ {
+ obj=new MediatorConfig({
+ Name:name,
+ DeviceType:devicetype,
+ DeviceIp:deviceip,
+ DevicePort:deviceport,
+ TrapPort:trapsPort,
+ NeXMLFile:nexml,
+ NcPort:ncport
+ });
+ obj.TestParams();
+ }
+ catch(e)
+ {
+ if(cbError!==undefined)
+ cbError(e);
+ }
+ this.post("create", {
+ config : JSON.stringify({
+ Name : obj.Name,
+ DeviceType : obj.DeviceType,
+ DeviceIp : obj.DeviceIp,
+ DevicePort : obj.DevicePort,
+ TrapPort : obj.TrapsPort,
+ NeXMLFile : obj.NeModel,
+ NcPort : obj.NetconfPort,
+ ODLConfig:[this.defaultODLConfig]
+ })
+ }, function(response) {
+ if(response.code==1)
+ {
+ if(cb!==undefined)
+ cb(true)
+ }
+ else
+ {
+ if(cbError!==undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.DeleteMediator = function(name, cb, cbError)
+{
+ var _self = this;
+ this.post('delete', {name:name}, function(response){
+ if(response.code==1)
+ {
+ if(cb!==undefined)
+ cb(true);
+ }
+ else
+ {
+ if(cb!==undefined)
+ cb(response.data);
+ }
+
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+MediatorServer.prototype.ClearLock = function(name, cb, cbError) {
+ var _self = this;
+ this.post("clearlock", {
+ name : name
+ }, function(response) {
+ if (response.code == 1) {
+ if (cb !== undefined)
+ cb(true);
+ } else {
+ _self.log(response.data);
+ if (cbError !== undefined)
+ cbError(response.data);
+ }
+ },function(err){
+ if(cbError!==undefined)
+ cbError(err);
+ });
+}
+/*
+ * do post request
+ *
+ * @params task
+ */
+MediatorServer.prototype.post = function(task, data, callback,callbackError) {
+ var _self = this;
+ if (typeof (data) === "function")
+ {
+ callbackError = callback;
+ callback = data;
+ }
+ var cb=function(r) {
+ if (callback !== undefined) {
+ try {
+ if (typeof (r) === "string")
+ r = JSON.parse(r);
+ callback(r);
+ } catch (e) {
+ _self.log(e);
+ if(callbackError!==undefined)
+ callbackError(e);
+ }
+ }
+ };
+
+ if(this.usejQueryv3)
+ {
+ $.post({
+ url : this._root + "api/?task=" + task,
+ data : data,
+ success : cb
+ });
+ }
+ else //jquery 1.x
+ {
+ if(typeof(data)=== "function")
+ {
+ $.post(this._root + "api/?task=" + task,cb).done(function() {
+ _self.log( "second success" );
+ })
+ .fail(function(e) {
+ _self.log( "error" +e);
+ if(callbackError!==undefined)
+ callbackError(e);
+ })
+ .always(function() {
+ _self.log( "finished" );
+ });
+ }
+ else
+ {
+ $.post(this._root + "api/?task=" + task,data,cb).done(function() {
+ _self.log( "second success" );
+ })
+ .fail(function(e) {
+ _self.log( "error" +e);
+ if(callbackError!==undefined)
+ callbackError(e);
+ })
+ .always(function() {
+ _self.log( "finished" );
+ });
+ }
+ }
+}
+
+MediatorServer.prototype._error = function(message) {
+ console.log(message);
+}
+MediatorServer.prototype.log = function(message) {
+// console.log(message);
+}
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/images/mwtnMediator.png b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/images/mwtnMediator.png Binary files differnew file mode 100755 index 00000000..f7c2a6c0 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/images/mwtnMediator.png diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator-custom.css b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator-custom.css new file mode 100644 index 00000000..15a684f1 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator-custom.css @@ -0,0 +1,69 @@ +/** + * Add your application related css here + */ +.mwtnMediatorGrid { + height: 600px; + background-color: white; +} + +.mwtnMediatorGrid span { + color: #393939; +} +span.mwtnMediatorStatusRunning{ + color: darkgreen; +} +span.mwtnMediatorStatusNotRunning{ + color: darkred; +} +span.mwtnMediatorCStatusIcon{ + font-size:2rem; + vertical-align:middle; +} +span.mwtnMediatorOStatusIcon{ + font-size:2.5rem; + vertical-align:middle; +} + +#mediatorserver-list{ + list-style-type:none; + padding:0; + margin:0; + display:block; + +} +#mediatorserver-list > li +{ + padding:0.3rem; + display:block; + position:relative; +} +#mediatorserver-list > li:nth-child(even) +{ + background:#FFF; +} +#mediatorserver-list > li:nth-child(odd) +{ + background:#EEE; +} +#mediatorserver-list > li.selected +{ + background:#EBFF7F; +} +#mediatorserver-list > li > span.desc +{ + display:block; +} +#mediatorserver-list > li > div.icons +{ + position:absolute; + right:0;top:0;bottom:0;width:auto; +} +#mediatorserver-list > li > div.icons > span.fa +{ + position:relative;margin-right:.6rem;margin-top:.3rem;font-size:2rem;cursor:pointer; +} +#mediatorserver-list > li > div.icons > span.fa:hover +{ + font-weight:bold; +} +.acc-mediatorlog > .panel-group .panel-body{padding:0;}
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.controller.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.controller.js new file mode 100644 index 00000000..5f35ba66 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.controller.js @@ -0,0 +1,613 @@ +/* + * @copyright 2017 highstreet technologies GmbH and others. All rights reserved. + * + * @license + * 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/mwtnMediator/mwtnMediator.module', + 'app/mwtnMediator/mwtnMediator.services'], + function(mwtnMediatorApp) { + + var mediatorServer; + var autoRefresh; + mwtnMediatorApp.register.controller('mwtnMediatorCtrl', ['$scope', '$rootScope','$uibModal', '$mwtnLog', '$mwtnMediator', + function($scope, $rootScope, $uibModal, $mwtnLog, $mwtnMediator) { + autoRefresh=false; + var COMPONENT = 'mwtnMediatorCtrl'; + $mwtnLog.info({component: COMPONENT, message: 'mwtnMediatorCtrl started!'}); + $rootScope.section_logo = 'src/app/mwtnMediator/images/mwtnMediator.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif' + $scope.highlightFilteredHeader = $mwtnMediator.highlightFilteredHeader; + + + + $scope.gridOptions = JSON.parse(JSON.stringify($mwtnMediator.gridOptions)); + $scope.gridOptions.rowHeight = 44; + + var statusCellTemplate = [ + '<div class="ui-grid-cell-contents">', + '<span class="mwtnMediatorStatusRunning" ng-show="grid.getCellValue(row, col)>0">running ({{grid.getCellValue(row, col)}})</span>', + '<span class="mwtnMediatorStatusNotRunning" ng-show="grid.getCellValue(row, col)==0">stopped</span>', + '</div>' + ].join(''); + var connectionStatusCellTemplate = [ + '<div class="ui-grid-cell-contents">', + '<span class="fa fa-server mwtnMediatorOStatusIcon" style="margin-right:-0.5rem;"></span>', + '<span class="fa fa-check-circle-o mwtnMediatorCStatusIcon" style="color:green;" ng-show="grid.getCellValue(row, col).Netconf"></span>', + '<span class="fa fa-times-circle-o mwtnMediatorCStatusIcon" style="color:red;" ng-show="!grid.getCellValue(row, col).Netconf"></span>', + '<span class="fa fa-minus mwtnMediatorCStatusIcon" style="color:green;font-weight:bold;" ng-show="grid.getCellValue(row, col).Netconf"></span>', + '<span class="fa fa-ellipsis-h mwtnMediatorCStatusIcon" style="color:red;font-weight:bold;" ng-show="!grid.getCellValue(row, col).Netconf"></span>', + '<span class="fa fa-dot-circle-o mwtnMediatorCStatusIcon" style="font-size:3rem;color:#666;"></span>', + '<span class="fa fa-minus mwtnMediatorCStatusIcon" style="color:green;font-weight:bold;" ng-show="grid.getCellValue(row, col).NetworkElement"></span>', + '<span class="fa fa-ellipsis-h mwtnMediatorCStatusIcon" style="color:red;font-weight:bold;" ng-show="!grid.getCellValue(row, col).NetworkElement"></span>', + '<span class="fa fa-check-circle-o mwtnMediatorCStatusIcon" style="color:green;" ng-show="grid.getCellValue(row, col).NetworkElement"></span>', + '<span class="fa fa-times-circle-o mwtnMediatorCStatusIcon" style="color:red;" ng-show="!grid.getCellValue(row, col).NetworkElement"></span>', + '<span class="fa fa-wifi mwtnMediatorOStatusIcon" style="margin-left:-0.5rem;"></span>', + '</div>'].join(''); + + var requiredNesActionCellTemplate = [ + '<a class="vCenter" ng-class="{attention: grid.appScope.hover}" >', + '<button class="btn btn-primary" ng-click="grid.appScope.startMediator(row.entity)">Start</button>', + '<button class="btn btn-default" ng-click="grid.appScope.stopMediator(row.entity)">Stop</button>', + '<button class="btn btn-default" ng-click="grid.appScope.showDetails(row.entity)"><i class="fa fa-info-circle" aria-hidden="true"></i></button>', + '</a>' ].join('<span> </span>'); + + $scope.gridOptions.columnDefs = [ + { field: 'Name', type: 'string', displayName: 'Mediator', headerCellClass: $scope.highlightFilteredHeader, width : 200 }, + { field: 'PID', type: 'int', name: 'Status', cellTemplate:statusCellTemplate, headerCellClass: $scope.highlightFilteredHeader, width : 120 }, + { field: 'DeviceIp', type: 'string', displayName: 'IP address', headerCellClass: $scope.highlightFilteredHeader, width : 120 }, + { + field: 'ConnectionStatus', + type: 'object', + name: 'Connection', + enableSorting : false, + enableFiltering: false, + cellTemplate:connectionStatusCellTemplate, + width : 150 + }, + { name : 'actions', + enableSorting : false, + enableFiltering: false, + cellTemplate: requiredNesActionCellTemplate, + width : 280, + pinnedRight : true + } + ]; + + + + var refreshMediators = function() + { + var i=$('#btn_refreshMediators > i'); + i.addClass("fa-spin"); + console.log("refresh mediators list"); + if(mediatorServer!==undefined) + { + mediatorServer.LoadConfigs(function(configs){ + $scope.data = configs; + $scope.$apply(); + i.removeClass("fa-spin"); + }, + function(err){ + $scope.data = []; + $scope.$apply(); + i.removeClass("fa-spin"); + console.log("cannot reach mediatorserver:"+err); + }); + } + } + var refreshMediator = function(name) + { + console.log("refresh mediators list"); + if(mediatorServer!==undefined) + { + mediatorServer.ReloadConfig(name,function(changes){ + $scope.$apply(); + }, + function(err){ + console.log("cannot reach mediatorserver:"+err); + }); + } + } + var onServerSelectedChanged = function(item){ + var serverURL; + if(item!==undefined) + { + if(typeof(item)==='object') + serverURL=item.url; + else if(typeof(item)==='string') + { + try + { + $mwtnMediator.getServerData(parseInt(item)).then(function(data){ + if(data!==undefined) + { + serverURL=data.url; + mediatorServer = new MediatorServer(serverURL); + $mwtnLog.info({component: COMPONENT, message: 'loading server configs for '+serverURL}); + refreshMediators(); + } + else + console.log("search for server data failed. should never happened") + }); + } + catch(e) + {"error loading server:n"+console.log(e);} + } + } + } + + /* GUI Events =======================================*/ + $scope.onAutoRefreshChanged = function() + { + autoRefresh = $('#ckbx_mediatorAutorefresh').prop('checked'); + console.log("set autorefresh to "+autoRefresh); + } + $scope.editMediatorServers = function() + { + var modalInstance = $uibModal.open({ + animation:true, + ariaLabelledBy: 'modal-title', + ariaDescribedBy: 'modal-body', + templateUrl: 'src/app/mwtnMediator/templates/mediatorServerConfigCtrl.tpl.html', + controller: 'MediatorServerConfigCtrl', + size: 'lg', + resolve: { + currentElement: function () { + return $scope.currentElement; + } + } + + }); + } + $scope.createNewMediator = function() + { + if(mediatorServer!==undefined) + { + console.log("create new mediator"); + var modalInstance = $uibModal.open({ + animation:true, + ariaLabelledBy: 'modal-title', + ariaDescribedBy: 'modal-body', + templateUrl: 'src/app/mwtnMediator/templates/mediatorCreateNew.tpl.html', + controller: 'MediatorNewCtrl', + size: 'lg', + resolve: { + currentElement: function () { + return $scope.currentElement; + } + } + + }); + } + else + { + console.log("no mediatorserver selected"); + } + } + $scope.refreshMediators = refreshMediators; + + $scope.startMediator = function(el) + { + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled',true); + console.log("starting mediator "+el.Name+" ..."); + if(mediatorServer!==undefined) + { + mediatorServer.StartMediator(el.Name,function(res){ + refreshMediator(el.Name); + //console.log(res); + },function(err){ + if(btn!==undefined) + btn.prop('disabled',false); + // console.log("error starting mediator"); + }); + } + } + $scope.stopMediator = function(el) + { + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled',true); + console.log("stopping mediator "+el.Name+" ..."); + if(mediatorServer!==undefined) + { + mediatorServer.StopMediator(el.Name,function(res){ + refreshMediator(el.Name); + //console.log(res); + },function(err){ + if(btn!==undefined) + btn.prop('disabled',false); + // console.log("error stopping mediator"); + }); + } + } + $scope.showDetails = function(el) + { + $scope.currentElement = el; + var modalInstance = $uibModal.open({ + animation:true, + ariaLabelledBy: 'modal-title', + ariaDescribedBy: 'modal-body', + templateUrl: 'src/app/mwtnMediator/templates/mediatorDetails.tpl.html', + controller: 'MediatorDetailsCtrl', + size: 'lg', + resolve: { + currentElement: function () { + return $scope.currentElement; + } + } + + }); + } + $scope.onchangeserver = function(){ + autoRefresh=false; + $('#ckbx_mediatorAutorefresh').prop('checked',autoRefresh); + onServerSelectedChanged($scope.medserver); + } + /* End of GUI Events===========================*/ + + + $scope.gridOptions.data = 'data'; + $scope.options={ + + } + + //load mediator servers from database + $mwtnMediator.getServerData().then(function(data){ + //set as option source for GUI selector + $scope.options.medservers=data; + //autoselect first item + if(data!==undefined && data.length>0) + { + onServerSelectedChanged(data[0]); + //$scope.medserver= + } + }); + var timer = setInterval(function(){ + if(autoRefresh && mediatorServer!==undefined) + { + refreshMediators(); + } + + },30000); + + }]); + + + /************************************************************************************ + * medaitorDetails Controller definition + ************************************************************************************/ + mwtnMediatorApp.register.controller('MediatorDetailsCtrl', ['$scope', '$uibModalInstance', '$uibModal', '$mwtnConnect', '$mwtnLog', '$mwtnMediator','currentElement', + function ($scope, $uibModalInstance, $uibModal, $mwtnConnect, $mwtnLog, $mwtnMediator, currentElement) { + + var COMPONENT = 'MediatorDetailsCtrl'; + var element = currentElement; + var error = function(msg) + { + $scope.statusmessage=''; + $scope.errormessage=msg; + $scope.$apply(); + } + var status = function(msg) + { + $scope.statusmessage=msg; + $scope.errormessage=''; + $scope.$apply(); + } + var reloadDelayed = function() + { + setTimeout(function(){ + mediatorServer.ReloadConfig(element.Name,function(res){ + $scope.$apply(); + },function(err){error(err);}); + },1000); + } + var refreshLogs = function() + { + mediatorServer.LoadLogs(currentElement.Name,function(res){ + $scope.logdata=res; + $scope.$apply(); + + },function(err){ + $scope.logdata=[]; + $scope.$apply(); + }); + } + $scope.statusmessage=''; + $scope.errormessage=''; + $scope.logGridOptions = JSON.parse(JSON.stringify($mwtnMediator.logGridOptions)); + //$scope.logGridOptions.rowHeight = 44; + $scope.logGridOptions.columnDefs = [ + { field: 'ts', type: 'string', displayName: 'Timestamp', headerCellClass: $scope.highlightFilteredHeader, width : 180 }, + { field: 'lvl', type: 'String', displayName: 'LogLevel', headerCellClass: $scope.highlightFilteredHeader, width : 90 }, + { field: 'src', type: 'string', displayName: 'Source', headerCellClass: $scope.highlightFilteredHeader, width : 120 }, + { field: 'msg', type: 'string', displayName: 'Message', headerCellClass: $scope.highlightFilteredHeader, width : 300 }, + + ]; + $scope.logGridOptions.data = 'logdata'; + // $mwtnLog.info({component: COMPONENT, message: 'MediatorDetailsCtrl started!'}); + $scope.data = { + el:currentElement + }; + $scope.ok = function () { + $uibModalInstance.close({el: currentElement}); + }; + $scope.start = function(){ + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled', true); + mediatorServer.StartMediator(element.Name,function(res){ + if(btn!==undefined) + btn.prop('disabled', true); + status(res); + reloadDelayed(); + },function(err){ + if(btn!==undefined) + btn.prop('disabled', false); + error(err); + + }); + }; + $scope.stop = function(){ + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled', true); + mediatorServer.StopMediator(element.Name,function(res){ + if(btn!==undefined) + btn.prop('disabled', true); + status(res); + reloadDelayed(); + },function(err){ + if(btn!==undefined) + btn.prop('disabled', false); + error(err); + + }); + }; + $scope.delete = function(){ + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled', true); + if(confirm("Do you really want to delete this mediator?")) + { + mediatorServer.DeleteMediator(element.Name,function(res){ + status(res); + },function(err){ + if(btn!==undefined) + btn.prop('disabled', false); + error(err); + }); + } + else + { + if(btn!==undefined) + btn.prop('disabled', false); + } + }; + $scope.unlock = function(){ + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled', true); + mediatorServer.ClearLock(element.Name,function(res){ + status(res); + reloadDelayed(); + },function(err){ + if(btn!==undefined) + btn.prop('disabled', false); + error(err); + }); + } + refreshLogs(); + } + ]); + /************************************************************************************ + * medaitorCreateNew Controller definition + ************************************************************************************/ + mwtnMediatorApp.register.controller('MediatorNewCtrl', ['$scope', '$uibModalInstance', '$uibModal', '$mwtnConnect', '$mwtnLog', + function ($scope, $uibModalInstance, $uibModal, $mwtnConnect, $mwtnLog) { + + var COMPONENT = 'MediatorNewCtrl'; + // $mwtnLog.info({component: COMPONENT, message: COMPONENT + ' started!'}); + var status = function(msg) + { + $scope.statusmessage=msg; + $scope.errormessage=""; + $scope.$apply(); + } + var error = function(msg) + { + $scope.statusmessage=""; + $scope.errormessage=msg; + $scope.$apply(); + } + $scope.options={ + nexmlmodel:[], + nedevicetype:MediatorConfig.DeviceTypes + }; + $scope.mediator={name:'',devicetype:0,remoteip:'',remoteport:161,trapsport:0,ncport:0,nexml:''}; + $scope.odlconfig=mediatorServer.GetDefaultODLConfig(); + $scope.odlsavebtn={enabled:false}; + + //=======load data + mediatorServer.LoadNetworkElementXMLFiles(function(xmlNames){ + $scope.options.nexmlmodel=xmlNames; + $scope.$apply(); + },function(err){ + error(err); + }); + mediatorServer.LoadAvailableNCPorts(function(portValues){ + if(portValues!==undefined && portValues.length>0) + { + $scope.mediator.ncport = portValues[0]; + } + },function(err){error(err);}); + mediatorServer.LoadAvailableSnmpPorts(function(portValues){ + if(portValues!==undefined && portValues.length>0) + { + $scope.mediator.trapsport = portValues[0]; + } + },function(err){error(err);}); + + + $scope.errormessage=''; + $scope.statusmessage=''; + + //====handle events======== + $scope.odledit = function(){ + $scope.odlsavebtn.enabled=true; + console.log("enable odl configs") + $scope.$apply(); + } + $scope.odlsave = function(){ + mediatorServer.SetDefaultODLConfig($scope.odlconfig); + } + $scope.ok = function () { + var btn=$(this); + if(btn!==undefined) + btn.prop('disabled', true); + mediatorServer.CreateMediator($scope.mediator.name, + $scope.mediator.devicetype, + $scope.mediator.remoteip, + $scope.mediator.remoteport, + $scope.mediator.trapsport, + $scope.mediator.nexml, + $scope.mediator.ncport, + function(e){ + if(e==true) + { + status("mediator created"); + setTimeout(function(){$uibModalInstance.close();},2000); + } + else + { + if(btn!==undefined) + btn.prop('disabled', false); + error(e); + + } + },function(err){ + if(btn!==undefined) + btn.prop('disabled', false); + error(err); + + }); + + }; + $scope.cancel = function(){ + $uibModalInstance.close(); + }; + + } + ]); + /************************************************************************************ + * medaitorServerConfig Controller definition + ************************************************************************************/ + mwtnMediatorApp.register.controller('MediatorServerConfigCtrl', ['$scope', '$uibModalInstance', '$uibModal', '$mwtnConnect', '$mwtnLog', '$mwtnMediator', + function ($scope, $uibModalInstance, $uibModal, $mwtnConnect, $mwtnLog, $mwtnMediator) { + + var COMPONENT = 'MediatorServerConfigCtrl'; + // $mwtnLog.info({component: COMPONENT, message: COMPONENT + ' started!'}); + var onServerRowSelect = function(obj,id) + { + if(obj!=undefined) + $(obj).addClass("selected"); + var tbxId=$('#tbx_mediatorserver-id'); + var tbxName=$('#tbx_mediatorserver-name'); + var tbxHost = $('#tbx_mediatorserver-host'); + var tbxVersion = $('#tbx_mediatorserver-version'); + var tbxVersionMed = $('#tbx_mediatorserver-medversion'); + tbxId.prop('disabled',true); + tbxName.prop('disabled',true); + tbxHost.prop('disabled',true); + tbxVersion.prop('disabled',true); + tbxVersionMed.prop('disabled',true); + + $mwtnMediator.getServerData(id).then(function(data){ + if(data!==undefined) + { + tbxId.val(data.id); + tbxName.val(data.name); + tbxHost.val(data.url); + tbxVersion.val(""); + tbxVersionMed.val(""); + var s=new MediatorServer(data.url); + s.LoadVersion(function(d){ + tbxVersion.val(d.server); + tbxVersionMed.val(d.mediator); + + },function(err){ + + }); + } + }); + } + var create = function(host,name,port) + { + var url=host+":"+port; + $mwtnMediator.addServer(name,url).then(function(data){ + reload(); + }); + } + var onEdit = function(id) + { + var tbxName=$('#tbx_mediatorserver-name'); + var tbxHost = $('#tbx_mediatorserver-host'); + tbxName.prop('disabled',false); + tbxHost.prop('disabled',false); + + } + var onDelete = function(id) + { + if(confirm("Do you really want to delete?")) + { + // console.log("delete server with id="+id); + $mwtnMediator.removeServer(id).then(function(){reload();}); + } + } + var reload = function(){ + $mwtnMediator.getServerData().then(function(data){ + + //fill table + var list=$('#mediatorserver-list'); + list.html(''); + if(data!==undefined && data.length>0) + { + for(var i=0;i<data.length;i++) + { + var desc=$('<span class="desc" id="item_'+data[i].id+'">'+data[i].name+'</span>'); + var li=$('<li></li>'); + var iconsbox=$('<div class="icons"></div>'); + var edit=$('<span class="fa fa-edit" id="item_edit_'+data[i].id+'"></span>'); + var del=$('<span class="fa fa-trash-o" id="item_del_'+data[i].id+'"></span>'); + iconsbox.html([edit,del]); + li.html([desc,iconsbox]); + if(i==0) + li.addClass("selected"); + //register click handlers + desc.click(function(){ + $('#mediatorserver-list > li').removeClass('selected'); + onServerRowSelect(this.parentNode,$(this).prop('id').substr(5)); + }); + edit.click(function(){ + onEdit($(this).prop('id').substr(10)); + }); + del.click(function(){ + onDelete($(this).prop('id').substr(9)); + }); + list.append(li); + } + onServerRowSelect(undefined,data[0].id); + } + }); + } + reload(); + $scope.close = function(){ + $uibModalInstance.close(); + }; + }]); + +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.module.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.module.js new file mode 100644 index 00000000..19c9142d --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.module.js @@ -0,0 +1,54 @@ +/* + * 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', + 'app/mwtnCommons/bower_components/angular-clipboard/angular-clipboard', + 'src/app/mwtnMediator/class.mediator.js'], function(ng) { + var mwtnMediatorApp = angular.module('app.mwtnMediator', ['ui.grid', 'ui.bootstrap', 'app.core', 'ui.router.state', 'config', 'angular-clipboard']); + + mwtnMediatorApp.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider) { + mwtnMediatorApp.register = { + controller : $controllerProvider.register, + directive : $compileProvider.directive, + factory : $provide.factory, + service : $provide.service + }; + + NavHelperProvider.addControllerUrl('app/mwtnMediator/mwtnMediator.controller'); + NavHelperProvider.addToMenu('mwtnMediator', { + "link" : "#/pnfMediator", + "active" : "main.mwtnMediator", + "title" : "pnf Mediator", + "icon" : "fa fa-globe", // Add navigation icon css class here + "page" : { + "title" : "pnf Mediator", + "description" : "mwtnMediator" + } + }); + + var access = routingConfig.accessLevels; + + $stateProvider.state('main.mwtnMediator', { + url: 'pnfMediator', + access: access.admin, + views : { + content : { + templateUrl: 'src/app/mwtnMediator/templates/frame.tpl.html', + controller: 'mwtnMediatorCtrl' + } + } + }); + + }); + + return mwtnMediatorApp; +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.services.js b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.services.js new file mode 100644 index 00000000..363b79a8 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/mwtnMediator.services.js @@ -0,0 +1,113 @@ +/* + * @copyright 2017 highstreet technologies 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/mwtnMediator/mwtnMediator.module'],function(mwtnMediatorApp) { + + mwtnMediatorApp.register.factory('$mwtnMediator', function($http, $q, $mwtnCommons, $mwtnDatabase, $mwtnLog) { + + var COMPONENT = '$mwtnMediator'; + $mwtnLog.info({component: COMPONENT, message: '$mwtnMediator started!'}); + + var service = {}; + + // import of mwtnCommons + service.gridOptions = $mwtnCommons.gridOptions; + service.highlightFilteredHeader = $mwtnCommons.highlightFilteredHeader; + + service.getAllData = $mwtnDatabase.getAllData; + service.getFilteredSortedData = $mwtnDatabase.getFilteredSortedData; + service.logGridOptions = $mwtnCommons.gridOptions; + + // service specific functions + service.getServerData = function(id){ + var deferred = $q.defer(); + var functionid="mwtn"; + var type="mediator-server"; + var sort = [ { 'id' : {order : 'asc'}}]; + + if(id===undefined)//get all + $mwtnDatabase.getAllData(functionid,type,0,99,sort,null).then(function(success){ + var list=[]; + success.data.hits.hits.map(function(entry){ + var row = { + id: entry._source.id, + url: entry._source.url, + name: entry._source.name + }; + list.push(row); + }); + deferred.resolve(list); + }, function(error){ + $mwtnLog.error({component: 'private getAlldata', message: JSON.stringify(error.data)}); + deferred.reject(error); + }); + else //get by id + $mwtnDatabase.getFilteredSortedData(functionid,type,0,99,sort,{'match':{'id':id}}).then(function(success){ + var list=[]; + success.data.hits.hits.map(function(entry){ + var row = { + id: entry._source.id, + url: entry._source.url, + name: entry._source.name + }; + list.push(row); + }); + deferred.resolve(list.length>0?list[0]:undefined); + }, function(error){ + $mwtnLog.error({component: 'private getFilteredSortedData', message: JSON.stringify(error.data)}); + deferred.reject(error); + }); + + return deferred.promise; + + + }; + /* + service.getMaxId = function(){ + var deferred = $q.defer(); + $mwtnDatabase.getAllData(functionid,type,0,99,sort,{'match'}).then(function(success){ + + return deferred.promise; + }; + */ + service.addServer = function(name,url){ + var deferred = $q.defer(); + var functionId="mwtn"; + var docType="mediator-server"; + //check params + var data={name:name,url:url}; + //check if contains + //insert into db + $mwtnDatabase.createSingleDocument(functionId, docType, id, data).then(function(success){ + + + deferred.resolve(data); + },function(error){ + $mwtnLog.error({component: 'private addServer', message: JSON.stringify(error.data)}); + deferred.reject(error); + }); + return deferred.promise; + }; + service.removeServer = function(id){ + var deferred = $q.defer(); + var functionId="mwtn"; + var docType="mediator-server"; + + $mwtnDatabase.deleteSingleDocument(functionId, docType, id).then(function(success){ + deferred.resolve(data); + },function(error){ + $mwtnLog.error({component: 'private removeServer', message: JSON.stringify(error.data)}); + deferred.reject(error); + }); + return deferred.promise; + }; + + return service; + }); + +}); diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/frame.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/frame.tpl.html new file mode 100644 index 00000000..debf0c21 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/frame.tpl.html @@ -0,0 +1,49 @@ +<ht-header help-link='sdnr/pnfMediator/0.4.0/README.md'></ht-header> +<div class=""></div> +<div class="owl container" style="width: 100%;"> + <div class="row"> + <div class="col-md-4"> + <div id="mvtnMediatorServerSelector"> + <select class="form-control" ng-model="medserver" ng-change="onchangeserver()" > + <option ng-repeat="option in options.medservers" value="{{option.id}}">{{option.name}}({{option.url}})</option> + </select> + </div> + </div> + <div class="col-md-8"> + <div style="float:left;display:inline-block;"> + <button class="btn btn-default" ng-click="editMediatorServers()"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></button> + </div> + <div style="float:right;display:inline-block;"> + <div class="checkbox" style="display:inline-block;"> + <label style="color:white;"><input type="checkbox" id="ckbx_mediatorAutorefresh" ng-click="onAutoRefreshChanged()" value="">AutoRefresh</label> + </div> + <button class="btn btn-default" ng-click="createNewMediator()"><i class="fa fa-plus-circle" aria-hidden="true"></i></button> + <button class="btn btn-default" id="btn_refreshMediators" ng-click="refreshMediators()"><i class="fa fa-refresh" aria-hidden="true"></i></button> + + </div> + + </div> + </div> + <div class="row"> + <div class="col-md-12"> + <hr class="ng-scope" /> + </div> + </div> + <div class="row"> + <div class="col-md-12"> + <div id="mwtnMediatorGrid" + ui-grid="gridOptions" + ui-grid-exporter + ui-grid-selection + ui-grid-pinning + ui-grid-resize-columns + ui-grid-move-columns + class="mwtnMediatorGrid"></div> + </div> + </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 diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorCreateNew.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorCreateNew.tpl.html new file mode 100644 index 00000000..5934eb8b --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorCreateNew.tpl.html @@ -0,0 +1,99 @@ +<div class="modal-header"> + <h3 class="modal-title" id="modal-title">{{ data.el.Name }}</h3> +</div> +<div class="modal-body" id="modal-body"> + <div class="row"> + <div class="col-md-3"><span>Name:</span></div> + <div class="col-md-9"> + <input type="text" class="form-control" ng-model="mediator.name" /> + </div> + </div> + <div class="row"> + <div class="col-md-3"><span>DeviceType:</div> + <div class="col-md-9"> + <select class="form-control" ng-model="mediator.devicetype" > + <option ng-repeat="option in options.nedevicetype" value="{{option.Value}}">{{option.Name}}</option> + </select> + </div> + </div> + <div class="row"> + <div class="col-md-3"><span>IP address:</div> + <div class="col-md-9"> + <input type="text" ng-model="mediator.remoteip" class="form-control" style="display:inline-block;width:70%;"/> + <span> : </span> + <input type="text" ng-model="mediator.remoteport" class="form-control" style="display:inline-block;width:25%;float:right;"/> + + </div> + </div> + <div class="row"> + <div class="col-md-3"><span>TrapsPort:</div> + <div class="col-md-9"> + <input type="number" class="form-control" ng-model="mediator.trapsport" /> + </div> + </div> + <div class="row"> + <div class="col-md-3"><span>NetconfPort:</div> + <div class="col-md-9"> + <input type="number" class="form-control" ng-model="mediator.ncport" /> + </div> + </div> + <div class="row"> + <div class="col-md-3"><span>NeModel:</div> + <div class="col-md-9"> + <select class="form-control" ng-model="mediator.nexml"> + <option ng-repeat="option in options.nexmlmodel" value="{{option}}">{{option}}</option> + </select> + </div> + </div> + <hr class="row" /> + <div class="row"> + <uib-accordion close-others="oneAtATime"> + <div uib-accordion-group class="panel-default" is-open="false"> + <uib-accordion-heading> + <i class="pull-left fa" ng-class="{'fa-chevron-down': false, 'fa-chevron-right': true}"></i> + <span>{{'ODL Connection Config' | translate}}</span> + </uib-accordion-heading> + <div class="" style="position:relative;"> + <button class="btn btn-default" ng-click="odledit()" style="position:absolute;top:1rem;right:1rem;"><i class="fa fa-edit"></i></button> + <div class="row"> + <div class="col-md-3"><span >Hostname:</span></div> + <div class="col-md-6"><input ng-disabled="!odlsavebtn.enabled" class="form-control" type="text" ng-model="odlconfig.Server" /></div> + </div> + <div class="row"> + <div class="col-md-3"><span >Port:</span></div> + <div class="col-md-6"><input ng-disabled="!odlsavebtn.enabled" class="form-control" type="text" ng-model="odlconfig.Port" /></div> + </div> + <div class="row"> + <div class="col-md-3"><span >Username:</span></div> + <div class="col-md-6"><input ng-disabled="!odlsavebtn.enabled" class="form-control" type="text" ng-model="odlconfig.User" /></div> + </div> + <div class="row"> + <div class="col-md-3"><span >Password:</span></div> + <div class="col-md-6"><input ng-disabled="!odlsavebtn.enabled" class="form-control" type="text" ng-model="odlconfig.Password" /></div> + </div> + <div class="row"> + <div class="col-md-3"></div> + <div class="col-md-6"><button class="btn btn-default" ng-click="odlsave()" ng-disabled="!odlsavebtn.enabled">Save</button></div> + </div> + + </div> +</div> + </uib-accordion> + </div> + <div class="row"> + <div class="col-md-12"> + <span style="display:block;text-align:right;color:#0F0;">{{statusmessage}}</span> + <span style="display:block;text-align:right;color:#F00;">{{errormessage}}</span> + </div> + </div> + +</div> +<div class="modal-footer"> + <button class="btn btn-primary" type="button" ng-click="ok()"> + <span>{{'MWTN_MED_ADD' | translate}}</span> + </button> + <button class="btn btn-danger" type="button" ng-show="true" ng-click="cancel()"> + <i class="fa fa-trash" aria-hidden="true"></i> + <span>{{'MWTN_CANCEL' | translate}}...</span> + </button> +</div> diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorDetails.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorDetails.tpl.html new file mode 100644 index 00000000..5223df03 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorDetails.tpl.html @@ -0,0 +1,96 @@ +<div class="modal-header"> + <h3 class="modal-title" id="modal-title">{{ data.el.Name }}</h3> +</div> +<div class="modal-body" id="modal-body"> + <div class="row"> + <div class="col-xs-3"><span>DeviceType:</span></div> + <div class="col-xs-9"><span>{{data.el.DeviceTypeString}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>DeviceIP:</span></div> + <div class="col-xs-9"><span>{{data.el.DeviceIp}}:{{data.el.DevicePort}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>TrapsPort:</span></div> + <div class="col-xs-9"><span>{{data.el.TrapsPort}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>NetconfPort:</span></div> + <div class="col-xs-9"><span>{{data.el.NetconfPort}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>NeXMLModel:</span></div> + <div class="col-xs-9"><span>{{data.el.NeModel}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>Status:</span></div> + <div class="col-xs-9"> + <span class="mwtnMediatorStatusRunning" ng-show="{{data.el.PID}}>0">running ({{data.el.PID}})</span> + <span class="mwtnMediatorStatusNotRunning" ng-show="{{data.el.PID}}==0">stopped</span> + </div> + </div> + <div class="row"> + <div class="col-xs-3"><span>Locked:</span></div> + <div class="col-xs-9"><span>{{data.el.IsLocked}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>NetconfConnected:</span></div> + <div class="col-xs-9"><span>{{data.el.IsNetConfConnected}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>NEConnected:</span></div> + <div class="col-xs-9"><span>{{data.el.IsNetworkElementConnected}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>Firewall Configured:</span></div> + <div class="col-xs-9"><span>{{data.el.FirewallRuleActive}}</span></div> + </div> + <div class="row"> + <div class="col-xs-3"><span>Autorun:</span></div> + <div class="col-xs-9"><span>{{data.el.Autorun}}</span></div> + </div> + <div class="row"> + <uib-accordion close-others="oneAtATime" class="acc-mediatorlog"> + <div uib-accordion-group class="panel-default" is-open="false"> + <uib-accordion-heading> + <i class="pull-left fa" ng-class="{'fa-chevron-down': false, 'fa-chevron-right': true}"></i> + <span>{{'Logs' | translate}}</span> + </uib-accordion-heading> + <div id="mwtnLogGrid" + ui-grid="logGridOptions" + ui-grid-exporter + ui-grid-selection + ui-grid-pinning + ui-grid-resize-columns + ui-grid-move-columns + class="mwtnLogGrid"></div> + +</div> + </uib-accordion> + </div> + <div class="row"> + <div class="col-md-12"> + <span style="display:block;text-align:right;color:#0F0;">{{statusmessage}}</span> + <span style="display:block;text-align:right;color:#F00;">{{errormessage}}</span> + </div> + </div> +</div> +<div class="modal-footer"> + <button class="btn btn-default" type="button" ng-show="{{data.el.IsLocked}}" ng-click="unlock()"> + <i class="fa fa-lock" aria-hidden="true"></i> + <span>{{'Unlock' | translate}}</span> + </button> + <button class="btn btn-danger" type="button" ng-show="true" ng-click="delete()"> + <i class="fa fa-trash" aria-hidden="true"></i> + <span>{{'MWTN_MED_DELETE' | translate}}...</span> + </button> + <button class="btn btn-primary" type="button" ng-show="true" ng-click="start()"> + <span>{{'MWTN_MED_START' | translate}}...</span> + </button> + <button class="btn btn-primary" type="button" ng-show="true" ng-click="stop()"> + <span>{{'MWTN_MED_STOP' | translate}}...</span> + </button> + <button class="btn btn-primary" type="button" ng-click="ok()"> + <span>{{'MWTN_MED_CLOSE' | translate}}</span> + </button> +</div> diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorServerConfigCtrl.tpl.html b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorServerConfigCtrl.tpl.html new file mode 100644 index 00000000..c3e96585 --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/mwtnMediator-module/src/main/resources/mwtnMediator/templates/mediatorServerConfigCtrl.tpl.html @@ -0,0 +1,41 @@ +<div class="modal-header"> + <h3 class="modal-title" id="modal-title">{{ data.el.Name }}</h3> +</div> +<div class="modal-body" id="modal-body"> + <div class="row"> + <div class="col-xs-12 col-lg-6"> + <h3>MediatorServers:</h3> + <ul id="mediatorserver-list" > + </ul> + </div> + <div class="col-xs-6 col-lg-6"> + <h3>Configuration:</h3> + <div id="mediatorserver-details"> + <div class="row"> + <div class="col-xs-5"><span style="float:right;">Id:</span></div> + <div class="col-xs-7"><input type="text" id="tbx_mediatorserver-id" name="mediatorserver-id" value="" /></div> + </div> + <div class="row"> + <div class="col-xs-5"><span style="float:right;">Name:</span></div> + <div class="col-xs-7"><input type="text" id="tbx_mediatorserver-name" name="mediatorserver-name" value="" /></div> + </div> + <div class="row"> + <div class="col-xs-5"><span style="float:right;">Host:</span></div> + <div class="col-xs-7"><input type="text" id="tbx_mediatorserver-host" name="mediatorserver-host" value="" /></div> + </div> + <div class="row"> + <div class="col-xs-5"><span style="float:right;">Version:</span></div> + <div class="col-xs-7"><input type="text" id="tbx_mediatorserver-version" name="mediatorserver-version" value="" /></div> + </div> + <div class="row"> + <div class="col-xs-5"><span style="float:right;">MediatorVersion:</span></div> + <div class="col-xs-7"><input type="text" id="tbx_mediatorserver-medversion" name="mediatorserver-medversion" value="" /></div> + </div> + </div> + </div> + </div> + <hr class="row" /> + <div class="row"> + <button class="btn btn-primary" ng-click="close()">Close</button> + </div> +</div>
\ No newline at end of file diff --git a/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/pom.xml b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/pom.xml new file mode 100644 index 00000000..d19f85ed --- /dev/null +++ b/sdnr/wireless-transport/code-Carbon-SR1/ux/mwtnMediator/pom.xml @@ -0,0 +1,24 @@ +<?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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>mwtn</artifactId> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <version>0.5.1-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + <packaging>pom</packaging> + <groupId>com.highstreet.technologies.odl.dlux</groupId> + <artifactId>mwtnMediator</artifactId> + <version>0.5.1-SNAPSHOT</version> + <name>${prefix} ${project.artifactId}</name> + + <prerequisites> + <maven>3.0</maven> + </prerequisites> + + <modules> + <module>mwtnMediator-module</module> + <module>mwtnMediator-bundle</module> + </modules> +</project>
\ No newline at end of file |