Commit 9b3ce1a9cd8aba5c8a8672e4403060f63eff6f6a

Authored by Alexis Koralewski
1 parent 31a7d215
Exists in dev

UI changes on agent_detail view

src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html
@@ -28,13 +28,20 @@ @@ -28,13 +28,20 @@
28 color : red; 28 color : red;
29 } 29 }
30 .table{ 30 .table{
31 - width:auto; 31 + //max-width:90vw;
  32 + table-layout: fixed;
32 } 33 }
33 th{ 34 th{
34 max-width: 15vw; 35 max-width: 15vw;
35 vertical-align:top; 36 vertical-align:top;
36 text-align: center; 37 text-align: center;
37 } 38 }
  39 + td{
  40 + overflow:hidden;
  41 + }
  42 + #td_result{
  43 + max-width:20vw;
  44 + }
38 .theader{ 45 .theader{
39 text-align: center; 46 text-align: center;
40 min-width:7vw; 47 min-width:7vw;
@@ -55,7 +62,7 @@ @@ -55,7 +62,7 @@
55 } 62 }
56 </style> 63 </style>
57 <div> 64 <div>
58 - <h1> {{ agent_name }} </h1><br> 65 + <h1 id="agent_title"> {{ agent_name }} </h1><br>
59 {% if managed_by %} 66 {% if managed_by %}
60 <p> This agent is managed by <a href="{% url 'agent_detail' managed_by %}">{{ managed_by }} </a></p> 67 <p> This agent is managed by <a href="{% url 'agent_detail' managed_by %}">{{ managed_by }} </a></p>
61 {% endif %} 68 {% endif %}
@@ -180,10 +187,10 @@ @@ -180,10 +187,10 @@
180 <th class="theader align-top">Sender</th> 187 <th class="theader align-top">Sender</th>
181 <th class="theader align-top">Recipient</th> 188 <th class="theader align-top">Recipient</th>
182 <th class="theader align-top">Status </th> 189 <th class="theader align-top">Status </th>
183 - <th class="theader align-top">Deposit<br> (UTC)</th>  
184 - <th class="theader align-top">Read<br> (UTC)</th>  
185 <th class="theader align-top small-cln">Validity<br> (s)</th> 190 <th class="theader align-top small-cln">Validity<br> (s)</th>
186 <th class="theader align-top small-cln">Timeout<br> (s)</th> 191 <th class="theader align-top small-cln">Timeout<br> (s)</th>
  192 + <th class="theader align-top">Deposit<br> (UTC)</th>
  193 + <th class="theader align-top">Read<br> (UTC)</th>
187 <th class="theader align-top">Exec start <br>(UTC)</th> 194 <th class="theader align-top">Exec start <br>(UTC)</th>
188 <th class="theader align-top">Exec end <br>(UTC)</th> 195 <th class="theader align-top">Exec end <br>(UTC)</th>
189 <th class="theader align-top small-cln">Exec time <br>(s)</th> 196 <th class="theader align-top small-cln">Exec time <br>(s)</th>
@@ -199,15 +206,15 @@ @@ -199,15 +206,15 @@
199 <td v-if="command.sender.includes('@') || command.sender == 'System'">[[ command.sender]]</td> 206 <td v-if="command.sender.includes('@') || command.sender == 'System'">[[ command.sender]]</td>
200 <td v-else> <a v-bind:href="`/dashboard/agent_detail/${command.sender}`">[[ command.sender]]</a></td> 207 <td v-else> <a v-bind:href="`/dashboard/agent_detail/${command.sender}`">[[ command.sender]]</a></td>
201 <td> <a v-bind:href="`/dashboard/agent_detail/${command.recipient}`">[[ command.recipient ]]</a></td> 208 <td> <a v-bind:href="`/dashboard/agent_detail/${command.recipient}`">[[ command.recipient ]]</a></td>
202 - <td v-bind:class="['CMD_EXECUTED','CMD_PENDING','CMD_RUNNING'].includes(command.state) ? '' : 'red'"> [[ command.state ]] </td>  
203 - <td> [[ command.s_deposit_time]] </td>  
204 - <td> [[ command.r_read_time]]</td> 209 + <td v-bind:class="['CMD_EXECUTED','CMD_PENDING','CMD_RUNNING'].includes(command.state) ? '' : 'red'"> <b>[[ command.state ]]</b> </td>
205 <td> [[ command.validity_duration]] </td> 210 <td> [[ command.validity_duration]] </td>
206 <td> [[ command.exec_timeout]] </td> 211 <td> [[ command.exec_timeout]] </td>
  212 + <td> [[ command.s_deposit_time]] </td>
  213 + <td> [[ command.r_read_time]]</td>
