Skip to content

Commit

Permalink
revert js changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhleviet committed Dec 13, 2024
1 parent befa43d commit cfa2b00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
49 changes: 24 additions & 25 deletions src/main/html/webapp/components/core/job/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,42 @@ import template from './list.stache';

export default Control.extend({

"init": function(element, options) {
"init": function (element, options) {

this.options.refreshers = [];

var that = this;
Job.findAll({
page: options.page
}, function(jobs) {
jobs.sort(Job.compare);

$.each(jobs, function(key, job) {
job.syncTime();
}, function (jobs) {
$.each(jobs, function (key, job) {
$.each(jobs, function (key, job) {
job.syncTime();
});
if (JobRefresher.needsUpdate(job)) {
var refresher = new JobRefresher(element);
refresher.setJob(job);
that.options.refreshers.push(refresher);
}
});

$(element).html(template({
jobs: jobs
}));
$('[data-toggle="tooltip"]').tooltip()

$(element).fadeIn();
}, function(response) {
}, function (response) {
new ErrorPage(element, response);
});

},

'.delete-btn click': function(el, ev) {
'.delete-btn click': function (el, ev) {

var card = $(el).closest('.card');
var job = domData.get.call(card[0], 'job');

bootbox.confirm("Are you sure you want to delete <b>" + job.attr('name') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to delete <b>" + job.attr('name') + "</b>?", function (result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand All @@ -59,9 +58,9 @@ export default Control.extend({
var cancelButton = $("button[data-bb-handler='cancel']");
cancelButton.hide('hide');

job.destroy(function() {
job.destroy(function () {
bootbox.hideAll();
}, function(response) {
}, function (response) {
bootbox.hideAll();
showErrorDialog("Job could not be deleted", response);
});
Expand All @@ -74,12 +73,12 @@ export default Control.extend({

},

'.cancel-btn click': function(el, ev) {
'.cancel-btn click': function (el, ev) {

var card = $(el).closest('.card');
var job = domData.get.call(card[0], 'job');

bootbox.confirm("Are you sure you want to cancel <b>" + job.attr('name') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to cancel <b>" + job.attr('name') + "</b>?", function (result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand All @@ -91,9 +90,9 @@ export default Control.extend({
var operation = new JobOperation();
operation.attr('id', job.attr('id'));
operation.attr('action', 'cancel');
operation.save(function() {
operation.save(function () {
bootbox.hideAll();
}, function(response) {
}, function (response) {
bootbox.hideAll();
showErrorDialog("Job could not be canceld", response);
});
Expand All @@ -105,10 +104,10 @@ export default Control.extend({

},

destroy: function() {
destroy: function () {

// stops all job refreshers!
$.each(this.options.refreshers, function(key, refresher) {
$.each(this.options.refreshers, function (key, refresher) {
refresher.stop();
});

Expand All @@ -119,37 +118,37 @@ export default Control.extend({

var JobRefresher = Control({

setJob: function(job) {
setJob: function (job) {
this.job = job;
this.active = true;
this.refresh();
},

refresh: function() {
refresh: function () {
var that = this;
Job.findOne({
id: that.job.id
}, function(currentJob) {
}, function (currentJob) {

currentJob.syncTime();

if (JobRefresher.needsUpdate(currentJob) && that.active) {
setTimeout(function() {
setTimeout(function () {
that.refresh();
}, 20000);
}
}, function(response) {
}, function (response) {
new ErrorPage(that.element, response);
});

},

stop: function() {
stop: function () {
this.active = false;
}

});

JobRefresher.needsUpdate = function(job) {
JobRefresher.needsUpdate = function (job) {
return job.attr("state") == 1 || job.attr("state") == 2 || job.attr("state") == 3;
};
4 changes: 0 additions & 4 deletions src/main/html/webapp/models/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export default Model.extend({
findOne: 'GET api/v2/jobs/{id}/status',
destroy: 'DELETE api/v2/jobs/{id}',
}, {
// Add compare function for client-side sorting
compare: function(a, b) {
return b.submittedOn - a.submittedOn;
},

'syncTime': function () {
if (this.attr('startTime') > 0 && this.attr('endTime') === 0) {
Expand Down

0 comments on commit cfa2b00

Please sign in to comment.