Fixed the warnings/errors reported by eslint for all the static

javascripts.
This commit is contained in:
Ashesh Vashi
2018-01-12 12:59:51 +05:30
parent b78b97d89b
commit c32eb6bd37
102 changed files with 25830 additions and 24548 deletions

View File

@@ -1,8 +1,11 @@
define('pgadmin.node.pga_schedule', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'sources/pgadmin', 'moment', 'pgadmin.browser', 'alertify',
'backform', 'pgadmin.backform'
], function(gettext, url_for, $, _, S, pgAdmin, moment, pgBrowser, Alertify, Backform) {
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'sources/pgadmin', 'moment', 'pgadmin.browser', 'alertify',
'pgadmin.backform', 'pgadmin.backgrid',
], function(
gettext, url_for, $, _, S, pgAdmin, moment, pgBrowser, Alertify, Backform,
Backgrid
) {
if (!pgBrowser.Nodes['coll-pga_schedule']) {
pgBrowser.Nodes['coll-pga_schedule'] =
@@ -11,7 +14,7 @@ define('pgadmin.node.pga_schedule', [
label: gettext('Schedules'),
type: 'coll-pga_schedule',
columns: ['jscid', 'jscname', 'jscenabled'],
hasStatistics: false
hasStatistics: false,
});
}
@@ -20,7 +23,7 @@ define('pgadmin.node.pga_schedule', [
var weekdays = [
gettext('Sunday'), gettext('Monday'), gettext('Tuesday'),
gettext('Wednesday'), gettext('Thursday'), gettext('Friday'),
gettext('Saturday')
gettext('Saturday'),
],
monthdays = [
gettext('1st'), gettext('2nd'), gettext('3rd'),
@@ -33,13 +36,13 @@ define('pgadmin.node.pga_schedule', [
gettext('22nd'), gettext('23rd'), gettext('24th'),
gettext('25th'), gettext('26th'), gettext('27th'),
gettext('28th'), gettext('29th'), gettext('30th'),
gettext('31st'), gettext('Last day')
gettext('31st'), gettext('Last day'),
],
months = [
gettext('January'), gettext('February'), gettext('March'),
gettext('April'), gettext('May'), gettext('June'),
gettext('July'), gettext('August'), gettext('September'),
gettext('October'), gettext('November'), gettext('December')
gettext('October'), gettext('November'), gettext('December'),
],
hours = [
gettext('00'), gettext('01'), gettext('02'), gettext('03'),
@@ -47,7 +50,7 @@ define('pgadmin.node.pga_schedule', [
gettext('08'), gettext('09'), gettext('10'), gettext('11'),
gettext('12'), gettext('13'), gettext('14'), gettext('15'),
gettext('16'), gettext('17'), gettext('18'), gettext('19'),
gettext('20'), gettext('21'), gettext('22'), gettext('23')
gettext('20'), gettext('21'), gettext('22'), gettext('23'),
],
minutes = [
gettext('00'), gettext('01'), gettext('02'), gettext('03'),
@@ -64,21 +67,21 @@ define('pgadmin.node.pga_schedule', [
gettext('44'), gettext('45'), gettext('46'), gettext('47'),
gettext('48'), gettext('49'), gettext('50'), gettext('51'),
gettext('52'), gettext('53'), gettext('54'), gettext('55'),
gettext('56'), gettext('57'), gettext('58'), gettext('59')
gettext('56'), gettext('57'), gettext('58'), gettext('59'),
],
AnyDatetimeCell = Backgrid.Extension.MomentCell.extend({
editor: Backgrid.Extension.DatetimePickerEditor,
render: function() {
this.$el.empty();
var model = this.model;
this.$el.text(this.formatter.fromRaw(model.get(this.column.get("name")), model) || gettext('<any>'));
this.$el.text(this.formatter.fromRaw(model.get(this.column.get('name')), model) || gettext('<any>'));
this.delegateEvents();
return this;
}
},
}),
DatetimeCell = Backgrid.Extension.MomentCell.extend({
editor: Backgrid.Extension.DatetimePickerEditor
editor: Backgrid.Extension.DatetimePickerEditor,
}),
BooleanArrayFormatter = function(selector, indexes) {
var self = this;
@@ -101,7 +104,7 @@ define('pgadmin.node.pga_schedule', [
}
return self.indexes ? resIdx : res.join(', ');
}
};
this.toRaw = function(d) {
if (!self.indexes)
return d;
@@ -111,14 +114,14 @@ define('pgadmin.node.pga_schedule', [
res.push(_.indexOf(d, String(i + 1)) != -1);
}
return res;
}
};
return self;
},
BooleanArrayOptions = function(ctrl) {
var selector = ctrl.field.get('selector'),
val = ctrl.model.get(ctrl.field.get('name')),
res = [];
val = ctrl.model.get(ctrl.field.get('name')),
res = [];
if (selector) {
res = _.map(
@@ -133,7 +136,7 @@ define('pgadmin.node.pga_schedule', [
defaults: {
jexid: undefined,
jexdate: null,
jextime: null
jextime: null,
},
idAttribute: 'jexid',
schema: [{
@@ -141,20 +144,20 @@ define('pgadmin.node.pga_schedule', [
editable: true, placeholder: gettext('<any>'),
cell: AnyDatetimeCell, options: {format: 'YYYY-MM-DD'},
displayFormat: 'YYYY-MM-DD', modelFormat: 'YYYY-MM-DD',
cellHeaderClasses:'width_percent_50', allowEmpty: true
cellHeaderClasses:'width_percent_50', allowEmpty: true,
},{
id: 'jextime', type: 'text', placeholder: gettext('<any>'),
label: gettext('Time'), editable: true, cell: AnyDatetimeCell,
options: {format: 'HH:mm'}, displayFormat: 'HH:mm',
modelFormat: 'HH:mm:ss', displayInUTC: false, allowEmpty: true,
cellHeaderClasses:'width_percent_50', modalInUTC: false
cellHeaderClasses:'width_percent_50', modalInUTC: false,
}],
validate: function() {
var self = this, exceptions = this.collection,
dates = {}, errMsg, hasExceptionErr = false,
d = (this.get('jexdate') || '<any>'),
t = this.get('jextime') || '<any>',
id = this.get('jexid') || this.cid;
errMsg, hasExceptionErr = false,
d = (this.get('jexdate') || '<any>'),
t = this.get('jextime') || '<any>',
id = this.get('jexid') || this.cid;
self.errorModel.unset('jscdate');
if (d == t && d == '<any>') {
@@ -169,17 +172,17 @@ define('pgadmin.node.pga_schedule', [
if (
d == (ex.get('jexdate') || '<any>') &&
t == (ex.get('jextime') || '<any>')
t == (ex.get('jextime') || '<any>')
) {
errMsg = gettext('Please specify unique set of exceptions.');
if (ex.errorModel.get('jscdate') != errMsg)
self.errorModel.set('jscdate', errMsg);
self.errorModel.set('jscdate', errMsg);
hasExceptionErr = true;
}
});
return errMsg;
}
},
});
pgBrowser.Nodes['pga_schedule'] = pgBrowser.Node.extend({
@@ -189,15 +192,13 @@ define('pgadmin.node.pga_schedule', [
hasSQL: true,
hasDepends: false,
hasStatistics: false,
canDrop: function(node) {
return true;
},
canDrop: true,
label: gettext('Schedule'),
node_image: 'icon-pga_schedule',
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
return;
return;
this.initialized = true;
@@ -205,17 +206,17 @@ define('pgadmin.node.pga_schedule', [
name: 'create_pga_schedule_on_job', node: 'pga_job', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Schedule...'),
icon: 'wcTabIcon icon-pga_schedule', data: {action: 'create'}
icon: 'wcTabIcon icon-pga_schedule', data: {action: 'create'},
},{
name: 'create_pga_schedule_on_coll', node: 'coll-pga_schedule', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Schedule...'),
icon: 'wcTabIcon icon-pga_schedule', data: {action: 'create'}
icon: 'wcTabIcon icon-pga_schedule', data: {action: 'create'},
},{
name: 'create_pga_schedule', node: 'pga_schedule', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Schedule...'),
icon: 'wcTabIcon icon-pga_schedule', data: {action: 'create'}
icon: 'wcTabIcon icon-pga_schedule', data: {action: 'create'},
}]);
},
model: pgBrowser.Node.Model.extend({
@@ -232,7 +233,7 @@ define('pgadmin.node.pga_schedule', [
jscmonths: _.map(months, function() { return false; }),
jschours: _.map(hours, function() { return false; }),
jscminutes: _.map(minutes, function() { return false; }),
jscexceptions: []
jscexceptions: [],
},
idAttribute: 'jscid',
parse: function(d) {
@@ -243,7 +244,7 @@ define('pgadmin.node.pga_schedule', [
d.jscexceptions.push({
'jexid': d.jexid[idx],
'jexdate': d.jexdate[idx],
'jextime': d.jextime[idx]
'jextime': d.jextime[idx],
});
}
}
@@ -255,15 +256,15 @@ define('pgadmin.node.pga_schedule', [
},
schema: [{
id: 'jscid', label: gettext('ID'), type: 'int',
cellHeaderClasses: 'width_percent_5', mode: ['properties']
cellHeaderClasses: 'width_percent_5', mode: ['properties'],
},{
id: 'jscname', label: gettext('Name'), type: 'text',
cellHeaderClasses: 'width_percent_45',
disabled: function() { return false; }
disabled: function() { return false; },
},{
id: 'jscenabled', label: gettext('Enabled?'), type: 'switch',
disabled: function() { return false; },
cellHeaderClasses: 'width_percent_5'
cellHeaderClasses: 'width_percent_5',
},{
id: 'jscstart', label: gettext('Start'), type: 'text',
control: 'datetimepicker', cell: DatetimeCell,
@@ -271,42 +272,42 @@ define('pgadmin.node.pga_schedule', [
displayFormat: 'YYYY-MM-DD HH:mm:ss Z',
modelFormat: 'YYYY-MM-DD HH:mm:ss Z', options: {
format: 'YYYY-MM-DD HH:mm:ss Z',
minDate: moment().add(0, 'm')
}, cellHeaderClasses: 'width_percent_25'
minDate: moment().add(0, 'm'),
}, cellHeaderClasses: 'width_percent_25',
},{
id: 'jscend', label: gettext('End'), type: 'text',
control: 'datetimepicker', cell: DatetimeCell,
disabled: function() { return false; }, displayInUTC: false,
displayFormat: 'YYYY-MM-DD HH:mm:ss Z', options: {
format: 'YYYY-MM-DD HH:mm:ss Z', useCurrent: false,
minDate: moment().add(0, 'm')
minDate: moment().add(0, 'm'),
}, cellHeaderClasses: 'width_percent_25',
modelFormat: 'YYYY-MM-DD HH:mm:ss Z'
modelFormat: 'YYYY-MM-DD HH:mm:ss Z',
},{
id: 'jscweekdays', label: gettext('Week days'), type: 'text',
control: Backform.Control.extend({
formatter: new BooleanArrayFormatter(weekdays, false)
}), mode: ['properties']
formatter: new BooleanArrayFormatter(weekdays, false),
}), mode: ['properties'],
},{
id: 'jscmonthdays', label: gettext('Month days'), type: 'text',
control: Backform.Control.extend({
formatter: new BooleanArrayFormatter(monthdays, false)
}), mode: ['properties']
formatter: new BooleanArrayFormatter(monthdays, false),
}), mode: ['properties'],
},{
id: 'jscmonths', label: gettext('Months'), type: 'text',
control: Backform.Control.extend({
formatter: new BooleanArrayFormatter(months, false)
}), mode: ['properties']
formatter: new BooleanArrayFormatter(months, false),
}), mode: ['properties'],
},{
id: 'jschours', label: gettext('Hours'), type: 'text',
control: Backform.Control.extend({
formatter: new BooleanArrayFormatter(hours, false)
}), mode: ['properties']
formatter: new BooleanArrayFormatter(hours, false),
}), mode: ['properties'],
},{
id: 'jscminutes', label: gettext('Minutes'), type: 'text',
control: Backform.Control.extend({
formatter: new BooleanArrayFormatter(minutes, false)
}), mode: ['properties']
formatter: new BooleanArrayFormatter(minutes, false),
}), mode: ['properties'],
},{
id: 'jscexceptions', label: gettext('Exceptions'), type: 'text',
control: Backform.Control.extend({
@@ -321,17 +322,17 @@ define('pgadmin.node.pga_schedule', [
for (; idx < rawData.length; idx++) {
d = rawData[idx];
if (idx)
res += ', ';
res += ', ';
res += '[' + String((d.jexdate || '') + ' ' + (d.jextime || '')).replace(/^\s+|\s+$/g, '') + ']';
}
return res;
}
this.toRaw = function(data) { return data; }
};
this.toRaw = function(data) { return data; };
return this;
}
}), mode: ['properties']
},
}), mode: ['properties'],
},{
type: 'nested', label: gettext('Days'), group: gettext('Repeat'),
mode: ['create', 'edit'],
@@ -343,13 +344,13 @@ define('pgadmin.node.pga_schedule', [
this.$el.prepend(
'<div class="set-group pg-el-xs-12 ' +
Backform.helpMessageClassName + '">' +
gettext('Schedules are specified using a <b>cron-style</b> format.<br/><ul><li>For each selected time or date element, the schedule will execute.<br/>e.g. To execute at 5 minutes past every hour, simply select 05 in the Minutes list box.<br/></li><li>Values from more than one field may be specified in order to further control the schedule.<br/>e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.</li><li>For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.</li></ul>') +
'</div>'
Backform.helpMessageClassName + '">' +
gettext('Schedules are specified using a <b>cron-style</b> format.<br/><ul><li>For each selected time or date element, the schedule will execute.<br/>e.g. To execute at 5 minutes past every hour, simply select 05 in the Minutes list box.<br/></li><li>Values from more than one field may be specified in order to further control the schedule.<br/>e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.</li><li>For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.</li></ul>') +
'</div>'
);
return res;
}
},
}),
schema:[{
id: 'jscweekdays', label: gettext('Week Days'), cell: 'select2',
@@ -362,11 +363,11 @@ define('pgadmin.node.pga_schedule', [
width: 'style',
dropdownAdapter: $.fn.select2.amd.require(
'select2/selectAllAdapter'
)
),
},
selector: weekdays,
formatter: new BooleanArrayFormatter(weekdays, true),
options: BooleanArrayOptions
options: BooleanArrayOptions,
},{
id: 'jscmonthdays', label: gettext('Month Days'), cell: 'select2',
group: gettext('Days'), control: 'select2',
@@ -378,10 +379,10 @@ define('pgadmin.node.pga_schedule', [
width: 'style',
dropdownAdapter: $.fn.select2.amd.require(
'select2/selectAllAdapter'
)
),
},
formatter: new BooleanArrayFormatter(monthdays, true),
selector: monthdays, options: BooleanArrayOptions
selector: monthdays, options: BooleanArrayOptions,
},{
id: 'jscmonths', label: gettext('Months'), cell: 'select2',
group: gettext('Days'), control: 'select2',
@@ -393,11 +394,11 @@ define('pgadmin.node.pga_schedule', [
width: 'style',
dropdownAdapter: $.fn.select2.amd.require(
'select2/selectAllAdapter'
)
),
},
formatter: new BooleanArrayFormatter(months, true),
selector: months, options: BooleanArrayOptions
}]
selector: months, options: BooleanArrayOptions,
}],
},{
type: 'nested', control: 'fieldset', label: gettext('Times'),
group: gettext('Repeat'), mode: ['create', 'edit'],
@@ -412,10 +413,10 @@ define('pgadmin.node.pga_schedule', [
width: 'style',
dropdownAdapter: $.fn.select2.amd.require(
'select2/selectAllAdapter'
)
),
},
formatter: new BooleanArrayFormatter(hours, true),
selector: hours, options: BooleanArrayOptions
selector: hours, options: BooleanArrayOptions,
},{
id: 'jscminutes', label: gettext('Minutes'), cell: 'select2',
group: gettext('Times'), control: 'select2',
@@ -427,26 +428,26 @@ define('pgadmin.node.pga_schedule', [
width: 'style',
dropdownAdapter: $.fn.select2.amd.require(
'select2/selectAllAdapter'
)
),
},
formatter: new BooleanArrayFormatter(minutes, true),
selector: minutes, options: BooleanArrayOptions
}]
selector: minutes, options: BooleanArrayOptions,
}],
},{
id: 'jscexceptions', type: 'collection', mode: ['edit', 'create'],
label: "", canEdit: false, model: ExceptionModel, canAdd: true,
label: '', canEdit: false, model: ExceptionModel, canAdd: true,
group: gettext('Exceptions'), canDelete: true,
cols: ['jexdate', 'jextime'], control: 'sub-node-collection'
cols: ['jexdate', 'jextime'], control: 'sub-node-collection',
},{
id: 'jscdesc', label: gettext('Comment'), type: 'multiline'
id: 'jscdesc', label: gettext('Comment'), type: 'multiline',
}],
validate: function(keys) {
validate: function() {
var val = this.get('jscname'),
errMsg = null;
errMsg = null, msg;
if (_.isUndefined(val) || _.isNull(val) ||
String(val).replace(/^\s+|\s+$/g, '') == '') {
var msg = gettext('Name cannot be empty.');
msg = gettext('Name cannot be empty.');
this.errorModel.set('jscname', msg);
errMsg = msg;
} else {
@@ -456,7 +457,7 @@ define('pgadmin.node.pga_schedule', [
val = this.get('jscstart');
if (_.isUndefined(val) || _.isNull(val) ||
String(val).replace(/^\s+|\s+$/g, '') == '') {
var msg = gettext('Please enter the start time.');
msg = gettext('Please enter the start time.');
this.errorModel.set('jscstart', msg);
errMsg = errMsg || msg;
} else {
@@ -466,7 +467,7 @@ define('pgadmin.node.pga_schedule', [
val = this.get('jscend');
if (_.isUndefined(val) || _.isNull(val) ||
String(val).replace(/^\s+|\s+$/g, '') == '') {
var msg = gettext('Please enter the end time.');
msg = gettext('Please enter the end time.');
this.errorModel.set('jscend', msg);
errMsg = errMsg || msg;
} else {
@@ -476,21 +477,22 @@ define('pgadmin.node.pga_schedule', [
// End time must be greater than Start time
if(!errMsg) {
var start_time = this.get('jscstart'),
end_time = this.get('jscend'), elapsed_time,
end_time = this.get('jscend'),
start_time_js = start_time.split(' '),
end_time_js = end_time.split(' ');
start_time_js = moment(start_time_js[0] + ' ' + start_time_js[1]);
end_time_js = moment(end_time_js[0] + ' ' + end_time_js[1]);
if(end_time_js.isBefore(start_time_js)) {
errMsg = gettext('Start time must be less than end time');
this.errorModel.set('jscstart', errMsg);
}
start_time_js = moment(start_time_js[0] + ' ' + start_time_js[1]);
end_time_js = moment(end_time_js[0] + ' ' + end_time_js[1]);
if(end_time_js.isBefore(start_time_js)) {
errMsg = gettext('Start time must be less than end time');
this.errorModel.set('jscstart', errMsg);
}
}
return errMsg;
}
})
},
}),
});
}

View File

@@ -1,19 +1,19 @@
define('pgadmin.node.pga_job', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'pgadmin.node.pga_jobstep', 'pgadmin.node.pga_schedule'
'pgadmin.node.pga_jobstep', 'pgadmin.node.pga_schedule',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
if (!pgBrowser.Nodes['coll-pga_job']) {
var pga_jobs = pgBrowser.Nodes['coll-pga_job'] =
pgBrowser.Nodes['coll-pga_job'] =
pgBrowser.Collection.extend({
node: 'pga_job',
label: gettext('pga_jobs'),
type: 'coll-pga_job',
columns: ['jobid', 'jobname', 'jobenabled', 'jlgstatus', 'jobnextrun', 'joblastrun', 'jobdesc'],
hasStatistics: false
hasStatistics: false,
});
};
}
if (!pgBrowser.Nodes['pga_job']) {
pgBrowser.Nodes['pga_job'] = pgBrowser.Node.extend({
@@ -26,9 +26,7 @@ define('pgadmin.node.pga_job', [
hasCollectiveStatistics: true,
width: '80%',
height: '80%',
canDrop: function(node) {
return true;
},
canDrop: true,
label: gettext('pgAgent Job'),
node_image: function() {
return 'icon-pga_job';
@@ -36,7 +34,7 @@ define('pgadmin.node.pga_job', [
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
return;
return;
this.initialized = true;
@@ -44,17 +42,17 @@ define('pgadmin.node.pga_job', [
name: 'create_pga_job_on_coll', node: 'coll-pga_job', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('pgAgent Job...'),
icon: 'wcTabIcon icon-pga_job', data: {action: 'create'}
icon: 'wcTabIcon icon-pga_job', data: {action: 'create'},
},{
name: 'create_pga_job', node: 'pga_job', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('pgAgent Job...'),
icon: 'wcTabIcon icon-pga_job', data: {action: 'create'}
icon: 'wcTabIcon icon-pga_job', data: {action: 'create'},
}, {
name: 'run_now_pga_job', node: 'pga_job', module: this,
applies: ['object', 'context'], callback: 'run_pga_job_now',
priority: 4, label: gettext('Run now'), data: {action: 'create'},
icon: 'fa fa-play-circle'
icon: 'fa fa-play-circle',
}]);
},
model: pgBrowser.Node.Model.extend({
@@ -72,80 +70,80 @@ define('pgadmin.node.pga_job', [
jobrunningat: undefined,
jobdesc: '',
jsteps: [],
jschedules: []
jschedules: [],
},
idAttribute: 'jobid',
parse: function() {
var d = pgBrowser.Node.Model.prototype.parse.apply(this, arguments);
if (d) {
d.jobrunningat = d.jaghostagent || gettext("Not running currently.");
d.jlgstatus = d.jlgstatus || gettext("Unknown");
d.jobrunningat = d.jaghostagent || gettext('Not running currently.');
d.jlgstatus = d.jlgstatus || gettext('Unknown');
}
return d;
},
schema: [{
id: 'jobname', label: gettext('Name'), type: 'text',
cellHeaderClasses: 'width_percent_30'
cellHeaderClasses: 'width_percent_30',
},{
id: 'jobid', label: gettext('ID'), mode: ['properties'],
type: 'int'
type: 'int',
},{
id: 'jobenabled', label: gettext('Enabled?'), type: 'switch',
cellHeaderClasses: 'width_percent_5'
cellHeaderClasses: 'width_percent_5',
},{
id: 'jobclass', label: gettext('Job class'), type: 'text',
mode: ['properties']
mode: ['properties'],
},{
id: 'jobjclid', label: gettext('Job class'), type: 'int',
control: 'node-ajax-options', url: 'classes', url_with_id: false,
cache_node: 'server', mode: ['create', 'edit'],
select2: {allowClear: false},
helpMessage: gettext('Please select a class to categorize the job. This option will not affect the way the job runs.')
helpMessage: gettext('Please select a class to categorize the job. This option will not affect the way the job runs.'),
},{
id: 'jobhostagent', label: gettext('Host agent'), type: 'text',
mode: ['edit', 'create'],
helpMessage: gettext('Enter the hostname of a machine running pgAgent if you wish to ensure only that machine will run this job. Leave blank if any host may run the job.')
helpMessage: gettext('Enter the hostname of a machine running pgAgent if you wish to ensure only that machine will run this job. Leave blank if any host may run the job.'),
},{
id: 'jobhostagent', label: gettext('Host agent'), type: 'text',
mode: ['properties']
mode: ['properties'],
},{
id: 'jobcreated', type: 'text', mode: ['properties'],
label: gettext('Created')
label: gettext('Created'),
},{
id: 'jobchanged', type: 'text', mode: ['properties'],
label: gettext('Changed')
label: gettext('Changed'),
},{
id: 'jobnextrun', type: 'text', mode: ['properties'],
label: gettext('Next run'), cellHeaderClasses: 'width_percent_20'
label: gettext('Next run'), cellHeaderClasses: 'width_percent_20',
},{
id: 'joblastrun', type: 'text', mode: ['properties'],
label: gettext('Last run'), cellHeaderClasses: 'width_percent_20'
label: gettext('Last run'), cellHeaderClasses: 'width_percent_20',
},{
id: 'jlgstatus', type: 'text', label: gettext('Last result'),
cellHeaderClasses: 'width_percent_5', mode: ['properties']
cellHeaderClasses: 'width_percent_5', mode: ['properties'],
},{
id: 'jobrunningat', type: 'text', mode: ['properties'],
label: gettext('Running at')
label: gettext('Running at'),
},{
id: 'jobdesc', label: gettext('Comment'), type: 'multiline',
cellHeaderClasses: 'width_percent_15'
cellHeaderClasses: 'width_percent_15',
},{
id: 'jsteps', label: '', group: gettext('Steps'),
type: 'collection', mode: ['edit', 'create'],
model: pgBrowser.Nodes['pga_jobstep'].model, canEdit: true,
control: 'sub-node-collection', canAdd: true, canDelete: true,
columns: [
'jstname', 'jstenabled', 'jstkind', 'jstconntype', 'jstonerror'
]
'jstname', 'jstenabled', 'jstkind', 'jstconntype', 'jstonerror',
],
},{
id: 'jschedules', label: '', group: gettext('Schedules'),
type: 'collection', mode: ['edit', 'create'],
control: 'sub-node-collection', canAdd: true, canDelete: true,
canEdit: true, model: pgBrowser.Nodes['pga_schedule'].model,
columns: ['jscname', 'jscenabled', 'jscstart', 'jscend']
columns: ['jscname', 'jscenabled', 'jscstart', 'jscend'],
}],
validate: function(keys) {
validate: function() {
var name = this.get('jobname');
if (_.isUndefined(name) || _.isNull(name) ||
String(name).replace(/^\s+|\s+$/g, '') == '') {
@@ -156,7 +154,7 @@ define('pgadmin.node.pga_job', [
this.errorModel.unset('jobname');
}
return null;
}
},
}),
/* Run pgagent job now */
run_pga_job_now: function(args) {
@@ -172,15 +170,15 @@ define('pgadmin.node.pga_job', [
$.ajax({
url: obj.generate_url(i, 'run_now', d, true),
method:'PUT',
success: function(res) {
// 'pgagent.pga_job' table updated with current time
// to run the job now.
t.unload(i);
},
error: function(xhr, status, error) {
var error_msg = "Unable to run pgagent job.";
// 'pgagent.pga_job' table updated with current time to run the job
// now.
success: function() { t.unload(i); },
error: function(xhr) {
var error_msg = gettext('Unable to run pgagent job.');
if (xhr.readyState == 0) {
alertify.error(gettext('Not connected to the server or the connection to the server has been closed.'));
alertify.error(
gettext('Not connected to the server or the connection to the server has been closed.')
);
}
else {
if (_.isUndefined(xhr.responseText)) {
@@ -194,7 +192,7 @@ define('pgadmin.node.pga_job', [
}
}
t.unload(i);
}
},
});
return false;

View File

@@ -1,7 +1,7 @@
define('pgadmin.node.pga_jobstep', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', 'backform',
'backgrid', 'pgadmin.backform', 'pgadmin.backgrid'
'backgrid', 'pgadmin.backform', 'pgadmin.backgrid',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, Backgrid) {
if (!pgBrowser.Nodes['coll-pga_jobstep']) {
@@ -12,9 +12,9 @@ define('pgadmin.node.pga_jobstep', [
type: 'coll-pga_jobstep',
columns: [
'jstid', 'jstname', 'jstenabled', 'jstkind', 'jstconntype',
'jstonerror'
'jstonerror',
],
hasStatistics: false
hasStatistics: false,
});
}
@@ -26,18 +26,18 @@ define('pgadmin.node.pga_jobstep', [
},
dependentChanged: function dependentChanged() {
var model = this.model,
column = this.column,
editable = this.column.get("editable"),
input = this.$el.find('input[type=checkbox]').first(),
self_name = column.get('name'),
is_editable;
column = this.column,
editable = this.column.get('editable'),
input = this.$el.find('input[type=checkbox]').first(),
self_name = column.get('name'),
is_editable;
is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) : !!editable;
if (is_editable) {
this.$el.addClass("editable");
this.$el.addClass('editable');
input.bootstrapSwitch('disabled', false);
} else {
this.$el.removeClass("editable");
this.$el.removeClass('editable');
input.bootstrapSwitch('disabled', true);
// Set self value into model
setTimeout(function () {
@@ -49,7 +49,7 @@ define('pgadmin.node.pga_jobstep', [
this.delegateEvents();
return this;
},
remove: Backgrid.Extension.DependentCell.prototype.remove
remove: Backgrid.Extension.DependentCell.prototype.remove,
});
if (!pgBrowser.Nodes['pga_jobstep']) {
@@ -63,9 +63,7 @@ define('pgadmin.node.pga_jobstep', [
hasCollectiveStatistics: true,
width: '70%',
height: '80%',
canDrop: function(node) {
return true;
},
canDrop: true,
label: gettext('Step'),
node_image: function() {
return 'icon-pga_jobstep';
@@ -73,7 +71,7 @@ define('pgadmin.node.pga_jobstep', [
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
return;
return;
this.initialized = true;
@@ -81,17 +79,17 @@ define('pgadmin.node.pga_jobstep', [
name: 'create_pga_jobstep_on_job', node: 'pga_job', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Job Step...'),
data: {'action': 'create'}, icon: 'wcTabIcon icon-pga_jobstep'
data: {'action': 'create'}, icon: 'wcTabIcon icon-pga_jobstep',
},{
name: 'create_pga_jobstep_on_coll', node: 'coll-pga_jobstep', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Job Step...'),
data: {'action': 'create'}, icon: 'wcTabIcon icon-pga_jobstep'
data: {'action': 'create'}, icon: 'wcTabIcon icon-pga_jobstep',
},{
name: 'create_pga_jobstep', node: 'pga_jobstep', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties',
category: 'create', priority: 4, label: gettext('Job Step...'),
data: {'action': 'create'}, icon: 'wcTabIcon icon-pga_jobstep'
data: {'action': 'create'}, icon: 'wcTabIcon icon-pga_jobstep',
}]);
},
model: pgBrowser.Node.Model.extend({
@@ -107,7 +105,7 @@ define('pgadmin.node.pga_jobstep', [
jstconnstr: null,
jstdbname: null,
jstonerror: 'f',
jstnextrun: ''
jstnextrun: '',
},
initialize: function() {
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
@@ -125,29 +123,28 @@ define('pgadmin.node.pga_jobstep', [
idAttribute: 'jstid',
schema: [{
id: 'jstid', label: gettext('ID'), type: 'int',
cellHeaderClasses: 'width_percent_5', mode: ['properties']
cellHeaderClasses: 'width_percent_5', mode: ['properties'],
},{
id: 'jstname', label: gettext('Name'), type: 'text',
disabled: function(m) { return false; },
cellHeaderClasses: 'width_percent_60'
disabled: false, cellHeaderClasses: 'width_percent_60',
},{
id: 'jstenabled', label: gettext('Enabled?'), type: 'switch',
disabled: function(m) { return false; }
disabled: function() { return false; },
},{
id: 'jstkind', label: gettext('Kind'), type: 'switch',
options: {
'onText': gettext('SQL'), 'offText': gettext('Batch'),
'onColor': 'primary', 'offColor': 'primary'
'onColor': 'primary', 'offColor': 'primary',
}, control: Backform.SwitchControl,
disabled: function(m) { return false; }
disabled: function() { return false; },
},{
id: 'jstconntype', label: gettext('Connection type'),
type: 'switch', deps: ['jstkind'], mode: ['properties'],
disabled: function(m) { return !m.get('jstkind'); },
options: {
'onText': gettext('Local'), 'offText': gettext('Remote'),
'onColor': 'primary', 'offColor': 'primary'
}
'onColor': 'primary', 'offColor': 'primary',
},
},{
id: 'jstconntype', label: gettext('Connection type'),
type: 'switch', deps: ['jstkind'], mode: ['create', 'edit'],
@@ -159,14 +156,14 @@ define('pgadmin.node.pga_jobstep', [
},
options: {
'onText': gettext('Local'), 'offText': gettext('Remote'),
'onColor': 'primary', 'offColor': 'primary'
}, helpMessage: gettext('Select <b>Local</b> if the job step will execute on the local database server, or <b>Remote</b> to specify a remote database server.')
'onColor': 'primary', 'offColor': 'primary',
}, helpMessage: gettext('Select <b>Local</b> if the job step will execute on the local database server, or <b>Remote</b> to specify a remote database server.'),
},{
id: 'jstdbname', label: gettext('Database'), type: 'text',
mode: ['properties'], disabled: function(m) { return false; }
mode: ['properties'], disabled: function() { return false; },
},{
id: 'jstconnstr', type: 'text', mode: ['properties'],
label: gettext('Connection string')
label: gettext('Connection string'),
},{
id: 'jstdbname', label: gettext('Database'), type: 'text',
control: 'node-list-by-name', node: 'database',
@@ -174,30 +171,30 @@ define('pgadmin.node.pga_jobstep', [
disabled: function(m) {
return !m.get('jstkind') || !m.get('jstconntype');
}, deps: ['jstkind', 'jstconntype'], mode: ['create', 'edit'],
helpMessage: gettext('Please select the database on which the job step will run.')
helpMessage: gettext('Please select the database on which the job step will run.'),
},{
id: 'jstconnstr', label: gettext('Connection string'), type: 'text',
deps: ['jstkind', 'jstconntype'], disabled: function(m) {
return !m.get('jstkind') || m.get('jstconntype');
}, helpMessage: S(
gettext("Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.<br>For more information, please see the documentation on %s")
gettext('Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = \'a value\'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.<br>For more information, please see the documentation on %s')
).sprintf(
'<a href="https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING" target="_blank">libpq connection strings</a>'
).value(), mode: ['create', 'edit']
).value(), mode: ['create', 'edit'],
},{
id: 'jstonerror', label: gettext('On error'), cell: 'select2',
control: 'select2', options: [
{'label': gettext('Fail'), 'value': "f"},
{'label': gettext('Success'), 'value': "s"},
{'label': gettext('Ignore'), 'value': "i"}
], select2: {allowClear: false}, disabled: function(m) {
{'label': gettext('Fail'), 'value': 'f'},
{'label': gettext('Success'), 'value': 's'},
{'label': gettext('Ignore'), 'value': 'i'},
], select2: {allowClear: false}, disabled: function() {
return false;
}
},
},{
id: 'jstdesc', label: gettext('Comment'), type: 'multiline'
id: 'jstdesc', label: gettext('Comment'), type: 'multiline',
},{
id: 'jstcode', label: '', cell: 'string', deps: ['jstkind'],
type: 'text', control: 'sql-field', group: gettext('Code'),
type: 'text', group: gettext('Code'),
control: Backform.SqlFieldControl.extend({
render: function() {
if (this.model.get('jstkind')) {
@@ -208,16 +205,16 @@ define('pgadmin.node.pga_jobstep', [
return Backform.SqlFieldControl.prototype.render.apply(
this, arguments
);
}
})
},
}),
}],
validate: function(keys) {
validate: function() {
var val = this.get('jstname'),
errMsg = null;
errMsg = null, msg;
if (
_.isUndefined(val) || _.isNull(val) ||
String(val).replace(/^\s+|\s+$/g, '') == ''
String(val).replace(/^\s+|\s+$/g, '') == ''
) {
errMsg = gettext('Name cannot be empty.');
this.errorModel.set('jstname', errMsg);
@@ -232,7 +229,7 @@ define('pgadmin.node.pga_jobstep', [
_.isUndefined(val) || _.isNull(val) ||
String(val).replace(/^\s+|\s+$/g, '') == ''
) {
var msg = gettext('Please select a database.');
msg = gettext('Please select a database.');
errMsg = errMsg || msg;
this.errorModel.set('jstdbname', msg);
} else {
@@ -240,8 +237,7 @@ define('pgadmin.node.pga_jobstep', [
}
} else {
this.errorModel.unset('jstdbname');
var msg,
r = /\s*\b(\w+)\s*=\s*('([^'\\]*(?:\\.[^'\\]*)*)'|[\w|\.]*)/g;
var r = /\s*\b(\w+)\s*=\s*('([^'\\]*(?:\\.[^'\\]*)*)'|[\w|\.]*)/g;
val = this.get('jstconnstr');
if (
_.isUndefined(val) || _.isNull(val) ||
@@ -252,18 +248,18 @@ define('pgadmin.node.pga_jobstep', [
msg = gettext('Please enter a valid connection string.');
} else {
var m,
params = {
'host': true, 'hostaddr': true, 'port': true,
'dbname': true, 'user': true, 'password': true,
'connect_timeout': true, 'client_encoding': true,
'application_name': true, 'options': true,
'fallback_application_name': true, 'sslmode': true,
'sslcert': true, 'sslkey': true, 'sslrootcert': true,
'sslcrl': true, 'keepalives': true, 'service': true,
'keepalives_idle': true, 'keepalives_interval': true,
'keepalives_count': true, 'sslcompression': true,
'requirepeer': true, 'krbsrvname': true, 'gsslib': true,
};
params = {
'host': true, 'hostaddr': true, 'port': true,
'dbname': true, 'user': true, 'password': true,
'connect_timeout': true, 'client_encoding': true,
'application_name': true, 'options': true,
'fallback_application_name': true, 'sslmode': true,
'sslcert': true, 'sslkey': true, 'sslrootcert': true,
'sslcrl': true, 'keepalives': true, 'service': true,
'keepalives_idle': true, 'keepalives_interval': true,
'keepalives_count': true, 'sslcompression': true,
'requirepeer': true, 'krbsrvname': true, 'gsslib': true,
};
while((m = r.exec(val))) {
if (params[m[1]]) {
@@ -295,9 +291,9 @@ define('pgadmin.node.pga_jobstep', [
val = this.get('jstcode');
if (
_.isUndefined(val) || _.isNull(val) ||
String(val).replace(/^\s+|\s+$/g, '') == ''
String(val).replace(/^\s+|\s+$/g, '') == ''
) {
var msg = gettext('Please specify code to execute.');
msg = gettext('Please specify code to execute.');
errMsg = errMsg || msg;
this.errorModel.set('jstcode', msg);
} else {
@@ -305,8 +301,8 @@ define('pgadmin.node.pga_jobstep', [
}
return errMsg;
}
})
},
}),
});
}