207 <td> [[ command.r_start_time]]</td> 214 <td> [[ command.r_start_time]]</td>
208 <td> [[ command.r_end_time]]</td> 215 <td> [[ command.r_end_time]]</td>
209 <td> [[ command.exec_time]]</td> 216 <td> [[ command.exec_time]]</td>
210 - <td> [[ command.result ]] </td> 217 + <td id="td_result"> [[ command.result ]] </td>
211 </tr> 218 </tr>
212 </tbody> 219 </tbody>
213 </table> 220 </table>
@@ -317,9 +324,12 @@ @@ -317,9 +324,12 @@
317 324
318 325
319 $("#additional_fields").empty(); 326 $("#additional_fields").empty();
320 - $.get('{% url 'agent_detail' agent_name %}', {'cmd':cmd},function(data){  
321 - if (data != null && typeof data != "String"){  
322 - for(var arg of data){ 327 + $.get('{% url 'agent_detail' agent_name %}', {'cmd':cmd},function(data,cmd){
  328 + let cmd_name = $("#cmd_name").find(":selected").val();
  329 + let cmd_with_choices = data.cmd_with_choices;
  330 + let cmd_with_args = data.specific_cmd_with_args;
  331 + if (cmd_with_args != null && typeof cmd_with_args != "String"){
  332 + for(var arg of cmd_with_args){
323 var arg_name = arg[0]; 333 var arg_name = arg[0];
324 if (arg_name == "<"){ 334 if (arg_name == "<"){
325 return null; 335 return null;
@@ -341,12 +351,23 @@ @@ -341,12 +351,23 @@
341 else{ 351 else{
342 $("#send_cmd_btn").show() 352 $("#send_cmd_btn").show()
343 $("<label></label>").text(arg_name).appendTo("#additional_fields"); 353 $("<label></label>").text(arg_name).appendTo("#additional_fields");
  354 + if (cmd_with_choices.includes(cmd_name)){
  355 + var sel = $("<select>").attr("name", arg_name).appendTo("#additional_fields");
  356 + console.log(arg[1][0])
  357 + var values = arg[1][0].split(",")
  358 + $(values).each(function(){
  359 + console.log(this)
  360 + sel.append($("<option>").attr("value",this).text(this));
  361 + });
  362 + }
  363 + else{
344 364
345 - $("<input type='text' value='' />")  
346 - .attr("id", arg_name)  
347 - .attr("name", arg_name)  
348 - .attr("type",arg_type)  
349 - .appendTo("#additional_fields"); 365 + $("<input type='text' value='' />")
  366 + .attr("id", arg_name)
  367 + .attr("name", arg_name)
  368 + .attr("type",arg_type)
  369 + .appendTo("#additional_fields");
  370 + }
350 } 371 }
351 } 372 }
352 } 373 }
@@ -369,7 +390,8 @@ @@ -369,7 +390,8 @@
369 var cmdform_exiting = $("#cmdform_exiting") 390 var cmdform_exiting = $("#cmdform_exiting")
370 if (status == "EXITING"){ 391 if (status == "EXITING"){
371 if (cmdform.is(":visible")){ 392 if (cmdform.is(":visible")){
372 - cmdform_exiting.show(); 393 + //cmdform_exiting.show();
  394 + $("#cmdform_title").hide();
373 cmdform.hide(); 395 cmdform.hide();
374 } 396 }
375 } 397 }
@@ -384,7 +406,6 @@ @@ -384,7 +406,6 @@
384 $("#cmd_unimplemented_message").hide() 406 $("#cmd_unimplemented_message").hide()
385 let agent_general_commands = data.agent_general_commands; 407 let agent_general_commands = data.agent_general_commands;
386 let specific_cmd_with_args = data.specific_cmd_with_args; 408 let specific_cmd_with_args = data.specific_cmd_with_args;
387 - $("#cmdform_running").empty();  
388 var select = $("<select>").attr('name','cmd_name').attr('id','cmd_name').appendTo("#cmdform_running"); 409 var select = $("<select>").attr('name','cmd_name').attr('id','cmd_name').appendTo("#cmdform_running");
389 for (cmd of agent_general_commands){ 410 for (cmd of agent_general_commands){
390 select.append($("<option>").attr('value',cmd).text(cmd)); 411 select.append($("<option>").attr('value',cmd).text(cmd));
@@ -397,8 +418,9 @@ @@ -397,8 +418,9 @@
397 //$("#cmdform_running").append("</select>"); 418 //$("#cmdform_running").append("</select>");
398 }); 419 });
399 } 420 }
400 - if (cmdform_exiting.is(":visible")){  
401 - cmdform_exiting.hide(); 421 + if ($("#cmdform_title").is(":visible")){
  422 + //cmdform_exiting.hide();
  423 + $("#cmdform_title").show();
402 cmdform.show(); 424 cmdform.show();
403 } 425 }
404 } 426 }
@@ -458,6 +480,13 @@ @@ -458,6 +480,13 @@
458 480
459 fetch("/api/agent_survey/{{agent_name}}?format=json").then(response => response.json()).then(function(data){ 481 fetch("/api/agent_survey/{{agent_name}}?format=json").then(response => response.json()).then(function(data){
460 app2.agent = data; 482 app2.agent = data;
  483 + if (data.status == "EXITING"){
  484 + $("#agent_title").text(data.name + " is not available").css("color","red")
  485 + }
  486 + else{
  487 + $("#agent_title").text(data.name + " is available").css("color","green")
  488 + }
  489 +
461 if (previous_status != data.status){ 490 if (previous_status != data.status){
462 display_form_cmd(data.status); 491 display_form_cmd(data.status);
463 previous_status = data.status; 492 previous_status = data.status;