Commit b86decc67243d83b116b412e849780f454424dd4
1 parent
36f3ccd1
Exists in
dev
fix cmd_description not found in js
Showing
1 changed file
with
63 additions
and
57 deletions
Show diff stats
src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html
... | ... | @@ -356,71 +356,77 @@ |
356 | 356 | let cmd_name = $("#cmd_name").find(":selected").val(); |
357 | 357 | let cmd_with_choices = data.cmd_with_choices; |
358 | 358 | let cmd_with_args = data.specific_cmd_with_args; |
359 | - if (cmd_name == null){ | |
360 | - return; | |
361 | - } | |
359 | + if (cmd_name == null){ | |
360 | + return; | |
361 | + } | |
362 | + if (data.cmds_description[cmd_name] != null){ | |
362 | 363 | let cmd_description = data.cmds_description[cmd_name] |
363 | - if (cmd_with_args != null && typeof cmd_with_args != "String"){ | |
364 | - for(var arg of cmd_with_args){ | |
365 | - var arg_name = arg[0]; | |
366 | - if (arg_name == "<"){ | |
367 | - return null; | |
368 | - } | |
369 | - var arg_type = arg[1]; | |
370 | - if (arg_type == "str"){ | |
371 | - var arg_type = "text"; | |
372 | - } | |
373 | - else if(arg_type == "int"){ | |
374 | - var arg_type = "number"; | |
375 | - } | |
376 | - if (arg_name == "U"){ | |
377 | - $("<p></p>").text("This command isn't implemented").css("display","inline").css("color","red").appendTo("#additional_fields"); | |
378 | - $("#send_cmd_btn").hide() | |
379 | - }else if (arg_name == "I"){ | |
380 | - $("<p></p>").text("This command is badly nammed. A command must start with \"do/get/set\"").css("color","red").css("display","inline").appendTo("#additional_fields"); | |
381 | - $("#send_cmd_btn").hide() | |
364 | + | |
365 | + } | |
366 | + else{ | |
367 | + let cmd_description = ""; | |
368 | + } | |
369 | + if (cmd_with_args != null && typeof cmd_with_args != "String"){ | |
370 | + for(var arg of cmd_with_args){ | |
371 | + var arg_name = arg[0]; | |
372 | + if (arg_name == "<"){ | |
373 | + return null; | |
374 | + } | |
375 | + var arg_type = arg[1]; | |
376 | + if (arg_type == "str"){ | |
377 | + var arg_type = "text"; | |
378 | + } | |
379 | + else if(arg_type == "int"){ | |
380 | + var arg_type = "number"; | |
381 | + } | |
382 | + if (arg_name == "U"){ | |
383 | + $("<p></p>").text("This command isn't implemented").css("display","inline").css("color","red").appendTo("#additional_fields"); | |
384 | + $("#send_cmd_btn").hide() | |
385 | + }else if (arg_name == "I"){ | |
386 | + $("<p></p>").text("This command is badly nammed. A command must start with \"do/get/set\"").css("color","red").css("display","inline").appendTo("#additional_fields"); | |
387 | + $("#send_cmd_btn").hide() | |
388 | + } | |
389 | + else{ | |
390 | + $("#send_cmd_btn").show() | |
391 | + $("<label></label>").text(arg_name).appendTo("#additional_fields"); | |
392 | + if (cmd_with_choices.includes(cmd_name)){ | |
393 | + var sel = $("<select>").attr("name", arg_name).appendTo("#additional_fields"); | |
394 | + console.log(arg[1][0]) | |
395 | + var values = arg[1][0].split(",") | |
396 | + $(values).each(function(){ | |
397 | + console.log(this) | |
398 | + sel.append($("<option>").attr("value",this).text(this)); | |
399 | + }); | |
382 | 400 | } |
383 | 401 | else{ |
384 | - $("#send_cmd_btn").show() | |
385 | - $("<label></label>").text(arg_name).appendTo("#additional_fields"); | |
386 | - if (cmd_with_choices.includes(cmd_name)){ | |
387 | - var sel = $("<select>").attr("name", arg_name).appendTo("#additional_fields"); | |
388 | - console.log(arg[1][0]) | |
389 | - var values = arg[1][0].split(",") | |
390 | - $(values).each(function(){ | |
391 | - console.log(this) | |
392 | - sel.append($("<option>").attr("value",this).text(this)); | |
393 | - }); | |
394 | - } | |
395 | - else{ | |
396 | 402 | |
397 | - $("<input type='text' value='' />") | |
398 | - .attr("id", arg_name) | |
399 | - .attr("name", arg_name) | |
400 | - .attr("type",arg_type) | |
401 | - .appendTo("#additional_fields"); | |
402 | - } | |
403 | + $("<input type='text' value='' />") | |
404 | + .attr("id", arg_name) | |
405 | + .attr("name", arg_name) | |
406 | + .attr("type",arg_type) | |
407 | + .appendTo("#additional_fields"); | |
403 | 408 | } |
404 | 409 | } |
405 | 410 | } |
406 | - else{ | |
407 | - if (! cmd.startsWith("get")){ | |
408 | - $("#send_cmd_btn").show() | |
409 | - $("<label></label>").text("parameter(s)").appendTo("#additional_fields"); | |
410 | - $("<input type='text' value='' />") | |
411 | - .attr("id", "arg_name") | |
412 | - .attr("name", "parameters") | |
413 | - .attr("type","text") | |
414 | - .appendTo("#additional_fields"); | |
415 | - } | |
416 | - | |
417 | - } | |
418 | - if (cmd_description.length == 0){ | |
419 | - cmd_description = "No description" | |
411 | + } | |
412 | + else{ | |
413 | + if (! cmd.startsWith("get")){ | |
414 | + $("#send_cmd_btn").show() | |
415 | + $("<label></label>").text("parameter(s)").appendTo("#additional_fields"); | |
416 | + $("<input type='text' value='' />") | |
417 | + .attr("id", "arg_name") | |
418 | + .attr("name", "parameters") | |
419 | + .attr("type","text") | |
420 | + .appendTo("#additional_fields"); | |
420 | 421 | } |
421 | - $('<div style="display:inline;">').prop("title",cmd_description).append('<i class="fa fa-question-circle-o" aria-hidden="true"></i>').appendTo("#additional_fields"); | |
422 | - $('.fa-question-circle-o').tooltip(); | |
423 | - }); | |
422 | + | |
423 | + } | |
424 | + if (cmd_description.length == 0){ | |
425 | + cmd_description = "No description" | |
426 | + } | |
427 | + $('<div style="display:inline;">').prop("title",cmd_description).append('<i class="fa fa-question-circle-o" aria-hidden="true"></i>').appendTo("#additional_fields"); | |
428 | + $('.fa-question-circle-o').tooltip(); | |
429 | + }); | |
424 | 430 | } |
425 | 431 | function display_form_cmd(status){ |
426 | 432 | var cmdform = $("#cmdform") | ... | ... |