Commit 319843baf83005c8a70f05e10d5d4ea6da21f32e

Authored by Etienne Pallier
2 parents 6a60b61d 68880592
Exists in dev

Merge branch 'dev' of https://gitlab.irap.omp.eu/epallier/pyros into dev

CHANGELOG
1 1 25-11-2022 (AKo): v0.6.13.0
2 2 - Add is_active field for agents in tnc obsconfig
  3 + - Add new colors in agents_cmds and agent_detail for cmd status
  4 + - Add tooltip on agent cmd form to display cmd description
3 5  
4 6 24-11-2022 (EP): v0.6.12.0
5 7 - Added tooltip to Agent specific commands
... ...
src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html
... ... @@ -27,6 +27,12 @@
27 27 .red{
28 28 color : red;
29 29 }
  30 + .orange{
  31 + color : orange;
  32 + }
  33 + .violet{
  34 + color : violet;
  35 + }
30 36 .table{
31 37 //max-width:90vw;
32 38 table-layout: fixed;
... ... @@ -38,6 +44,7 @@
38 44 }
39 45 td{
40 46 overflow:hidden;
  47 + word-wrap: break-word;
41 48 }
42 49 #td_result{
43 50 max-width:20vw;
... ... @@ -206,7 +213,7 @@
206 213 <td v-if="command.sender.includes('@') || command.sender == 'System'">[[ command.sender]]</td>
207 214 <td v-else> <a v-bind:href="`/dashboard/agent_detail/${command.sender}`">[[ command.sender]]</a></td>
208 215 <td> <a v-bind:href="`/dashboard/agent_detail/${command.recipient}`">[[ command.recipient ]]</a></td>
209   - <td v-bind:class="['CMD_EXECUTED','CMD_PENDING','CMD_RUNNING'].includes(command.state) ? '' : 'red'"> <b>[[ command.state ]]</b> </td>
  216 + <td v-bind:class="[command.state == 'CMD_PENDING' ? 'orange' : '',command.state == 'CMD_RUNNING' ? 'red' : '',['CMD_EXECUTED','CMD_PENDING','CMD_RUNNING'].includes(command.state) ? '' : 'violet']"> <b>[[ command.state ]]</b> </td>
210 217 <td> [[ command.validity_duration]] </td>
211 218 <td> [[ command.exec_timeout]] </td>
212 219 <td> [[ command.s_deposit_time]] </td>
... ... @@ -328,6 +335,8 @@
328 335 let cmd_name = $("#cmd_name").find(":selected").val();
329 336 let cmd_with_choices = data.cmd_with_choices;
330 337 let cmd_with_args = data.specific_cmd_with_args;
  338 + let cmd_description = data.cmds_description[cmd_name]
  339 +
331 340 if (cmd_with_args != null && typeof cmd_with_args != "String"){
332 341 for(var arg of cmd_with_args){
333 342 var arg_name = arg[0];
... ... @@ -383,15 +392,21 @@
383 392 }
384 393  
385 394 }
  395 + if (cmd_description.length == 0){
  396 + cmd_description = "No description"
  397 + }
  398 + $('<div style="display:inline;">').prop("title",cmd_description).append('<i class="fa fa-question-circle-o" aria-hidden="true"></i>').appendTo("#additional_fields");
  399 + $('.fa-question-circle-o').tooltip();
386 400 });
387 401 }
388 402 function display_form_cmd(status){
389 403 var cmdform = $("#cmdform")
390 404 var cmdform_exiting = $("#cmdform_exiting")
  405 + var cmdform_title = $("#cmdform_title")
391 406 if (status == "EXITING"){
392 407 if (cmdform.is(":visible")){
393 408 //cmdform_exiting.show();
394   - $("#cmdform_title").hide();
  409 + cmdform_title.hide();
395 410 cmdform.hide();
396 411 }
397 412 }
... ... @@ -408,19 +423,19 @@
408 423 let specific_cmd_with_args = data.specific_cmd_with_args;
409 424 var select = $("<select>").attr('name','cmd_name').attr('id','cmd_name').appendTo("#cmdform_running");
410 425 for (cmd of agent_general_commands){
411   - select.append($("<option>").attr('value',cmd).text(cmd));
  426 + select.append($("<option>").attr('value',cmd).title(cmd_description).text(cmd));
412 427 }
413 428 for (cmd in specific_cmd_with_args){
414   - select.append($("<option>").attr('value',cmd).attr(cmd));
  429 + select.append($("<option>").attr('value',cmd).title(cmd_description).attr(cmd));
415 430 }
416 431  
417 432 }
418 433 //$("#cmdform_running").append("</select>");
419 434 });
420 435 }
421   - if ($("#cmdform_title").is(":visible")){
  436 + if (! $("#cmdform_exiting").is(":visible")){
422 437 //cmdform_exiting.hide();
423   - $("#cmdform_title").show();
  438 + cmdform_title.show();
424 439 cmdform.show();
425 440 }
426 441 }
... ...
src/core/pyros_django/dashboard/templates/dashboard/agents_commands.html
... ... @@ -20,6 +20,19 @@
20 20 #overflowtable{
21 21 overflow-x: scroll;
22 22 }
  23 + td{
  24 + overflow:hidden;
  25 + word-wrap: break-word;
  26 + }
  27 + .orange{
  28 + color : orange;
  29 + }
  30 + .violet{
  31 + color : violet;
  32 + }
  33 + .red{
  34 + color: red;
  35 + }
