Fixes for make tasks
This commit is contained in:
parent
e2e9c80647
commit
ff93c78831
6 changed files with 376 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||||
from paramecio2.libraries import datetime
|
from paramecio2.libraries import datetime
|
||||||
from paramecio2.libraries.urls import make_media_url
|
from paramecio2.libraries.urls import make_media_url
|
||||||
from modules.monit.models.monit import Server, ServerData, Alerts
|
from modules.monit.models.monit import Server, ServerData, Alerts
|
||||||
|
from modules.pastafari2.libraries.scandir import scandir
|
||||||
from paramecio2.libraries.db.webmodel import WebModel
|
from paramecio2.libraries.db.webmodel import WebModel
|
||||||
from paramecio2.libraries.lists import AjaxList
|
from paramecio2.libraries.lists import AjaxList
|
||||||
from paramecio2.libraries.db.extraforms.fileform import FileForm
|
from paramecio2.libraries.db.extraforms.fileform import FileForm
|
||||||
|
|
@ -20,6 +21,10 @@ from pathlib import Path
|
||||||
import paramiko
|
import paramiko
|
||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
|
import configparser
|
||||||
|
from collections import OrderedDict
|
||||||
|
from importlib import import_module, reload
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ujson as json
|
import ujson as json
|
||||||
except:
|
except:
|
||||||
|
|
@ -35,10 +40,28 @@ t.env.directories.insert(1, os.path.dirname(__file__).replace('/admin', '')+'/te
|
||||||
|
|
||||||
system_path='./ssh/'
|
system_path='./ssh/'
|
||||||
|
|
||||||
|
base_path='modules/pastafari2/tasks'
|
||||||
|
|
||||||
|
if hasattr(config, 'pastafari_base_path'):
|
||||||
|
base_path=config.pastafari_base_path
|
||||||
|
|
||||||
|
pastafari_paths=[]
|
||||||
|
|
||||||
|
if hasattr(config, 'pastafari_paths'):
|
||||||
|
pastafari_paths=config.pastafari_paths
|
||||||
|
|
||||||
@admin_app.route('/pastafari2/dashboard/')
|
@admin_app.route('/pastafari2/dashboard/')
|
||||||
def pastafari2_dashboard():
|
def pastafari2_dashboard():
|
||||||
|
|
||||||
return t.load_template('dash_pastafari.phtml', title=I18n.lang('pastafari2', 'servers_dashboard', 'Servers Dashboard'), path_module='admin_app.pastafari2_dashboard')
|
config_parser=configparser.ConfigParser()
|
||||||
|
|
||||||
|
select_task=scandir(base_path, config_parser, OrderedDict(), 'tasks')
|
||||||
|
|
||||||
|
for module in pastafari_paths:
|
||||||
|
|
||||||
|
select_task=scandir(module, config_parser, select_task, 'tasks')
|
||||||
|
|
||||||
|
return t.load_template('dash_pastafari.phtml', title=I18n.lang('pastafari2', 'servers_dashboard', 'Servers Dashboard'), path_module='admin_app.pastafari2_dashboard', select_task=select_task)
|
||||||
|
|
||||||
@admin_app.route('/pastafari2/settings/')
|
@admin_app.route('/pastafari2/settings/')
|
||||||
def pastafari2_settings():
|
def pastafari2_settings():
|
||||||
|
|
@ -472,7 +495,77 @@ def pastafari2_update_task():
|
||||||
|
|
||||||
return {'error': error, 'txt_error': txt_error, 'error_form': error_form, 'task_id': task_id}
|
return {'error': error, 'txt_error': txt_error, 'error_form': error_form, 'task_id': task_id}
|
||||||
|
|
||||||
return {}
|
@admin_app.route('/pastafari2/make_task/', methods=['POST'])
|
||||||
|
def pastafari2_make_task():
|
||||||
|
|
||||||
|
db=g.connection
|
||||||
|
|
||||||
|
ids=json.loads(request.form.get('ids', '[]'))
|
||||||
|
arr_ids=[]
|
||||||
|
|
||||||
|
task_file=request.form.get('task', '')
|
||||||
|
|
||||||
|
task_file=task_file.replace('/', '.')
|
||||||
|
|
||||||
|
task_file=task_file.replace('.py', '')
|
||||||
|
|
||||||
|
task_execute=import_module(task_file)
|
||||||
|
|
||||||
|
task_first=task_execute.ServerTask('', db, remote_user='root', remote_password='', private_key='./ssh/id_rsa', password_key='', remote_path='pastafari2', task_id=0, data={'mysql_password': ''})
|
||||||
|
|
||||||
|
if config.reloader:
|
||||||
|
reload(task_execute)
|
||||||
|
|
||||||
|
send_task=request.args.get('send_task', '')
|
||||||
|
|
||||||
|
#if not os.path.isfile(task)
|
||||||
|
|
||||||
|
if send_task=='':
|
||||||
|
|
||||||
|
#Check if form
|
||||||
|
|
||||||
|
if hasattr(task_first, 'form'):
|
||||||
|
|
||||||
|
url_exec=url_for('.pastafari2_make_task', ids=ids, task_file=task_file, send_task=1)
|
||||||
|
|
||||||
|
return t.load_template('maketask.phtml', form=task_first.form(t, yes_error=False, pass_values=False), url_exec=url_exec)
|
||||||
|
|
||||||
|
error=0
|
||||||
|
txt_error=''
|
||||||
|
error_form={}
|
||||||
|
|
||||||
|
#print(ids)
|
||||||
|
for v in ids:
|
||||||
|
arr_ids.append(str(int(v)))
|
||||||
|
|
||||||
|
where_sql='WHERE id IN ('+",".join(arr_ids)+') order by hostname ASC'
|
||||||
|
|
||||||
|
#print(where_sql)
|
||||||
|
|
||||||
|
task=Task(db)
|
||||||
|
|
||||||
|
task_id=0
|
||||||
|
|
||||||
|
path_task='modules.pastafari2.tasks.system.updates'
|
||||||
|
|
||||||
|
#Load task, check if have question
|
||||||
|
|
||||||
|
data={}
|
||||||
|
|
||||||
|
server_host=''
|
||||||
|
|
||||||
|
user=config_task.remote_user
|
||||||
|
|
||||||
|
ssh_key_priv='./ssh/id_rsa'
|
||||||
|
"""
|
||||||
|
if not task.run_task(server_host, path_task, 'Update server', 'update_server', 'Task for update servers', user=user, password='', where_sql_server=where_sql, ssh_key_priv=ssh_key_priv, url='', data=data, send_task=True):
|
||||||
|
|
||||||
|
error=1
|
||||||
|
error_form['#server_host_error']=I18n.lang('pastafari2', 'error_exec_task', 'Error: cannot execute the task')
|
||||||
|
|
||||||
|
task_id=task.task_id
|
||||||
|
"""
|
||||||
|
return {'error': error, 'txt_error': txt_error, 'error_form': error_form, 'task_id': task_id}
|
||||||
|
|
||||||
@admin_app.route('/pastafari2/multiprogress/')
|
@admin_app.route('/pastafari2/multiprogress/')
|
||||||
def pastafari2_multiprogress():
|
def pastafari2_multiprogress():
|
||||||
|
|
|
||||||
131
admin/tasks_edit.py
Normal file
131
admin/tasks_edit.py
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
from settings import config
|
||||||
|
from flask import g, url_for, request, session, make_response
|
||||||
|
from paramecio2.libraries.generate_admin_class import GenerateAdminClass
|
||||||
|
from paramecio2.libraries.i18n import I18n
|
||||||
|
from paramecio2.modules.admin import admin_app, t as admin_t
|
||||||
|
from paramecio2.libraries.db.coreforms import SelectForm
|
||||||
|
from paramecio2.libraries.mtemplates import PTemplate, env_theme
|
||||||
|
from paramecio2.libraries import datetime
|
||||||
|
from paramecio2.libraries.urls import make_media_url
|
||||||
|
from paramecio2.libraries.db.webmodel import WebModel
|
||||||
|
from paramecio2.libraries.lists import AjaxList
|
||||||
|
from paramecio2.libraries.db.extraforms.fileform import FileForm
|
||||||
|
from paramecio2.libraries.formsutils import show_form
|
||||||
|
from modules.pastafari2.libraries.task import Task as SSHTask
|
||||||
|
from modules.pastafari2.libraries.configtask import config_task
|
||||||
|
#from modules.pastafari2.models.scripts import Task, LogTask
|
||||||
|
from modules.pastafari2.models.pastafari2 import NameServerScripts, ServerScripts
|
||||||
|
from modules.pastafari2.models.pastafari2 import ServerGroup
|
||||||
|
from paramecio2.libraries.lists import SimpleList
|
||||||
|
from paramecio2.libraries.db.coreforms import SelectForm, SelectModelForm, HiddenForm
|
||||||
|
|
||||||
|
@admin_app.route('/pastafari2/tasks_edit/', methods=['GET', 'POST'])
|
||||||
|
def pastafari2_tasks_edit():
|
||||||
|
|
||||||
|
t=admin_t
|
||||||
|
|
||||||
|
db=g.connection
|
||||||
|
|
||||||
|
scripts=NameServerScripts(db)
|
||||||
|
|
||||||
|
url=url_for('admin_app.pastafari2_tasks_edit')
|
||||||
|
|
||||||
|
admin=GenerateAdminClass(scripts, url, t)
|
||||||
|
|
||||||
|
admin.list.raw_query=False
|
||||||
|
|
||||||
|
#request.args['order']=request.args.get('order', '1')
|
||||||
|
admin.list.order='1'
|
||||||
|
|
||||||
|
admin.list.fields_showed=['id', 'name']
|
||||||
|
|
||||||
|
admin.list.arr_extra_options=[scripts_options]
|
||||||
|
|
||||||
|
admin.no_insert=True
|
||||||
|
|
||||||
|
admin.no_delete=True
|
||||||
|
|
||||||
|
form_admin=admin.show()
|
||||||
|
|
||||||
|
if type(form_admin).__name__=='str':
|
||||||
|
|
||||||
|
return t.load_template('content.phtml', title=I18n.lang('admin', 'tasks_edit', 'Tasks edit'), contents=form_admin, path_module='admin_app.pastafari2_tasks_edit')
|
||||||
|
else:
|
||||||
|
|
||||||
|
return form_admin
|
||||||
|
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def scripts_options(url, row_id, row):
|
||||||
|
"""
|
||||||
|
if row['is_parent']:
|
||||||
|
|
||||||
|
return ['<a target="_blank" href="'+url_for('admin_app.pastafari2_multiprogress', task_id=row_id)+'">'+I18n.lang('pastafari2', 'view_task_log', 'View task log')+'</a>']
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
return ['<a target="_blank" href="'+url_for('admin_app.pastafari2_progress', task_id=row_id)+'">'+I18n.lang('pastafari2', 'view_task_log', 'View task log')+'</a>']
|
||||||
|
"""
|
||||||
|
#return ['<a href="">'+I18n.lang('pastafari2', 'edit_scripts', 'Edit scripts')+'</a>']
|
||||||
|
|
||||||
|
arr_options=SimpleList.standard_options(url, row_id, row)
|
||||||
|
|
||||||
|
arr_options.append('<a href="'+url_for('admin_app.pastafari2_scripts_edit', scripts_id=row_id)+'">'+I18n.lang('pastafari2', 'edit_scripts', 'Edit scripts')+'</a>')
|
||||||
|
|
||||||
|
return arr_options
|
||||||
|
|
||||||
|
|
||||||
|
@admin_app.route('/pastafari2/scripts_edit/', methods=['GET', 'POST'])
|
||||||
|
def pastafari2_scripts_edit():
|
||||||
|
"""Simple function for edit and add scripts to a task"""
|
||||||
|
|
||||||
|
t=admin_t
|
||||||
|
|
||||||
|
db=g.connection
|
||||||
|
|
||||||
|
scripts_id=request.args.get('scripts_id', '0')
|
||||||
|
|
||||||
|
scripts=ServerScripts(db)
|
||||||
|
|
||||||
|
scripts.fields['scripts_id'].name_form=HiddenForm
|
||||||
|
|
||||||
|
scripts.fields['scripts_id'].extra_parameters=[]
|
||||||
|
|
||||||
|
scripts.fields['scripts_id'].default_value=scripts_id
|
||||||
|
|
||||||
|
scripts.enctype=True
|
||||||
|
|
||||||
|
scripts.fields['file'].yes_prefix=False
|
||||||
|
|
||||||
|
server=NameServerScripts(db)
|
||||||
|
|
||||||
|
url=url_for('.pastafari2_scripts_edit', scripts_id=scripts_id)
|
||||||
|
|
||||||
|
arr_server=server.select_a_row(scripts_id)
|
||||||
|
|
||||||
|
if arr_server:
|
||||||
|
|
||||||
|
scripts.set_conditions('WHERE scripts_id=%s', [scripts_id])
|
||||||
|
|
||||||
|
admin=GenerateAdminClass(scripts, url, t)
|
||||||
|
|
||||||
|
admin.list.fields_showed=['name', 'file', 'position']
|
||||||
|
|
||||||
|
admin.list.yes_search=False
|
||||||
|
|
||||||
|
#admin.list.table_div=True
|
||||||
|
|
||||||
|
admin.list.order_field='position'
|
||||||
|
|
||||||
|
form_admin=admin.show()
|
||||||
|
|
||||||
|
if type(form_admin).__name__=='str':
|
||||||
|
|
||||||
|
return t.load_template('edit_scripts.phtml', title=I18n.lang('pastafari2', 'edit_script', 'Edit scripts'), path_module='admin_app.pastafari2_edit_scripts', server_scripts=arr_server, edit_update=form_admin)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return form_admin
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
return ""
|
||||||
39
libraries/scandir.py
Normal file
39
libraries/scandir.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
def scandir(mydir, config_parser, arr_dir=OrderedDict(), father=''):
|
||||||
|
|
||||||
|
search_dir=os.listdir(mydir)
|
||||||
|
|
||||||
|
for one_path in search_dir:
|
||||||
|
|
||||||
|
if os.path.isfile(mydir+'/'+one_path):
|
||||||
|
if one_path=='info.cfg':
|
||||||
|
# Read the info file and put radio form in python files signed in file
|
||||||
|
config_parser.clear()
|
||||||
|
config_parser.read(mydir+'/'+one_path)
|
||||||
|
|
||||||
|
if 'info' in config_parser:
|
||||||
|
if 'name' in config_parser['info']:
|
||||||
|
|
||||||
|
if not father in arr_dir:
|
||||||
|
arr_dir[father]={}
|
||||||
|
|
||||||
|
arr_dir[father][os.path.basename(mydir)]=[]
|
||||||
|
|
||||||
|
arr_dir[father][os.path.basename(mydir)].append([config_parser['info']['name'], father, 0])
|
||||||
|
|
||||||
|
if 'modules' in config_parser:
|
||||||
|
for k, v in config_parser['modules'].items():
|
||||||
|
#arr_dir[father][os.path.basename(mydir)].append([config_parser['modules'][k], s.dumps({'file': mydir+'/'+k+'.py'}), 1])
|
||||||
|
arr_dir[father][os.path.basename(mydir)].append([config_parser['modules'][k], mydir+'/'+k+'.py', 1])
|
||||||
|
|
||||||
|
|
||||||
|
elif os.path.isdir(mydir+'/'+one_path):
|
||||||
|
|
||||||
|
arr_dir=scandir(mydir+'/'+one_path, config_parser, arr_dir, os.path.basename(mydir))
|
||||||
|
|
||||||
|
return arr_dir
|
||||||
|
|
||||||
|
|
@ -56,5 +56,16 @@ class ServerScripts(WebModel):
|
||||||
super().__init__(connection)
|
super().__init__(connection)
|
||||||
self.register(corefields.CharField('name'), True)
|
self.register(corefields.CharField('name'), True)
|
||||||
self.register(FileField('file', './scripts/local/tasks'), True)
|
self.register(FileField('file', './scripts/local/tasks'), True)
|
||||||
self.register(corefields.ForeignKeyField('scripts_id', NameServerScripts(connection), 11, False, 'id', 'group', select_fields=[]))
|
self.register(corefields.ForeignKeyField('scripts_id', NameServerScripts(connection), 11, False, 'id', 'name', select_fields=[]))
|
||||||
self.register(corefields.IntegerField('position'))
|
self.register(corefields.IntegerField('position'))
|
||||||
|
self.register(corefields.CharField('question0'))
|
||||||
|
self.register(corefields.CharField('question1'))
|
||||||
|
self.register(corefields.CharField('question2'))
|
||||||
|
self.register(corefields.CharField('question3'))
|
||||||
|
self.register(corefields.CharField('question4'))
|
||||||
|
self.register(corefields.CharField('question5'))
|
||||||
|
self.register(corefields.CharField('question6'))
|
||||||
|
self.register(corefields.CharField('question7'))
|
||||||
|
self.register(corefields.CharField('question8'))
|
||||||
|
self.register(corefields.CharField('question9'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,5 @@ config_admin.append([I18n.lang('pastafari2', 'pastafari_admin', 'Pastafari admin
|
||||||
config_admin.append([I18n.lang('pastafari2', 'settings', 'Settings'), 'modules.pastafari2.admin.dashboard', 'admin_app.pastafari2_settings', 'fa-code'])
|
config_admin.append([I18n.lang('pastafari2', 'settings', 'Settings'), 'modules.pastafari2.admin.dashboard', 'admin_app.pastafari2_settings', 'fa-code'])
|
||||||
config_admin.append([I18n.lang('pastafari2', 'servers', 'Servers'), 'modules.pastafari2.admin.dashboard', 'admin_app.pastafari2_dashboard', 'fa-linux'])
|
config_admin.append([I18n.lang('pastafari2', 'servers', 'Servers'), 'modules.pastafari2.admin.dashboard', 'admin_app.pastafari2_dashboard', 'fa-linux'])
|
||||||
config_admin.append([I18n.lang('pastafari2', 'groups', 'Groups'), 'modules.pastafari2.admin.groups', 'admin_app.pastafari2_groups', 'fa-object-group'])
|
config_admin.append([I18n.lang('pastafari2', 'groups', 'Groups'), 'modules.pastafari2.admin.groups', 'admin_app.pastafari2_groups', 'fa-object-group'])
|
||||||
config_admin.append([I18n.lang('pastafari2', 'tasks_log', 'Tasks log'), 'modules.pastafari2.admin.tasks', 'admin_app.pastafari2_tasks', 'fa-tasks'])
|
config_admin.append([I18n.lang('pastafari2', 'tasks_edit', 'Tasks edit'), 'modules.pastafari2.admin.tasks_edit', 'admin_app.pastafari2_tasks_edit', 'fa-tasks'])
|
||||||
|
config_admin.append([I18n.lang('pastafari2', 'tasks_log', 'Tasks log'), 'modules.pastafari2.admin.tasks', 'admin_app.pastafari2_tasks', 'fa-file-text-o'])
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,69 @@
|
||||||
<p>${lang('monit', 'choose_group', 'Choose group')}:
|
<p>${lang('monit', 'choose_group', 'Choose group')}:
|
||||||
<select name="group_id" id="group_id">
|
<select name="group_id" id="group_id">
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<%def name="show_tasks(task_folder, separator)">
|
||||||
|
<!--<ul class="superul">-->
|
||||||
|
% if task_folder in select_task:
|
||||||
|
|
||||||
|
% for task,value in select_task[task_folder].items():
|
||||||
|
|
||||||
|
<optgroup label="${separator}${value[0][0]}">
|
||||||
|
% if len(value)>=2:
|
||||||
|
% for script in enumerate(value, 1):
|
||||||
|
%if script[1][2]==1:
|
||||||
|
<option value="${script[1][1]}">
|
||||||
|
${script[1][0].split(',')[0].strip()}
|
||||||
|
</option>
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
% endif
|
||||||
|
|
||||||
|
<!--<li>
|
||||||
|
<a href="#" class="category_server">${value[0][0]}</a>
|
||||||
|
|
||||||
|
% if len(value)>=2:
|
||||||
|
<ul style="display:none;" class="sonul">
|
||||||
|
% for script in enumerate(value, 1):
|
||||||
|
%if script[1][2]==1:
|
||||||
|
<li>
|
||||||
|
${script[1][0].split(',')[0].strip()}<input type="radio" name="task" value="${script[1][1]}"/>
|
||||||
|
<i class="fa fa-question-circle tooltip" data-tooltip-content="#tooltip_task_${script[1][1]}_content" style="cursor:pointer;"></i> \
|
||||||
|
<div class="tooltip_templates" style="display:none;"><div id="tooltip_task_${script[1][1]}_content">ayuda</div></div>
|
||||||
|
</li>
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
</ul>
|
||||||
|
% endif
|
||||||
|
|
||||||
|
</li>-->
|
||||||
|
% if task in select_task:
|
||||||
|
${show_tasks(task, separator+'--')}
|
||||||
|
%endif
|
||||||
|
</optgroup>
|
||||||
|
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
% endif
|
||||||
|
<!--</ul>-->
|
||||||
|
</%def>
|
||||||
|
<p>
|
||||||
|
<select name="task" id="task">
|
||||||
|
<option value="">Select a task...</option>
|
||||||
|
${show_tasks('tasks', '')}
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<input type="button" name="select_all" class="select_all" value="${lang('pastafari2', 'select_all_servers', 'Select all servers')}" />
|
<input type="button" name="select_all" class="select_all" value="${lang('pastafari2', 'select_all_servers', 'Select all servers')}" />
|
||||||
<input type="button" name="deselect_all" class="deselect_all" value="${lang('pastafari2', 'deselect_all_servers', 'Deselect all servers')}" />
|
<input type="button" name="deselect_all" class="deselect_all" value="${lang('pastafari2', 'deselect_all_servers', 'Deselect all servers')}" />
|
||||||
<input type="button" name="update_selected_servers" class="update_selected_servers button_blue" value="${lang('pastafari2', 'update_selected_servers', 'Update selected servers')}" />
|
<input type="button" name="update_selected_servers" class="send_task_server update_selected_servers button_blue" value="${lang('pastafari2', 'update_selected_servers', 'Update selected servers')}" />
|
||||||
|
<input type="button" name="make_task_selected_servers" class="send_task_server make_task_selected_servers button_blue" value="${lang('pastafari2', 'make_task_selected_servers', 'Make task in selected servers')}" />
|
||||||
<div id="table_servers">
|
<div id="table_servers">
|
||||||
</div>
|
</div>
|
||||||
<input type="button" name="select_all" class="select_all" value="${lang('pastafari2', 'select_all_servers', 'Select all servers')}" />
|
<input type="button" name="select_all" class="select_all" value="${lang('pastafari2', 'select_all_servers', 'Select all servers')}" />
|
||||||
<input type="button" name="deselect_all" class="deselect_all" value="${lang('pastafari2', 'deselect_all_servers', 'Deselect all servers')}" />
|
<input type="button" name="deselect_all" class="deselect_all" value="${lang('pastafari2', 'deselect_all_servers', 'Deselect all servers')}" />
|
||||||
<input type="button" name="update_selected_servers" class="update_selected_servers button_blue" value="${lang('pastafari2', 'update_selected_servers', 'Update selected servers')}" />
|
<input type="button" name="update_selected_servers" class="send_task_server update_selected_servers button_blue" value="${lang('pastafari2', 'update_selected_servers', 'Update selected servers')}" />
|
||||||
|
<input type="button" name="make_task_selected_servers" class="send_task_server make_task_selected_servers button_blue" value="${lang('pastafari2', 'make_task_selected_servers', 'Make task in selected servers')}" />
|
||||||
</div>
|
</div>
|
||||||
</%block>
|
</%block>
|
||||||
<%block name="jscript_block">
|
<%block name="jscript_block">
|
||||||
|
|
@ -73,7 +126,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('.update_selected_servers').click( function () {
|
$('.send_task_server').click( function () {
|
||||||
|
|
||||||
if($('.server_id:checked').length==0) {
|
if($('.server_id:checked').length==0) {
|
||||||
|
|
||||||
|
|
@ -83,8 +136,6 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$('#layer_loading').show();
|
|
||||||
|
|
||||||
server_ids=[];
|
server_ids=[];
|
||||||
|
|
||||||
$('.server_id:checked').each( function () {
|
$('.server_id:checked').each( function () {
|
||||||
|
|
@ -93,10 +144,29 @@ $(document).ready(function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
url_task="${url_for('.pastafari2_update_task')}";
|
||||||
|
|
||||||
|
task='';
|
||||||
|
|
||||||
|
if($(this).hasClass('make_task_selected_servers')) {
|
||||||
|
|
||||||
|
url_task="${url_for('.pastafari2_make_task')}";
|
||||||
|
task=$('#task').val();
|
||||||
|
|
||||||
|
if(task=='') {
|
||||||
|
|
||||||
|
alert("${lang('pastafari2', 'no_task_selected', 'No task selected')}");
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#layer_loading').show();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
||||||
url:"${url_for('.pastafari2_update_task')}",
|
url:url_task,
|
||||||
data: {'ids': JSON.stringify(server_ids)},
|
data: {'ids': JSON.stringify(server_ids), 'task': task},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
|
||||||
if(!data.error) {
|
if(!data.error) {
|
||||||
|
|
@ -131,5 +201,25 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*$('.category_server').click(function () {
|
||||||
|
|
||||||
|
if($(this).parent().children('.sonul').css('display')=='none')
|
||||||
|
{
|
||||||
|
|
||||||
|
$(this).parent().children('.sonul').show();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
$(this).parent().children('.sonul').hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});*/
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</%block>
|
</%block>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue