From 0f2d03218ecb111dbf5686b9623935e91fe69862 Mon Sep 17 00:00:00 2001 From: cepreu Date: Wed, 27 Sep 2017 09:57:55 +1000 Subject: [PATCH 01/31] using variable in static path in web.ini --- polemarch/web.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polemarch/web.ini b/polemarch/web.ini index f189c6df..ed567b04 100755 --- a/polemarch/web.ini +++ b/polemarch/web.ini @@ -22,7 +22,7 @@ enable-threads = true # path to static content static-map = /static=%(program_name)/static -static-map = /static=/opt/%(program_name)/lib/python2.7/site-packages/polemarch/static +static-map = /static=/opt/%(program_name)/lib/python2.7/site-packages/%(program_name)/static # PID-file for service pidfile = /var/run/%(program_name)/web.pid From e2ded09e05956f17fe1ef828dc789651b543adfa Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Wed, 27 Sep 2017 16:36:07 +1000 Subject: [PATCH 02/31] bug fix for select2 autocomplte in json params editor --- polemarch/static/templates/jsonEditor.html | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/polemarch/static/templates/jsonEditor.html b/polemarch/static/templates/jsonEditor.html index 5cf05728..64f28fb6 100644 --- a/polemarch/static/templates/jsonEditor.html +++ b/polemarch/static/templates/jsonEditor.html @@ -167,23 +167,25 @@
<% if(opt.select2){ %> <~ jsonEditor.model.isLoaded_cli_reference> - + + <% for(var i in jsonEditor.options[optionsblock]){ %> + <% if($.inArray(i, opt.excluded_options) == -1){ %> + + <% } %> <% } %> - <% } %> - - <=js $("#new_json_name<%- opt.prefix%>").select2() js=> + + <=js $("#new_json_name<%- opt.prefix%>").select2() js=> + <% } %> <~> <% }else{ %> From 73fc3e6b2590ae7fde75b0a0684422ec6594f3d4 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Wed, 27 Sep 2017 16:36:13 +1000 Subject: [PATCH 03/31] bug fix for select2 autocomplte in json params editor --- polemarch/static/js/jsonEditor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/polemarch/static/js/jsonEditor.js b/polemarch/static/js/jsonEditor.js index 38c6f08f..cd907ddf 100644 --- a/polemarch/static/js/jsonEditor.js +++ b/polemarch/static/js/jsonEditor.js @@ -5,6 +5,7 @@ function jsonEditor(){ jsonEditor.model = {} jsonEditor.model.isLoaded_cli_reference = false; +jsonEditor.model.isLoading_cli_reference = false; jsonEditor.options = {}; @@ -381,22 +382,23 @@ jsonEditor.initAutoComplete = function(optionsblock, prefix) } jsonEditor.initForm = function(optionsblock, prefix) -{ +{ if(!prefix) { prefix = "prefix" } prefix = prefix.replace(/[^A-z0-9]/g, "_").replace(/[\[\]]/gi, "_") + console.log(optionsblock, jsonEditor.options[optionsblock]) if(jsonEditor.options[optionsblock]) { jsonEditor.initAutoComplete(optionsblock, prefix) return; } - if(!jsonEditor.model.isLoaded_cli_reference) + if(!jsonEditor.model.isLoaded_cli_reference && !jsonEditor.model.isLoading_cli_reference) { - jsonEditor.model.isLoaded_cli_reference = true; + jsonEditor.model.isLoading_cli_reference = true; return spajs.ajax.Call({ url: "/api/v1/ansible/cli_reference/", type: "GET", @@ -406,6 +408,7 @@ jsonEditor.initForm = function(optionsblock, prefix) { Object.assign(jsonEditor.options, data) jsonEditor.initAutoComplete(optionsblock, prefix) + jsonEditor.model.isLoaded_cli_reference = true; } }); } From 91066bfeea9f481cdb6a1c4541c6e23324beb614 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Wed, 27 Sep 2017 17:18:22 +1000 Subject: [PATCH 04/31] bug fix for mugules args string --- polemarch/static/templates/pmAnsibleModule.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polemarch/static/templates/pmAnsibleModule.html b/polemarch/static/templates/pmAnsibleModule.html index 7e954bf7..b3ccce87 100644 --- a/polemarch/static/templates/pmAnsibleModule.html +++ b/polemarch/static/templates/pmAnsibleModule.html @@ -158,7 +158,7 @@

From a9bd36b30e5114675cfb1f2203427903067969d4 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Wed, 27 Sep 2017 17:20:37 +1000 Subject: [PATCH 05/31] update templates for modules autocomplte --- polemarch/static/js/pmAnsibleModule.js | 2 + polemarch/static/js/polemarch.js | 6 +- .../static/templates/pmModuleTemplates.html | 57 +++++-------------- 3 files changed, 16 insertions(+), 49 deletions(-) diff --git a/polemarch/static/js/pmAnsibleModule.js b/polemarch/static/js/pmAnsibleModule.js index 62cab783..02d44831 100644 --- a/polemarch/static/js/pmAnsibleModule.js +++ b/polemarch/static/js/pmAnsibleModule.js @@ -202,6 +202,7 @@ pmAnsibleModule.execute = function(project_id, inventory_id, group, module, data * Вернёт код для поля автокомплита модулей * @param {String} id * @returns HTML templte + * @private */ pmAnsibleModule.moduleAutocompleteFiled = function(opt) { @@ -272,6 +273,7 @@ pmAnsibleModule.moduleAutocompleteFiled = function(opt) * Вернёт код для поля ввода аргументов к запуску модуля * @param {String} id * @returns HTML templte + * @private */ pmAnsibleModule.argsAutocompleteFiled = function(opt) { diff --git a/polemarch/static/js/polemarch.js b/polemarch/static/js/polemarch.js index cb5fce5d..ecb36ad1 100644 --- a/polemarch/static/js/polemarch.js +++ b/polemarch/static/js/polemarch.js @@ -22,15 +22,11 @@ function getCookie(name) function loadTpl(name) { return jQuery.ajax({ - url: window.pmStaticPath+"/"+name+".html", + url: window.pmStaticPath+""+name+".html", type: "GET", success: function(res) { $("body").append(res) - }, - error:function(res) - { - $.notify("Error in template loaging", "error"); } }) } diff --git a/polemarch/static/templates/pmModuleTemplates.html b/polemarch/static/templates/pmModuleTemplates.html index 4e505c8d..69710fcf 100644 --- a/polemarch/static/templates/pmModuleTemplates.html +++ b/polemarch/static/templates/pmModuleTemplates.html @@ -84,28 +84,13 @@

<~>

-
- <%= pmAnsibleModule.moduleAutocompleteFiled({id:'module-autocomplete', value:pmModuleTemplates.model.items[item_id].data.module}) %> -
-
-
-
- - - -
-
- args (string) – which args must be passed to module. Just raw string with arguments. You can specify here contains of args option. For example ls -la for shell module. -
-
-
+ <%= + pmAnsibleModule.moduleFileds( + { + module:{id:'module-autocomplete', value:pmModuleTemplates.model.items[item_id].data.module }, + args:{id:'module-args-string', value:pmModuleTemplates.model.items[item_id].data.args } + }) + %>
@@ -192,28 +177,12 @@

<~> -
- <%= pmAnsibleModule.moduleAutocompleteFiled({id:'module-autocomplete'}) %> -
-
-
-
- - - -
-
- args (string) – which args must be passed to module. Just raw string with arguments. You can specify here contains of args option. For example ls -la for shell module. -
-
-
+ <%= + pmAnsibleModule.moduleFileds( + { + module:{id:'module-autocomplete'}, args:{id:'module-args-string'} + }) + %> From 4ba894b5bc4706cf328df279b92f5a4515680c7e Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Thu, 28 Sep 2017 10:39:22 +1000 Subject: [PATCH 06/31] Postinstall script fix --- deb.mk | 4 ++-- rpm.mk | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deb.mk b/deb.mk index 638bffe4..8a93549a 100644 --- a/deb.mk +++ b/deb.mk @@ -106,10 +106,10 @@ chown -R $(USER):$(USER) /var/log/$(NAME) chown -R $(USER):$(USER) /var/run/$(NAME) chown -R $(USER):$(USER) /var/lock/$(NAME) # making migration and activate services -sudo -u $(USER) /opt/$(NAME)/bin/polemarchctl migrate > /dev/null 2>&1 +sudo -H -u $(USER) /opt/$(NAME)/bin/polemarchctl migrate +systemctl daemon-reload systemctl enable polemarchweb.service systemctl enable polemarchworker.service -systemctl daemon-reload endef export DEBIAN_POSTINST diff --git a/rpm.mk b/rpm.mk index f7e28a2a..aa9a8353 100755 --- a/rpm.mk +++ b/rpm.mk @@ -91,10 +91,10 @@ install -m 755 initbin/%{shortname}worker.service $$RPM_BUILD_ROOT/etc/systemd/s install -m 755 initbin/%{shortname}.conf $$RPM_BUILD_ROOT/etc/tmpfiles.d/%{shortname}.conf %post -sudo -u %{name} /opt/%{name}/bin/%{shortname}ctl migrate > /dev/null 2>&1 -/usr/bin/systemctl enable %{shortname}web.service > /dev/null 2>&1 -/usr/bin/systemctl enable %{shortname}worker.service > /dev/null 2>&1 -/usr/bin/systemctl daemon-reload > /dev/null 2>&1 +sudo -H -u %{name} /opt/%{name}/bin/%{shortname}ctl migrate +/usr/bin/systemctl daemon-reload +/usr/bin/systemctl enable %{shortname}web.service +/usr/bin/systemctl enable %{shortname}worker.service %preun /usr/bin/systemctl disable %{shortname}web.service > /dev/null 2>&1 From 9499621b979220350626762223c82c4e8077ea6e Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Thu, 28 Sep 2017 12:22:12 +1000 Subject: [PATCH 07/31] Update gitpython version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c9a12dda..6d749a19 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ jsonfield==2.0.2 uWSGI==2.0.15 # Repo types -gitpython==2.1.5 +gitpython==2.1.6 # additional DB and cache connectors PyMySQL From fafde1034e6556a2e4bd9df1532586d95e15ffa3 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Fri, 29 Sep 2017 12:29:11 +1000 Subject: [PATCH 08/31] add responsive to select2 init options --- polemarch/static/js/pmAnsibleModule.js | 6 +++--- polemarch/static/js/pmGroups.js | 4 ++-- polemarch/static/js/pmInventories.js | 4 ++-- polemarch/static/js/pmModuleTemplates.js | 8 ++++---- polemarch/static/js/pmPeriodicTasks.js | 4 ++-- polemarch/static/js/pmProjects.js | 10 +++++----- polemarch/static/js/pmTasksTemplates.js | 8 ++++---- polemarch/static/templates/jsonEditor.html | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/polemarch/static/js/pmAnsibleModule.js b/polemarch/static/js/pmAnsibleModule.js index 02d44831..9089fd33 100644 --- a/polemarch/static/js/pmAnsibleModule.js +++ b/polemarch/static/js/pmAnsibleModule.js @@ -44,7 +44,7 @@ pmAnsibleModule.showInProject = function(holder, menuInfo, data) return $.when(pmProjects.loadItem(project_id), pmInventories.loadAllItems()).done(function() { $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_run_page', {item_id:project_id})) - $("#inventories-autocomplete").select2(); + $("#inventories-autocomplete").select2({ width: '100%' }); }).fail(function() { $.notify("", "error"); @@ -59,8 +59,8 @@ pmAnsibleModule.fastCommandWidget = function(holder) return $.when(pmProjects.loadAllItems(), pmInventories.loadAllItems()).done(function() { $(holder).insertTpl(spajs.just.render('fastcommand_widget', {})) - $("#projects-autocomplete").select2(); - $("#inventories-autocomplete").select2(); + $("#projects-autocomplete").select2({ width: '100%' }); + $("#inventories-autocomplete").select2({ width: '100%' }); }).fail(function() { diff --git a/polemarch/static/js/pmGroups.js b/polemarch/static/js/pmGroups.js index 041ac6e4..28224c43 100644 --- a/polemarch/static/js/pmGroups.js +++ b/polemarch/static/js/pmGroups.js @@ -375,7 +375,7 @@ pmGroups.showAddSubGroupsForm = function(item_id, holder) return $.when(pmGroups.loadAllItems()).done(function(){ $("#add_existing_item_to_group").remove() $(".content").appendTpl(spajs.just.render('add_existing_groups_to_group', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() @@ -390,7 +390,7 @@ pmGroups.showAddSubHostsForm = function(item_id, holder) return $.when(pmHosts.loadAllItems()).done(function(){ $("#add_existing_item_to_group").remove() $(".content").appendTpl(spajs.just.render('add_existing_hosts_to_group', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() diff --git a/polemarch/static/js/pmInventories.js b/polemarch/static/js/pmInventories.js index 7c9feb69..72488e5a 100644 --- a/polemarch/static/js/pmInventories.js +++ b/polemarch/static/js/pmInventories.js @@ -850,7 +850,7 @@ pmInventories.showAddSubGroupsForm = function(item_id, holder) return $.when(pmGroups.loadAllItems()).done(function(){ $("#add_existing_item_to_inventory").remove() $(".content").appendTpl(spajs.just.render('add_existing_groups_to_inventory', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() @@ -865,7 +865,7 @@ pmInventories.showAddSubHostsForm = function(item_id, holder) return $.when(pmHosts.loadAllItems()).done(function(){ $("#add_existing_item_to_inventory").remove() $(".content").appendTpl(spajs.just.render('add_existing_hosts_to_inventory', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() diff --git a/polemarch/static/js/pmModuleTemplates.js b/polemarch/static/js/pmModuleTemplates.js index 3a49c9c0..77f91965 100644 --- a/polemarch/static/js/pmModuleTemplates.js +++ b/polemarch/static/js/pmModuleTemplates.js @@ -45,8 +45,8 @@ pmModuleTemplates.showItem = function(holder, menuInfo, data) $.when(pmModuleTemplates.selectInventory(pmModuleTemplates.model.items[item_id].data.inventory)).always(function() { $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_module_page', {item_id:item_id})) - $("#inventories-autocomplete").select2(); - $("#projects-autocomplete").select2(); + $("#inventories-autocomplete").select2({ width: '100%' }); + $("#projects-autocomplete").select2({ width: '100%' }); def.resolve(); }); @@ -66,8 +66,8 @@ pmModuleTemplates.showNewItemPage = function(holder, menuInfo, data) { $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_new_module_page', {})) - $("#inventories-autocomplete").select2(); - $("#projects-autocomplete").select2(); + $("#inventories-autocomplete").select2({ width: '100%' }); + $("#projects-autocomplete").select2({ width: '100%' }); def.resolve(); }).fail(function() diff --git a/polemarch/static/js/pmPeriodicTasks.js b/polemarch/static/js/pmPeriodicTasks.js index b396df5b..8ad94ed9 100644 --- a/polemarch/static/js/pmPeriodicTasks.js +++ b/polemarch/static/js/pmPeriodicTasks.js @@ -273,7 +273,7 @@ pmPeriodicTasks.showNewItemPage = function(holder, menuInfo, data) thisObj.model.newitem = {type:'INTERVAL', kind:'PLAYBOOK'} $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_new_page', {project_id:project_id})) - $('#new_periodic-tasks_inventory').select2(); + $('#new_periodic-tasks_inventory').select2({ width: '100%' }); new autoComplete({ selector: '#new_periodic-tasks_playbook', @@ -324,7 +324,7 @@ pmPeriodicTasks.showItem = function(holder, menuInfo, data) $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_page', {item_id:item_id, project_id:project_id})) pmPeriodicTasks.selectInventory(pmPeriodicTasks.model.items[item_id].inventory) - $('#periodic-tasks_'+item_id+'_inventory').select2(); + $('#periodic-tasks_'+item_id+'_inventory').select2({ width: '100%' }); new autoComplete({ selector: '#periodic-tasks_'+item_id+'_playbook', diff --git a/polemarch/static/js/pmProjects.js b/polemarch/static/js/pmProjects.js index b3ddbe60..5923ceb6 100644 --- a/polemarch/static/js/pmProjects.js +++ b/polemarch/static/js/pmProjects.js @@ -55,7 +55,7 @@ pmProjects.openRunPlaybookPage = function(holder, menuInfo, data) { $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_run_playbook', {item_id:project_id, query:project_id})) - $("#inventories-autocomplete").select2(); + $("#inventories-autocomplete").select2({ width: '100%' }); new autoComplete({ selector: '#playbook-autocomplete', @@ -230,7 +230,7 @@ pmProjects.showAddSubInventoriesForm = function(item_id, holder) return $.when(pmInventories.loadAllItems()).done(function(){ $("#add_existing_item_to_project").remove() $(".content").appendTpl(spajs.just.render('add_existing_inventories_to_project', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() @@ -245,7 +245,7 @@ pmProjects.showAddSubInventoriesForm = function(item_id, holder) return $.when(pmInventories.loadAllItems()).done(function(){ $("#add_existing_item_to_project").remove() $(".content").appendTpl(spajs.just.render('add_existing_inventories_to_project', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() @@ -260,7 +260,7 @@ pmProjects.showAddSubGroupsForm = function(item_id, holder) return $.when(pmGroups.loadAllItems()).done(function(){ $("#add_existing_item_to_project").remove() $(".content").appendTpl(spajs.just.render('add_existing_groups_to_project', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() @@ -275,7 +275,7 @@ pmProjects.showAddSubHostsForm = function(item_id, holder) return $.when(pmHosts.loadAllItems()).done(function(){ $("#add_existing_item_to_project").remove() $(".content").appendTpl(spajs.just.render('add_existing_hosts_to_project', {item_id:item_id})) - $("#polemarch-model-items-select").select2(); + $("#polemarch-model-items-select").select2({ width: '100%' }); }).fail(function(){ }).promise() diff --git a/polemarch/static/js/pmTasksTemplates.js b/polemarch/static/js/pmTasksTemplates.js index 8af797b5..b10c0150 100644 --- a/polemarch/static/js/pmTasksTemplates.js +++ b/polemarch/static/js/pmTasksTemplates.js @@ -67,8 +67,8 @@ pmTasksTemplates.showItem = function(holder, menuInfo, data) thisObj.model.selectedProject == pmTasksTemplates.model.items[item_id].project $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_page', {item_id:item_id})) - $("#inventories-autocomplete").select2(); - //$("#projects-autocomplete").select2(); + $("#inventories-autocomplete").select2({ width: '100%' }); + //$("#projects-autocomplete").select2({ width: '100%' }); new autoComplete({ selector: '#playbook-autocomplete', @@ -130,8 +130,8 @@ pmTasksTemplates.showNewItemPage = function(holder, menuInfo, data) { $(holder).insertTpl(spajs.just.render(thisObj.model.name+'_new_page', {})) - $("#inventories-autocomplete").select2(); - //$("#projects-autocomplete").select2(); + $("#inventories-autocomplete").select2({ width: '100%' }); + //$("#projects-autocomplete").select2({ width: '100%' }); new autoComplete({ selector: '#playbook-autocomplete', diff --git a/polemarch/static/templates/jsonEditor.html b/polemarch/static/templates/jsonEditor.html index 64f28fb6..16d824f8 100644 --- a/polemarch/static/templates/jsonEditor.html +++ b/polemarch/static/templates/jsonEditor.html @@ -184,7 +184,7 @@ <% } %> <% } %> - <=js $("#new_json_name<%- opt.prefix%>").select2() js=> + <=js $("#new_json_name<%- opt.prefix%>").select2({ width: '100%' }) js=> <% } %> <~> <% }else{ %> From 5063d7685e66083f0fb5d26c0cf8337b14eb9c16 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Fri, 29 Sep 2017 15:10:31 +1000 Subject: [PATCH 09/31] ansible module autocomplte gui --- polemarch/main/templates/gui/gui.html | 4 +- .../moduleArgsEditor.js} | 75 ++++++--- polemarch/static/js/pmAnsibleModule.js | 151 +----------------- polemarch/static/js/pmModuleTemplates.js | 8 +- polemarch/static/js/pmPeriodicTasks.js | 6 +- .../static/templates/moduleArgsEditor.html | 44 +++++ .../static/templates/pmAnsibleModule.html | 46 +----- .../static/templates/pmModuleTemplates.html | 18 +-- 8 files changed, 113 insertions(+), 239 deletions(-) rename polemarch/static/{templates/pmAnsibleModule.js => js/moduleArgsEditor.js} (65%) create mode 100644 polemarch/static/templates/moduleArgsEditor.html diff --git a/polemarch/main/templates/gui/gui.html b/polemarch/main/templates/gui/gui.html index 1f852d14..21296dee 100644 --- a/polemarch/main/templates/gui/gui.html +++ b/polemarch/main/templates/gui/gui.html @@ -35,6 +35,7 @@ + {% endblock %} {% block script %} @@ -56,7 +57,8 @@ 'templates/pmHistory', 'templates/pmTasksTemplates', 'templates/pmModuleTemplates', - 'templates/pmAnsibleModule' + 'templates/pmAnsibleModule', + 'templates/moduleArgsEditor' ] // alert("New-") diff --git a/polemarch/static/templates/pmAnsibleModule.js b/polemarch/static/js/moduleArgsEditor.js similarity index 65% rename from polemarch/static/templates/pmAnsibleModule.js rename to polemarch/static/js/moduleArgsEditor.js index f1572d5c..403c20d1 100644 --- a/polemarch/static/templates/pmAnsibleModule.js +++ b/polemarch/static/js/moduleArgsEditor.js @@ -1,25 +1,45 @@ -/** - * Класс для запуска модулей Ansible. - * - */ + +var moduleArgsEditor = {} + +moduleArgsEditor.model = {} + + +moduleArgsEditor.loadAllModule = function() +{ + var def = new $.Deferred(); + var thisObj = this; + spajs.ajax.Call({ + url: "/api/v1/ansible/modules/", + type: "GET", + contentType:'application/json', + success: function(data) + { + thisObj.model.ansible_modules = data + def.resolve(); + }, + error:function(e) + { + console.warn(e) + polemarch.showErrors(e) + def.reject(); + } + }); + return def.promise(); +} /** * Вернёт код для поля автокомплита модулей * @param {String} id * @returns HTML templte + * @private */ -pmAnsibleModule.moduleAutocompleteFiled = function(opt) +moduleArgsEditor.moduleAutocompleteFiled = function(opt) { if(opt === undefined) { opt = {} } - - if(!opt.id) - { - opt.id = "module-autocomplete" - } - + if(!opt.value) { opt.value = "" @@ -29,14 +49,14 @@ pmAnsibleModule.moduleAutocompleteFiled = function(opt) html = spajs.just.onInsert(html, function() { - $.when(pmAnsibleModule.loadAllModule()).done(function() + $.when(moduleArgsEditor.loadAllModule()).done(function() { new autoComplete({ - selector: '#'+opt.id, + selector: '#module-autocomplete', minChars: 0, cache:false, showByClick:false, - menuClass:opt.id, + menuClass:"module-autocomplete", renderItem: function(item, search) { var name = item.replace(/^.*\.(.*?)$/, "$1") @@ -53,9 +73,9 @@ pmAnsibleModule.moduleAutocompleteFiled = function(opt) term = term.toLowerCase(); var matches = [] - for(var i in pmAnsibleModule.model.ansible_modules) + for(var i in moduleArgsEditor.model.ansible_modules) { - var val = pmAnsibleModule.model.ansible_modules[i] + var val = moduleArgsEditor.model.ansible_modules[i] if(val.toLowerCase().indexOf(term) != -1) { matches.push(val) @@ -77,18 +97,14 @@ pmAnsibleModule.moduleAutocompleteFiled = function(opt) * Вернёт код для поля ввода аргументов к запуску модуля * @param {String} id * @returns HTML templte + * @private */ -pmAnsibleModule.argsAutocompleteFiled = function(opt) +moduleArgsEditor.argsAutocompleteFiled = function(opt) { if(opt === undefined) { opt = {} - } - - if(!opt.id) - { - opt.id = "module-autocomplete" - } + } if(!opt.value) { @@ -104,7 +120,7 @@ pmAnsibleModule.argsAutocompleteFiled = function(opt) * @param {String} id * @returns HTML templte */ -pmAnsibleModule.moduleFileds = function(opt) +moduleArgsEditor.moduleFileds = function(opt) { if(opt === undefined) { @@ -123,4 +139,15 @@ pmAnsibleModule.moduleFileds = function(opt) var html = spajs.just.render('moduleFileds_template', opt) return html; +} + + +moduleArgsEditor.getModuleArgs = function(opt) +{ + return $("#module-args-string").val() +} + +moduleArgsEditor.getSelectedModuleName = function(opt) +{ + return $("#module-autocomplete").val() } \ No newline at end of file diff --git a/polemarch/static/js/pmAnsibleModule.js b/polemarch/static/js/pmAnsibleModule.js index 9089fd33..2a7bd3a5 100644 --- a/polemarch/static/js/pmAnsibleModule.js +++ b/polemarch/static/js/pmAnsibleModule.js @@ -75,34 +75,11 @@ pmAnsibleModule.fastCommandWidget_RunBtn = function() $('#inventories-autocomplete').val(), pmGroups.getGroupsAutocompleteValue(), 'shell', - $('#module-args-string').val(), + moduleArgsEditor.getModuleArgs(), {} ) } -pmAnsibleModule.loadAllModule = function() -{ - var def = new $.Deferred(); - var thisObj = this; - spajs.ajax.Call({ - url: "/api/v1/ansible/modules/", - type: "GET", - contentType:'application/json', - success: function(data) - { - thisObj.model.ansible_modules = data - def.resolve(); - }, - error:function(e) - { - console.warn(e) - polemarch.showErrors(e) - def.reject(); - } - }); - return def.promise(); -} - /** * @param {Integer} project_id * @param {Integer} inventory_id @@ -145,7 +122,7 @@ pmAnsibleModule.execute = function(project_id, inventory_id, group, module, data if(!data_args) { - data_args = $("#module-args-string").val(); + data_args = moduleArgsEditor.getModuleArgs(); } var data = data_vars @@ -197,127 +174,3 @@ pmAnsibleModule.execute = function(project_id, inventory_id, group, module, data return def.promise(); } - -/** - * Вернёт код для поля автокомплита модулей - * @param {String} id - * @returns HTML templte - * @private - */ -pmAnsibleModule.moduleAutocompleteFiled = function(opt) -{ - if(opt === undefined) - { - opt = {} - } - - if(!opt.id) - { - opt.id = "module-autocomplete" - } - - if(!opt.value) - { - opt.value = "" - } - - var html = spajs.just.render('moduleAutocompleteFiled_template', opt) - - html = spajs.just.onInsert(html, function() - { - $.when(pmAnsibleModule.loadAllModule()).done(function() - { - new autoComplete({ - selector: '#'+opt.id, - minChars: 0, - cache:false, - showByClick:false, - menuClass:opt.id, - renderItem: function(item, search) - { - var name = item.replace(/^.*\.(.*?)$/, "$1") - return '
' + name + " " + item + '
'; - }, - onSelect: function(event, term, item) - { - $("#module-autocomplete").val($(item).attr('data-value')); - //console.log('onSelect', term, item); - //var value = $(item).attr('data-value'); - }, - source: function(term, response) - { - term = term.toLowerCase(); - - var matches = [] - for(var i in pmAnsibleModule.model.ansible_modules) - { - var val = pmAnsibleModule.model.ansible_modules[i] - if(val.toLowerCase().indexOf(term) != -1) - { - matches.push(val) - } - } - if(matches.length) - { - response(matches); - } - } - }); - }) - }) - - return html; -} - -/** - * Вернёт код для поля ввода аргументов к запуску модуля - * @param {String} id - * @returns HTML templte - * @private - */ -pmAnsibleModule.argsAutocompleteFiled = function(opt) -{ - if(opt === undefined) - { - opt = {} - } - - if(!opt.id) - { - opt.id = "module-autocomplete" - } - - if(!opt.value) - { - opt.value = "" - } - - var html = spajs.just.render('moduleArgsFiled_template', opt) - return html; -} - -/** - * Вернёт код для полей для выбора модуля и аргументов к запуску модуля - * @param {String} id - * @returns HTML templte - */ -pmAnsibleModule.moduleFileds = function(opt) -{ - if(opt === undefined) - { - opt = {} - } - - if(!opt.module) - { - opt.module = {} - } - - if(!opt.args) - { - opt.args = {} - } - - var html = spajs.just.render('moduleFileds_template', opt) - return html; -} \ No newline at end of file diff --git a/polemarch/static/js/pmModuleTemplates.js b/polemarch/static/js/pmModuleTemplates.js index 77f91965..6fe86f63 100644 --- a/polemarch/static/js/pmModuleTemplates.js +++ b/polemarch/static/js/pmModuleTemplates.js @@ -112,11 +112,11 @@ pmModuleTemplates.addItem = function() data.name = $("#Templates-name").val() data.kind = this.model.kind data.data = { - module:$("#module-autocomplete").val(), + module:moduleArgsEditor.getSelectedModuleName(), inventory:$("#inventories-autocomplete").val(), project:$("#projects-autocomplete").val(), group:pmGroups.getGroupsAutocompleteValue(), - args:$("#module-args-string").val(), + args:moduleArgsEditor.getModuleArgs(), vars:jsonEditor.jsonEditorGetValues(), } @@ -161,11 +161,11 @@ pmModuleTemplates.updateItem = function(item_id) data.name = $("#Templates-name").val() data.kind = this.model.kind data.data = { - module:$("#module-autocomplete").val(), + module:moduleArgsEditor.getSelectedModuleName(), inventory:$("#inventories-autocomplete").val(), project:$("#projects-autocomplete").val(), group:pmGroups.getGroupsAutocompleteValue(), - args:$("#module-args-string").val(), + args:moduleArgsEditor.getModuleArgs(), vars:jsonEditor.jsonEditorGetValues(), } diff --git a/polemarch/static/js/pmPeriodicTasks.js b/polemarch/static/js/pmPeriodicTasks.js index 8ad94ed9..5ed3d3b9 100644 --- a/polemarch/static/js/pmPeriodicTasks.js +++ b/polemarch/static/js/pmPeriodicTasks.js @@ -138,7 +138,7 @@ pmPeriodicTasks.execute = function(project_id, item_id) return def.promise(); } data.group = pmGroups.getGroupsAutocompleteValue() - data.args = $("#module-args-string").val() + data.args = moduleArgsEditor.getModuleArgs() } else { @@ -445,7 +445,7 @@ pmPeriodicTasks.addItem = function(project_id) if(data.kind == "MODULE") { data.vars.group = pmGroups.getGroupsAutocompleteValue() - data.vars.args = $("#module-args-string").val(); + data.vars.args = moduleArgsEditor.getModuleArgs(); } spajs.ajax.Call({ @@ -577,7 +577,7 @@ pmPeriodicTasks.updateItem = function(item_id) if(data.kind == "MODULE") { data.vars.group = pmGroups.getGroupsAutocompleteValue() - data.vars.args = $("#module-args-string").val(); + data.vars.args = moduleArgsEditor.getModuleArgs(); } var thisObj = this; return spajs.ajax.Call({ diff --git a/polemarch/static/templates/moduleArgsEditor.html b/polemarch/static/templates/moduleArgsEditor.html new file mode 100644 index 00000000..fab6db25 --- /dev/null +++ b/polemarch/static/templates/moduleArgsEditor.html @@ -0,0 +1,44 @@ + + + + + + + + + + \ No newline at end of file diff --git a/polemarch/static/templates/pmAnsibleModule.html b/polemarch/static/templates/pmAnsibleModule.html index b3ccce87..193aec7c 100644 --- a/polemarch/static/templates/pmAnsibleModule.html +++ b/polemarch/static/templates/pmAnsibleModule.html @@ -54,7 +54,7 @@

<~> - <%= pmAnsibleModule.moduleFileds({module:{id:'module-autocomplete'}, args:{id:'module-args-string'}}) %> + <%= moduleArgsEditor.moduleFileds() %> @@ -138,47 +138,3 @@

- - - - - - - - - - \ No newline at end of file diff --git a/polemarch/static/templates/pmModuleTemplates.html b/polemarch/static/templates/pmModuleTemplates.html index 69710fcf..7d2e94e5 100644 --- a/polemarch/static/templates/pmModuleTemplates.html +++ b/polemarch/static/templates/pmModuleTemplates.html @@ -84,13 +84,10 @@

<~> - <%= - pmAnsibleModule.moduleFileds( - { - module:{id:'module-autocomplete', value:pmModuleTemplates.model.items[item_id].data.module }, - args:{id:'module-args-string', value:pmModuleTemplates.model.items[item_id].data.args } - }) - %> + <%= moduleArgsEditor.moduleFileds({ + module:{value:pmModuleTemplates.model.items[item_id].data.module }, + args:{value:pmModuleTemplates.model.items[item_id].data.args } + }) %> @@ -177,12 +174,7 @@

<~> - <%= - pmAnsibleModule.moduleFileds( - { - module:{id:'module-autocomplete'}, args:{id:'module-args-string'} - }) - %> + <%= moduleArgsEditor.moduleFileds() %> From 41b2c1f94816b16840a85069e46d9bb1efe66a2e Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Fri, 29 Sep 2017 15:13:45 +1000 Subject: [PATCH 10/31] Fix bug with unregister --- polemarch/api/routers.py | 7 ++++--- polemarch/api/urls.py | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/polemarch/api/routers.py b/polemarch/api/routers.py index 8d670b57..b8f5bbff 100644 --- a/polemarch/api/routers.py +++ b/polemarch/api/routers.py @@ -43,12 +43,13 @@ def _unreg(self, prefix, objects_list): del objects_list[index] break index += 1 + return objects_list def unregister_view(self, prefix): - self._unreg(prefix, self.custom_urls) # nocv + self.custom_urls = self._unreg(prefix, self.custom_urls) # nocv def unregister(self, prefix): - self._unreg(prefix, self.registry) + self.registry = self._unreg(prefix, self.registry) class APIRouter(_AbstractRouter): @@ -125,7 +126,7 @@ def register_router(self, prefix, router, name=None): self.routers.append((prefix, router, name)) def unregister_router(self, prefix): - self._unreg(prefix, self.routers) # nocv + self.routers = self._unreg(prefix, self.routers) # nocv def get_urls(self): urls = super(MainRouter, self).get_urls() diff --git a/polemarch/api/urls.py b/polemarch/api/urls.py index 7b3ce638..5749cbe5 100644 --- a/polemarch/api/urls.py +++ b/polemarch/api/urls.py @@ -28,7 +28,6 @@ # Register globals - urls = [ url(r'^api/', include(router.urls)), ] From 3a69645a4aa0a76acc98b19dbe3a29ab2a102ef8 Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Fri, 29 Sep 2017 16:23:08 +1000 Subject: [PATCH 11/31] Fix more tests for unregister --- polemarch/api/routers.py | 1 + polemarch/main/unittests/routers.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/polemarch/api/routers.py b/polemarch/api/routers.py index b8f5bbff..0f5e1408 100644 --- a/polemarch/api/routers.py +++ b/polemarch/api/routers.py @@ -37,6 +37,7 @@ def register_view(self, prefix, view, name=None): self.custom_urls.append((prefix, view, name)) def _unreg(self, prefix, objects_list): + del self._urls index = 0 for reg_prefix, _, _ in objects_list: if reg_prefix == prefix: diff --git a/polemarch/main/unittests/routers.py b/polemarch/main/unittests/routers.py index 81df35e9..a5c43877 100644 --- a/polemarch/main/unittests/routers.py +++ b/polemarch/main/unittests/routers.py @@ -1,6 +1,6 @@ from django.test import TestCase -from ...api.urls import router_v1 +from ...api.urls import router_v1, v1 class RoutersTestCase(TestCase): @@ -8,3 +8,10 @@ def test_uregister(self): router_v1.unregister("history") for pattern in router_v1.get_urls(): self.assertIsNone(pattern.regex.search("history/1/")) + router_v1.register('history', v1.UserViewSet) + checked = False + for pattern in router_v1.registry: + if pattern[0] == 'history': + checked = True + self.assertEqual(pattern[1], v1.UserViewSet) + self.assertTrue(checked, "Not registered!") From bbe313542a96d294d0444b243bd9f5c01e0586d8 Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Fri, 29 Sep 2017 16:38:26 +1000 Subject: [PATCH 12/31] ansible module autocomplte gui --- polemarch/static/js/libs/just-watch.js | 14 +++++++++++++- polemarch/static/js/moduleArgsEditor.js | 6 ++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/polemarch/static/js/libs/just-watch.js b/polemarch/static/js/libs/just-watch.js index 5deb5975..90370987 100644 --- a/polemarch/static/js/libs/just-watch.js +++ b/polemarch/static/js/libs/just-watch.js @@ -401,10 +401,22 @@ var justReactive = { { if(attrVal) { - el[j].setAttribute(newval.just_ids[i].attrName, attrVal); + if(el[j][newval.just_ids[i].attrName]) + { + el[j][newval.just_ids[i].attrName] = attrVal + } + else + { + el[j].setAttribute(newval.just_ids[i].attrName, attrVal); + } } else { + if(el[j][newval.just_ids[i].attrName]) + { + el[j][newval.just_ids[i].attrName] = null + } + el[j].removeAttribute(newval.just_ids[i].attrName); } } diff --git a/polemarch/static/js/moduleArgsEditor.js b/polemarch/static/js/moduleArgsEditor.js index 403c20d1..21599509 100644 --- a/polemarch/static/js/moduleArgsEditor.js +++ b/polemarch/static/js/moduleArgsEditor.js @@ -81,10 +81,8 @@ moduleArgsEditor.moduleAutocompleteFiled = function(opt) matches.push(val) } } - if(matches.length) - { - response(matches); - } + + response(matches); } }); }) From a661881ec1ea8ef2f3421051d1c599c3fe42fa43 Mon Sep 17 00:00:00 2001 From: cepreu Date: Fri, 29 Sep 2017 16:57:48 +1000 Subject: [PATCH 13/31] forgotten migration --- .../migrations/0018_auto_20170929_0657.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 polemarch/main/migrations/0018_auto_20170929_0657.py diff --git a/polemarch/main/migrations/0018_auto_20170929_0657.py b/polemarch/main/migrations/0018_auto_20170929_0657.py new file mode 100644 index 00000000..aec6feea --- /dev/null +++ b/polemarch/main/migrations/0018_auto_20170929_0657.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-09-29 06:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0017_periodictask_save_result'), + ] + + operations = [ + migrations.AlterField( + model_name='group', + name='hosts', + field=models.ManyToManyField(related_name='groups', related_query_name='groups', to='main.Host'), + ), + ] From bd88805ff854da71f5c745ec94753f9e4394c503 Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Mon, 2 Oct 2017 13:16:08 +1000 Subject: [PATCH 14/31] Fix tasks scheduler --- polemarch/main/settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/polemarch/main/settings.py b/polemarch/main/settings.py index 8bfe4adf..d0c3b2dd 100644 --- a/polemarch/main/settings.py +++ b/polemarch/main/settings.py @@ -358,16 +358,16 @@ TASKS_HANDLERS = { "REPO": { - "BACKEND": "polemarch.main.tasks.RepoTask" + "BACKEND": "polemarch.main.tasks.tasks.RepoTask" }, "SCHEDUER": { - "BACKEND": "polemarch.main.tasks.ScheduledTask" + "BACKEND": "polemarch.main.tasks.tasks.ScheduledTask" }, "MODULE": { - "BACKEND": "polemarch.main.tasks.ExecuteAnsibleModule" + "BACKEND": "polemarch.main.tasks.tasks.ExecuteAnsibleModule" }, "PLAYBOOK": { - "BACKEND": "polemarch.main.tasks.ExecuteAnsiblePlaybook" + "BACKEND": "polemarch.main.tasks.tasks.ExecuteAnsiblePlaybook" }, } From 140bb66cf8a669e8530a07194228555784af474f Mon Sep 17 00:00:00 2001 From: Trapenok Victor Date: Mon, 2 Oct 2017 15:12:19 +1000 Subject: [PATCH 15/31] was been moved input search field to own template --- polemarch/main/templates/gui/gui.html | 2 +- polemarch/static/js/pmAnsibleModule.js | 2 + polemarch/static/js/pmDashboard.js | 2 + polemarch/static/js/pmGroups.js | 1 + polemarch/static/js/pmHistory.js | 28 ++++++---- polemarch/static/js/pmHosts.js | 1 + polemarch/static/js/pmInventories.js | 1 + polemarch/static/js/pmItems.js | 10 +++- polemarch/static/js/pmModuleTemplates.js | 1 + polemarch/static/js/pmPeriodicTasks.js | 7 +-- polemarch/static/js/pmProjects.js | 1 + polemarch/static/js/pmTasks.js | 1 + polemarch/static/js/pmTasksTemplates.js | 1 + polemarch/static/js/pmTemplates.js | 1 + polemarch/static/js/pmUsers.js | 1 + polemarch/static/templates/pmGroups.html | 17 +------ polemarch/static/templates/pmHistory.html | 51 +++---------------- polemarch/static/templates/pmHosts.html | 18 +------ polemarch/static/templates/pmInventories.html | 17 +------ .../templates/{common.html => pmItems.html} | 18 +++++++ .../static/templates/pmPeriodicTasks.html | 17 +------ polemarch/static/templates/pmProjects.html | 17 +------ .../static/templates/pmTasksTemplates.html | 15 +----- polemarch/static/templates/pmUsers.html | 15 +----- 24 files changed, 82 insertions(+), 163 deletions(-) rename polemarch/static/templates/{common.html => pmItems.html} (70%) diff --git a/polemarch/main/templates/gui/gui.html b/polemarch/main/templates/gui/gui.html index 21296dee..fe5dd760 100644 --- a/polemarch/main/templates/gui/gui.html +++ b/polemarch/main/templates/gui/gui.html @@ -43,9 +43,9 @@ $(document).ready(function() { var templates = [ - 'templates/common', 'templates/jsonEditor', 'templates/crontabEditor', + 'templates/pmItems', 'templates/pmDashboard', 'templates/pmGroups', 'templates/pmHosts', diff --git a/polemarch/static/js/pmAnsibleModule.js b/polemarch/static/js/pmAnsibleModule.js index 2a7bd3a5..37dbd33f 100644 --- a/polemarch/static/js/pmAnsibleModule.js +++ b/polemarch/static/js/pmAnsibleModule.js @@ -11,6 +11,8 @@ var pmAnsibleModule = { } } +pmAnsibleModule.model.className = "pmAnsibleModule" + pmAnsibleModule.selectInventory = function(inventory_id) { var def = new $.Deferred(); diff --git a/polemarch/static/js/pmDashboard.js b/polemarch/static/js/pmDashboard.js index 1e5c766e..82d48130 100644 --- a/polemarch/static/js/pmDashboard.js +++ b/polemarch/static/js/pmDashboard.js @@ -6,6 +6,8 @@ var pmDashboard = { } } +pmDashboard.model.className = "pmDashboard" + pmDashboard.model.count = { projects:'-', inventories:'-', diff --git a/polemarch/static/js/pmGroups.js b/polemarch/static/js/pmGroups.js index 28224c43..499d98d8 100644 --- a/polemarch/static/js/pmGroups.js +++ b/polemarch/static/js/pmGroups.js @@ -2,6 +2,7 @@ var pmGroups = inheritance(pmItems) pmGroups.model.name = "groups" pmGroups.model.page_name = "group" +pmGroups.model.className = "pmGroups" pmGroups.copyItem = function(item_id) { diff --git a/polemarch/static/js/pmHistory.js b/polemarch/static/js/pmHistory.js index 0f7c83bc..cec4d8b0 100644 --- a/polemarch/static/js/pmHistory.js +++ b/polemarch/static/js/pmHistory.js @@ -4,6 +4,7 @@ var pmHistory = inheritance(pmItems) pmHistory.model.name = "history" pmHistory.model.linePerPage = 130; pmHistory.justDeepWatch('model'); +pmHistory.model.className = "pmHistory" pmHistory.cancelTask = function(item_id) { @@ -35,25 +36,34 @@ pmHistory.showSearchResults = function(holder, menuInfo, data) }) } -pmHistory.search = function(project_id, query) -{ - if(!project_id) +pmPeriodicTasks.search = function(query, options) +{ + if(options.inventory_id) { if(!query || !trim(query)) { - return spajs.open({ menuId:this.model.name, reopen:true}); + return spajs.open({ menuId:'inventory/' + options.inventory_id +"/" + this.model.name, reopen:true}); } - return spajs.open({ menuId:this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); + return spajs.open({ menuId:'inventory/' + options.inventory_id +"/" + this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); } + else if(options.project_id) + { + if(!query || !trim(query)) + { + return spajs.open({ menuId:'project/' + options.project_id +"/" + this.model.name, reopen:true}); + } - if(!query || !trim(query)) + return spajs.open({ menuId:'project/' + options.project_id +"/" + this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); + } + else if(!query || !trim(query)) { - return spajs.open({ menuId:'project/' + project_id +"/" + this.model.name, reopen:true}); + return spajs.open({ menuId:this.model.name, reopen:true}); } - - return spajs.open({ menuId:'project/' + project_id +"/" + this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); + + return spajs.open({ menuId:this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); } + pmHistory.showListInProjects = function(holder, menuInfo, data) { diff --git a/polemarch/static/js/pmHosts.js b/polemarch/static/js/pmHosts.js index 5da83667..2b4c0f14 100644 --- a/polemarch/static/js/pmHosts.js +++ b/polemarch/static/js/pmHosts.js @@ -3,6 +3,7 @@ var pmHosts = inheritance(pmItems) pmHosts.model.name = "hosts" pmHosts.model.page_name = "host" +pmHosts.model.className = "pmHosts" pmHosts.copyItem = function(item_id) { diff --git a/polemarch/static/js/pmInventories.js b/polemarch/static/js/pmInventories.js index 72488e5a..1158814a 100644 --- a/polemarch/static/js/pmInventories.js +++ b/polemarch/static/js/pmInventories.js @@ -3,6 +3,7 @@ var pmInventories = inheritance(pmItems) pmInventories.model.name = "inventories" pmInventories.model.page_name = "inventory" +pmInventories.model.className = "pmInventories" /** * Параметры из секции *:vars diff --git a/polemarch/static/js/pmItems.js b/polemarch/static/js/pmItems.js index e8520042..e9e5d561 100644 --- a/polemarch/static/js/pmItems.js +++ b/polemarch/static/js/pmItems.js @@ -19,6 +19,7 @@ pmItems.model.items = {} pmItems.model.name = "based" pmItems.model.page_name = "based" pmItems.model.selectedCount = 0; +pmItems.model.className = "pmItems" pmItems.toggleSelect = function(item_id, mode) { @@ -171,8 +172,15 @@ pmItems.showList = function(holder, menuInfo, data) }) } -pmItems.search = function(query) +pmItems.searchFiled = function(options) { + options.className = this.model.className; + this.model.searchAdditionalData = options + return spajs.just.render('searchFiled', {opt:options}); +} + +pmItems.search = function(query, options) +{ if(!query || !trim(query)) { return spajs.open({ menuId:this.model.name, reopen:true}); diff --git a/polemarch/static/js/pmModuleTemplates.js b/polemarch/static/js/pmModuleTemplates.js index 6fe86f63..6d32b4af 100644 --- a/polemarch/static/js/pmModuleTemplates.js +++ b/polemarch/static/js/pmModuleTemplates.js @@ -4,6 +4,7 @@ var pmModuleTemplates = inheritance(pmTemplates) pmModuleTemplates.model.name = "templates" pmModuleTemplates.model.page_name = "template" pmModuleTemplates.model.selectedInventory = 0 +pmModuleTemplates.model.className = "pmModuleTemplates" // Поддерживаемые kind /api/v1/templates/supported-kinds/ pmModuleTemplates.model.kind = "Module" diff --git a/polemarch/static/js/pmPeriodicTasks.js b/polemarch/static/js/pmPeriodicTasks.js index 5ed3d3b9..414bdc94 100644 --- a/polemarch/static/js/pmPeriodicTasks.js +++ b/polemarch/static/js/pmPeriodicTasks.js @@ -4,6 +4,7 @@ var pmPeriodicTasks = inheritance(pmItems) pmPeriodicTasks.model.page_name = "periodic-task" pmPeriodicTasks.model.name = "periodic-tasks" pmPeriodicTasks.model.selectedInventory = 0; +pmPeriodicTasks.model.className = "pmPeriodicTasks" pmPeriodicTasks.copyAndEdit = function(item_id) { @@ -241,14 +242,14 @@ pmPeriodicTasks.showList = function(holder, menuInfo, data) }).promise(); } -pmPeriodicTasks.search = function(project_id, query) +pmPeriodicTasks.search = function(query, options) { if(!query || !trim(query)) { - return spajs.open({ menuId:'project/' + project_id +"/" + this.model.name, reopen:true}); + return spajs.open({ menuId:'project/' + options.project_id +"/" + this.model.name, reopen:true}); } - return spajs.open({ menuId:'project/' + project_id +"/" + this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); + return spajs.open({ menuId:'project/' + options.project_id +"/" + this.model.name+"/search/"+encodeURIComponent(trim(query)), reopen:true}); } pmPeriodicTasks.showSearchResults = function(holder, menuInfo, data) diff --git a/polemarch/static/js/pmProjects.js b/polemarch/static/js/pmProjects.js index 5923ceb6..0ac4cabd 100644 --- a/polemarch/static/js/pmProjects.js +++ b/polemarch/static/js/pmProjects.js @@ -3,6 +3,7 @@ var pmProjects = inheritance(pmItems) pmProjects.model.name = "projects" jsonEditor.options[pmProjects.model.name] = {}; pmProjects.model.selectedInventory = 0 +pmProjects.model.className = "pmProjects" jsonEditor.options[pmProjects.model.name]['repo_password'] = { type:'password', diff --git a/polemarch/static/js/pmTasks.js b/polemarch/static/js/pmTasks.js index 7258f8b2..44794dc6 100644 --- a/polemarch/static/js/pmTasks.js +++ b/polemarch/static/js/pmTasks.js @@ -7,6 +7,7 @@ var pmTasks = inheritance(pmItems) pmTasks.model.name = "tasks" +pmTasks.model.className = "pmTasks" pmTasks.execute = function(project_id, inventory, playbook, data_vars) { diff --git a/polemarch/static/js/pmTasksTemplates.js b/polemarch/static/js/pmTasksTemplates.js index b10c0150..1d3ff744 100644 --- a/polemarch/static/js/pmTasksTemplates.js +++ b/polemarch/static/js/pmTasksTemplates.js @@ -5,6 +5,7 @@ var pmTasksTemplates = inheritance(pmTemplates) pmTasksTemplates.model.name = "templates" pmTasksTemplates.model.page_name = "template" +pmTasksTemplates.model.className = "pmTasksTemplates" // Поддерживаемые kind /api/v1/templates/supported-kinds/ pmTasksTemplates.model.kind = "Task" diff --git a/polemarch/static/js/pmTemplates.js b/polemarch/static/js/pmTemplates.js index 1a1df511..d9e50798 100644 --- a/polemarch/static/js/pmTemplates.js +++ b/polemarch/static/js/pmTemplates.js @@ -6,6 +6,7 @@ pmTemplates.model.name = "templates" // Поддерживаемые kind /api/v1/templates/supported-kinds/ pmTemplates.model.kind = "Task,Module" +pmTemplates.model.className = "pmTemplates" pmTemplates.copyAndEdit = function(item_id) { diff --git a/polemarch/static/js/pmUsers.js b/polemarch/static/js/pmUsers.js index 2a2fbfde..c83e1764 100644 --- a/polemarch/static/js/pmUsers.js +++ b/polemarch/static/js/pmUsers.js @@ -3,6 +3,7 @@ var pmUsers = inheritance(pmItems) pmUsers.model.name = "users" pmUsers.model.page_name = "user" +pmUsers.model.className = "pmUsers" pmUsers.copyItem = function(item_id) { diff --git a/polemarch/static/templates/pmGroups.html b/polemarch/static/templates/pmGroups.html index a214fb83..470c67dc 100644 --- a/polemarch/static/templates/pmGroups.html +++ b/polemarch/static/templates/pmGroups.html @@ -20,21 +20,8 @@

- Groups -
- -
- -
-
+ Groups + <%= pmGroups.searchFiled({query:query}) %> <% if(pmGroups.getTotalPages(pmGroups.model.itemslist)){ %>