23 36 </style>
24 37  
25 38 <div>
... ... @@ -80,7 +93,11 @@
80 93 {% endif %}
81 94 <td> <a href={% url 'agent_detail' command.recipient %}>{{ command.recipient }}</a></td>
82 95 {% if command.state == "CMD_PENDING" %}
83   - <td style="color:orange;"> <b>{{ command.state }}</b> </td>
  96 + <td class="orange"> <b>{{ command.state }}</b> </td>
  97 + {% elif command.state == "CMD_RUNNING" %}
  98 + <td class="red"> <b>{{ command.state }}</b> </td>
  99 + {% elif command.is_finished_with_error %}
  100 + <td class="violet"> <b>{{ command.state }}</b> </td>
84 101 {% else %}
85 102 <td> {{ command.state }} </td>
86 103 {% endif %}
... ...
src/core/pyros_django/dashboard/views.py
... ... @@ -230,6 +230,7 @@ def agent_detail(request, agent_name):
230 230 error_message = f"Cannot find agent logs. (Agent log path tried : {agent_log_path})"
231 231 specific_cmd_with_args = None
232 232 cmd_with_choices = []
  233 + cmds_description = {}
233 234 agent_general_commands = AgentCmd._AGENT_GENERAL_COMMANDS.copy()
234 235 if "get_all_cmds" in agent_general_commands:
235 236 agent_general_commands.remove("get_all_cmds")
... ... @@ -253,8 +254,11 @@ def agent_detail(request, agent_name):
253 254 specific_cmd_with_args = {}
254 255 for specific_cmd in agent_specific_cmd_to_list:
255 256 if "(" in specific_cmd:
  257 + description = specific_cmd.split(",")[1]
  258 + specific_cmd = specific_cmd.split(",")[0]
256 259 cmd = specific_cmd.split("(")[0]
257 260 specific_cmd_with_args[cmd] = []
  261 + cmds_description[cmd] = description
258 262 # get text between paretheses
259 263 args = re.findall(pattern="\(([^)]+)\)",string=specific_cmd)
260 264 for arg in args:
... ... @@ -276,11 +280,11 @@ def agent_detail(request, agent_name):
276 280 if request.GET.get("cmd"):
277 281 if request.GET.get("cmd") != "all":
278 282 if request.GET.get("cmd") in list(specific_cmd_with_args.keys()):
279   - return JsonResponse({"specific_cmd_with_args":specific_cmd_with_args.get(request.GET.get("cmd")),"cmd_with_choices":cmd_with_choices},safe=False)
  283 + return JsonResponse({"specific_cmd_with_args":specific_cmd_with_args.get(request.GET.get("cmd")),"cmd_with_choices":cmd_with_choices,"cmds_description":cmds_description},safe=False)
280 284 else:
281 285 return JsonResponse(None,safe=False)
282 286 else:
283   - return JsonResponse({"agent_general_commands":agent_general_commands,"specific_cmd_with_args":specific_cmd_with_args,"unimplemented_command":unimplemented_command,"cmd_with_choices":cmd_with_choices},safe=False)
  287 + return JsonResponse({"agent_general_commands":agent_general_commands,"specific_cmd_with_args":specific_cmd_with_args,"unimplemented_command":unimplemented_command,"cmd_with_choices":cmd_with_choices,"cmds_description":cmds_description},safe=False)
284 288 if request.GET.get("cmd"):
285 289 return JsonResponse(None,safe=False)
286 290 commands_sent_by_agent = AgentCmd.get_commands_sent_by_agent(agent_name)
... ...