mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure steps and schedules can be created in empty jobs. Fixes #1878
This commit is contained in:
parent
e6d018c44f
commit
ef0d26c294
@ -219,8 +219,8 @@ class JobScheduleView(PGChildNodeView):
|
|||||||
res = []
|
res = []
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'nodes.sql']),
|
"/".join([self.template_path, 'nodes.sql']),
|
||||||
jscid = jscid,
|
jscid=jscid,
|
||||||
jid = jid
|
jid=jid
|
||||||
)
|
)
|
||||||
|
|
||||||
status, result = self.conn.execute_2darray(sql)
|
status, result = self.conn.execute_2darray(sql)
|
||||||
@ -298,13 +298,22 @@ class JobScheduleView(PGChildNodeView):
|
|||||||
jid: Job ID
|
jid: Job ID
|
||||||
"""
|
"""
|
||||||
data = {}
|
data = {}
|
||||||
for k, v in request.args.items():
|
if request.args:
|
||||||
try:
|
for k, v in request.args.items():
|
||||||
data[k] = json.loads(
|
try:
|
||||||
v.decode('utf-8') if hasattr(v, 'decode') else v
|
data[k] = json.loads(
|
||||||
)
|
v.decode('utf-8') if hasattr(v, 'decode') else v
|
||||||
except ValueError:
|
)
|
||||||
data[k] = v
|
except ValueError:
|
||||||
|
data[k] = v
|
||||||
|
else:
|
||||||
|
data = json.loads(request.data.decode())
|
||||||
|
# convert python list literal to postgres array literal.
|
||||||
|
data['jscminutes'] = data['jscminutes'].replace("[", "{").replace("]", "}")
|
||||||
|
data['jschours'] = data['jschours'].replace("[", "{").replace("]", "}")
|
||||||
|
data['jscweekdays'] = data['jscweekdays'].replace("[", "{").replace("]", "}")
|
||||||
|
data['jscmonthdays'] = data['jscmonthdays'].replace("[", "{").replace("]", "}")
|
||||||
|
data['jscmonths'] = data['jscmonths'].replace("[", "{").replace("]", "}")
|
||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'create.sql']),
|
"/".join([self.template_path, 'create.sql']),
|
||||||
@ -327,8 +336,8 @@ class JobScheduleView(PGChildNodeView):
|
|||||||
self.conn.execute_void('END')
|
self.conn.execute_void('END')
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'nodes.sql']),
|
"/".join([self.template_path, 'nodes.sql']),
|
||||||
jscid = res,
|
jscid=res,
|
||||||
jid = jid
|
jid=jid
|
||||||
)
|
)
|
||||||
status, res = self.conn.execute_2darray(sql)
|
status, res = self.conn.execute_2darray(sql)
|
||||||
|
|
||||||
@ -357,17 +366,36 @@ class JobScheduleView(PGChildNodeView):
|
|||||||
jscid: JobSchedule ID
|
jscid: JobSchedule ID
|
||||||
"""
|
"""
|
||||||
data = {}
|
data = {}
|
||||||
for k, v in request.args.items():
|
if request.args:
|
||||||
try:
|
for k, v in request.args.items():
|
||||||
data[k] = json.loads(
|
try:
|
||||||
v.decode('utf-8') if hasattr(v, 'decode') else v
|
data[k] = json.loads(
|
||||||
)
|
v.decode('utf-8') if hasattr(v, 'decode') else v
|
||||||
except ValueError:
|
)
|
||||||
data[k] = v
|
except ValueError:
|
||||||
|
data[k] = v
|
||||||
|
else:
|
||||||
|
data = json.loads(request.data.decode())
|
||||||
|
# convert python list literal to postgres array literal.
|
||||||
|
if 'jscminutes' in data:
|
||||||
|
data['jscminutes'] = data['jscminutes'].replace("[", "{").replace("]", "}")
|
||||||
|
|
||||||
|
if 'jschours' in data:
|
||||||
|
data['jschours'] = data['jschours'].replace("[", "{").replace("]", "}")
|
||||||
|
|
||||||
|
if 'jscweekdays' in data:
|
||||||
|
data['jscweekdays'] = data['jscweekdays'].replace("[", "{").replace("]", "}")
|
||||||
|
|
||||||
|
if 'jscmonthdays' in data:
|
||||||
|
data['jscmonthdays'] = data['jscmonthdays'].replace("[", "{").replace("]", "}")
|
||||||
|
|
||||||
|
if 'jscmonths' in data:
|
||||||
|
data['jscmonths'] = data['jscmonths'].replace("[", "{").replace("]", "}")
|
||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'update.sql']),
|
"/".join([self.template_path, 'update.sql']),
|
||||||
jid=jid,
|
jid=jid,
|
||||||
|
jscid=jscid,
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -378,8 +406,8 @@ class JobScheduleView(PGChildNodeView):
|
|||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'nodes.sql']),
|
"/".join([self.template_path, 'nodes.sql']),
|
||||||
jscid = jscid,
|
jscid=jscid,
|
||||||
jid = jid
|
jid=jid
|
||||||
)
|
)
|
||||||
status, res = self.conn.execute_2darray(sql)
|
status, res = self.conn.execute_2darray(sql)
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ function($, _, S, pgAdmin, moment, pgBrowser, Alertify, Backform) {
|
|||||||
parent_type: 'pga_job',
|
parent_type: 'pga_job',
|
||||||
type: 'pga_schedule',
|
type: 'pga_schedule',
|
||||||
dialogHelp: '{{ url_for('help.static', filename='pgagent_jobs.html') }}',
|
dialogHelp: '{{ url_for('help.static', filename='pgagent_jobs.html') }}',
|
||||||
hasSQL: false,
|
hasSQL: true,
|
||||||
hasDepends: false,
|
hasDepends: false,
|
||||||
hasStatistics: false,
|
hasStatistics: false,
|
||||||
canDrop: function(node) {
|
canDrop: function(node) {
|
||||||
|
@ -232,8 +232,8 @@ SELECT EXISTS(
|
|||||||
res = []
|
res = []
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'nodes.sql']),
|
"/".join([self.template_path, 'nodes.sql']),
|
||||||
jstid = jstid,
|
jstid=jstid,
|
||||||
jid = jid
|
jid=jid
|
||||||
)
|
)
|
||||||
|
|
||||||
status, result = self.conn.execute_2darray(sql)
|
status, result = self.conn.execute_2darray(sql)
|
||||||
@ -315,13 +315,16 @@ SELECT EXISTS(
|
|||||||
jid: Job ID
|
jid: Job ID
|
||||||
"""
|
"""
|
||||||
data = {}
|
data = {}
|
||||||
for k, v in request.args.items():
|
if request.args:
|
||||||
try:
|
for k, v in request.args.items():
|
||||||
data[k] = json.loads(
|
try:
|
||||||
v.decode('utf-8') if hasattr(v, 'decode') else v
|
data[k] = json.loads(
|
||||||
)
|
v.decode('utf-8') if hasattr(v, 'decode') else v
|
||||||
except ValueError:
|
)
|
||||||
data[k] = v
|
except ValueError:
|
||||||
|
data[k] = v
|
||||||
|
else:
|
||||||
|
data = json.loads(request.data.decode())
|
||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'create.sql']),
|
"/".join([self.template_path, 'create.sql']),
|
||||||
@ -337,8 +340,8 @@ SELECT EXISTS(
|
|||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'nodes.sql']),
|
"/".join([self.template_path, 'nodes.sql']),
|
||||||
jstid = res,
|
jstid=res,
|
||||||
jid = jid
|
jid=jid
|
||||||
)
|
)
|
||||||
status, res = self.conn.execute_2darray(sql)
|
status, res = self.conn.execute_2darray(sql)
|
||||||
|
|
||||||
@ -417,8 +420,8 @@ SELECT EXISTS(
|
|||||||
|
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'nodes.sql']),
|
"/".join([self.template_path, 'nodes.sql']),
|
||||||
jstid = jstid,
|
jstid=jstid,
|
||||||
jid = jid
|
jid=jid
|
||||||
)
|
)
|
||||||
status, res = self.conn.execute_2darray(sql)
|
status, res = self.conn.execute_2darray(sql)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ INSERT INTO pgagent.pga_schedule(
|
|||||||
{{ data.jscmonthdays|qtLiteral }}::boolean[],
|
{{ data.jscmonthdays|qtLiteral }}::boolean[],
|
||||||
-- Months
|
-- Months
|
||||||
{{ data.jscmonths|qtLiteral }}::boolean[]
|
{{ data.jscmonths|qtLiteral }}::boolean[]
|
||||||
) RETURNING jscid INTO scid;{% if 'jscexceptions' in data %}
|
) RETURNING jscid {% if not jid %}INTO scid;{% endif %}{% if 'jscexceptions' in data %}
|
||||||
{% for exc in data.jscexceptions %}
|
{% for exc in data.jscexceptions %}
|
||||||
|
|
||||||
{{ EXCEPTIONS.INSERT(None, exc) }}{% endfor %}{% endif %}
|
{{ EXCEPTIONS.INSERT(None, exc) }}{% endfor %}{% endif %}
|
||||||
|
@ -1,10 +1,2 @@
|
|||||||
{% import 'macros/pga_schedule.macros' as SCHEDULE %}
|
{% import 'macros/pga_schedule.macros' as SCHEDULE %}
|
||||||
DO $$
|
|
||||||
DECLARE
|
|
||||||
jscid integer;
|
|
||||||
BEGIN
|
|
||||||
{{ SCHEDULE.INSERT(jid, data) }}
|
{{ SCHEDULE.INSERT(jid, data) }}
|
||||||
END
|
|
||||||
$$ LANGUAGE 'plpgsql';{% if fetch_id %}
|
|
||||||
|
|
||||||
{{ SCHEDULE.FETCH_CURRENT() }}{% endif %}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user