changeset 256:51841a9b5f81

Add jvm id and system id specification to gateways commands client. Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/024982.html
author Chris Lessard <clessard@redhat.com>
date Wed, 13 Sep 2017 09:24:54 -0400
parents ff86d084614e
children 2c430aae0242
files services/commands/src/main/resources/agent.html services/commands/src/main/resources/agent2.html services/commands/src/main/resources/index.html
diffstat 3 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/services/commands/src/main/resources/agent.html	Mon Sep 11 18:00:31 2017 +0200
+++ b/services/commands/src/main/resources/agent.html	Wed Sep 13 09:24:54 2017 -0400
@@ -83,6 +83,8 @@
 
             CmdChan.socket.onmessage = function (message) {
                 var data = JSON.parse(message.data);
+                var jvmId = escapeHtml(data.jvmId);
+                var systemId = escapeHtml(data.systemId);
                 var payload = data.payload;
 
                 var requestArguments = {}
@@ -95,6 +97,8 @@
 
                 // Print message to screen
                 data.payload = requestArguments;
+                data.jvmId = jvmId;
+                data.systemId = systemId;
                 Console.log('Got: ' + JSON.stringify(data));
 
                 // parse message
--- a/services/commands/src/main/resources/agent2.html	Mon Sep 11 18:00:31 2017 +0200
+++ b/services/commands/src/main/resources/agent2.html	Wed Sep 13 09:24:54 2017 -0400
@@ -27,7 +27,7 @@
         }
     ]]></style>
     <script type="application/javascript">
-    //<![CDATA[
+        //<![CDATA[
         var CmdChan = {};
 
         var Response = {};
@@ -83,6 +83,8 @@
 
             CmdChan.socket.onmessage = function (message) {
                 var data = JSON.parse(message.data);
+                var jvmId = escapeHtml(data.jvmId);
+                var systemId = escapeHtml(data.systemId);
                 var payload = data.payload;
 
                 var requestArguments = {}
@@ -95,11 +97,13 @@
 
                 // Print message to screen
                 data.payload = requestArguments;
+                data.jvmId = jvmId;
+                data.systemId = systemId;
                 Console.log('Got: ' + JSON.stringify(data));
 
                 // parse message
                 Msg.fromRequest(message.data);
-                
+
                 // send the always-ok reply
                 CmdChan.socket.send(Response.asJson(Msg.sequence, 'OK'));
                 Console.log('Info: OK reply sent.');
--- a/services/commands/src/main/resources/index.html	Mon Sep 11 18:00:31 2017 +0200
+++ b/services/commands/src/main/resources/index.html	Wed Sep 13 09:24:54 2017 -0400
@@ -88,9 +88,14 @@
         CmdChan.sendMessage = (function() {
             var action = document.getElementById('cmd-chan').value;
             var agent = document.getElementById('agent').value;
+            var systemId = document.getElementById('systemId').value;
+            var jvmId = document.getElementById('jvmId').value;
             var argumentKeys = document.getElementsByClassName('optionArgument');
             var argumentValues = document.getElementsByClassName('optionArgumentVal');
 
+            systemId = (systemId.length == 0) ? 'ignored_system' : systemId;
+            jvmId = (jvmId.length == 0) ? 'ignored_jvm' : jvmId;
+
             if (action != '' && agent != '') {
                 var clientRequest = {};
                 var url = null;
@@ -117,7 +122,8 @@
                 if (token != null) {
                     query_string = "?access_token=" + token;
                 }
-                url = url + '/commands/v1/actions/' + action + '/systems/ignored_system/agents/' + agent + '/jvms/ignored_jvm/sequence/' + CmdChan.sequence++ + query_string;
+                url = url + '/commands/v1/actions/' + action + '/systems/' + systemId + '/agents/' + agent + '/jvms/' + jvmId +'/sequence/' + CmdChan.sequence++ + query_string;
+
                 CmdChan.connect( url, clientRequest );
                 document.getElementById('cmd-chan').value = '';
             }
@@ -157,7 +163,9 @@
     </p>
     <p>
         <input type="text" placeholder="Type the action and press enter in order to send a message to the agent below." id="cmd-chan" />
-        <input type="text" placeholder="The agent to send messages to. Eg. 'testAgent' or 'otherAgent'" id="agent" /> <br>
+        <input type="text" placeholder="The agent to send messages to. Eg. 'testAgent' or 'otherAgent'" id="agent" />
+        <input type="text" placeholder="System Id" id="systemId"/>
+        <input type="text" placeholder="JVM Id" id="jvmId"/>
         <h3>Arguments: (blank fields will be omitted)</h3><br>
         <input type="text" placeholder="Argument 1" class="optionArgument"/><input type="text" placeholder="Value 1" class="optionArgumentVal"/><br>
         <input type="text" placeholder="Argument 2" class="optionArgument"/><input type="text" placeholder="Value 2" class="optionArgumentVal"/><br>