diff --git a/polemarch/main/templates/gui/gui.html b/polemarch/main/templates/gui/gui.html index 72b08f70..c776e959 100644 --- a/polemarch/main/templates/gui/gui.html +++ b/polemarch/main/templates/gui/gui.html @@ -2601,7 +2601,7 @@

<% if(jsonEditor.options[optionsblock] && jsonEditor.options[optionsblock][name]){ thisOpt = jsonEditor.options[optionsblock][name]; %>
-
- <% if(thisOpt.type == 'select' ){ %> - - <% } else if(thisOpt.type == 'password' ){ %> - - <% } else if(thisOpt.type == 'boolean' ){ %> -
-
-
-
Boolean value
-
- <% } else if(thisOpt.type == 'textarea' ){ %> +
+ + <% if(thisOpt.type == 'textfile' ){ %> + + + <% if(!thisOpt.required){ %> + + + + <% } %> + + + + + +
<% } else { %> - - <% } %> + <% if(thisOpt.type == 'select' ){ %> + + <% } else if(thisOpt.type == 'password' ){ %> + + <% } else if(thisOpt.type == 'boolean' ){ %> +
+
+
+
Boolean value
+
+ <% } else if(thisOpt.type == 'textarea' ){ %> + + <% } else { %> + + <% } %> - <% if(!thisOpt.required){ %> - - - - <% } %> + <% if(!thisOpt.required){ %> + + + + <% } %> + <% } %>
<% if(thisOpt.help){ %> -
+
@@ -2756,7 +2782,7 @@

-
+
diff --git a/polemarch/main/templates/menu.html b/polemarch/main/templates/menu.html index a926127a..81bc7fa5 100644 --- a/polemarch/main/templates/menu.html +++ b/polemarch/main/templates/menu.html @@ -3,8 +3,7 @@ {% load rest_framework %} {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} - {% if user.is_authenticated %} -
  • Help
  • + {% if user.is_authenticated %}
  • {% trans 'API' %}
  • {% endif %} diff --git a/polemarch/static/css/gui.css b/polemarch/static/css/gui.css index 617dc885..ca841715 100644 --- a/polemarch/static/css/gui.css +++ b/polemarch/static/css/gui.css @@ -426,4 +426,19 @@ table{ .popover{ max-width: 272px; } +} + +.textfile{ + position: relative; +} + +.textfile .input-file{ + position: absolute; + top: 0px; + left: 0px; + width: 100%; + height: 100%; + z-index: 1; + opacity: 0; + cursor: pointer; } \ No newline at end of file diff --git a/polemarch/static/js/jsonEditor.js b/polemarch/static/js/jsonEditor.js index 97c585cf..9569947a 100644 --- a/polemarch/static/js/jsonEditor.js +++ b/polemarch/static/js/jsonEditor.js @@ -46,7 +46,7 @@ jsonEditor.options['item']['ansible_ssh_pass'] = { } jsonEditor.options['item']['ansible_ssh_private_key_file'] = { - type:'textarea', + type:'textfile', help:'Inventory Parameter - ansible_ssh_private_key_file', helpcontent:'Private key file used by ssh. Useful if using multiple keys and you don’t want to use SSH agent.' } @@ -568,3 +568,25 @@ jsonEditor.jsonEditorAddVar = function(optionsblock) $("#jsonEditorVarList").append(spajs.just.render('jsonEditorLine', {name:name, value:value, optionsblock:optionsblock})) } +jsonEditor.loadFile = function(event, element) +{ + console.log("jsonEditor.loadFile", event.target.files) + for(var i=0; i 1024*1024*1) + { + $.notify("File too large", "error"); + console.log("File too large " + event.target.files[i].size) + continue; + } + + var reader = new FileReader(); + reader.onload = function(e) + { + $(element).val(e.target.result) + } + + reader.readAsText(event.target.files[i]); + return; + } +} \ No newline at end of file diff --git a/polemarch/static/js/pmTasks.js b/polemarch/static/js/pmTasks.js index 3a8f5bae..837e8448 100644 --- a/polemarch/static/js/pmTasks.js +++ b/polemarch/static/js/pmTasks.js @@ -43,3 +43,109 @@ pmTasks.execute = function(project_id, inventory, playbook) return def.promise(); } + + + +/** + * Обновляет поле модел this.model.itemslist и ложит туда список пользователей + * Обновляет поле модел this.model.items и ложит туда список инфу о пользователях по их id + */ +pmTasks.loadItems = function(limit, offset) +{ + if(!limit) + { + limit = 30; + } + + if(!offset) + { + offset = 0; + } + + var thisObj = this; + return jQuery.ajax({ + url: "/api/v1/"+this.model.name+"/", + type: "GET", + contentType:'application/json', + data: "limit="+encodeURIComponent(limit)+"&offset="+encodeURIComponent(offset), + beforeSend: function(xhr, settings) { + if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { + // Only send the token to relative URLs i.e. locally. + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); + } + }, + success: function(data) + { + //console.log("update Items", data) + thisObj.model.itemslist = data + thisObj.model.itemslist.limit = limit + thisObj.model.itemslist.offset = offset + + + for(var i in data.results) + { + data.results[i].id = data.results[i].playbook + var val = data.results[i] + thisObj.model.items.justWatch(val.id); + thisObj.model.items[val.id] = mergeDeep(thisObj.model.items[val.id], val) + } + }, + error:function(e) + { + console.warn(e) + polemarch.showErrors(e) + } + }); +} + +pmTasks.sendSearchQuery = function(query, limit, offset) +{ + if(!limit) + { + limit = 999; + } + + if(!offset) + { + offset = 0; + } + + var q = []; + for(var i in query) + { + q.push(encodeURIComponent(i)+"="+encodeURIComponent(query[i])) + } + + var thisObj = this; + return jQuery.ajax({ + url: "/api/v1/"+this.model.name+"/?"+q.join('&'), + type: "GET", + contentType:'application/json', + data: "limit="+encodeURIComponent(limit)+"&offset="+encodeURIComponent(offset), + beforeSend: function(xhr, settings) { + if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { + // Only send the token to relative URLs i.e. locally. + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); + } + }, + success: function(data) + { + //console.log("update Items", data) + thisObj.model.itemslist = data + + for(var i in data.results) + { + data.results[i].id = data.results[i].playbook + + var val = data.results[i] + thisObj.model.items[val.id] = val + } + }, + error:function(e) + { + console.warn(e) + polemarch.showErrors(e) + } + }); +} + \ No newline at end of file