Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Web portal submit job: support init json from sessionStorage. (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhut authored Mar 5, 2019
1 parent 2429b23 commit 8cb09a1
Showing 1 changed file with 32 additions and 22 deletions.
54 changes: 32 additions & 22 deletions src/webportal/src/app/job/job-submit/job-submit.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,31 +160,41 @@ $(document).ready(() => {
resize();
};
const query = url.parse(window.location.href, true).query;
const op = query.op;
const type = query.type;
const username = query.user;
const jobname = query.jobname;
if (type != null && username != null && jobname != null) {
const url = username==''
? `${webportalConfig.restServerUri}/api/v1/jobs/${jobname}/config`
: `${webportalConfig.restServerUri}/api/v1/user/${username}/jobs/${jobname}/config`;
$.ajax({
url: url,
type: 'GET',
success: (data) => {
let jobConfigObj = JSON.parse(data);
let timestamp = Date.now();
jobConfigObj.jobName += `_${timestamp}`;
editor.setValue(Object.assign({}, jobDefaultConfig, jobConfigObj));
},
error: (xhr, textStatus, error) => {
const res = JSON.parse(xhr.responseText);
if (res.message === 'ConfigFileNotFound') {
alert('This job\'s config file has not been stored.');
} else {
alert('Error: ' + res.message);
}
},
});
if (op === 'resubmit') {
if (type != null && username != null && jobname != null) {
const url = username==''
? `${webportalConfig.restServerUri}/api/v1/jobs/${jobname}/config`
: `${webportalConfig.restServerUri}/api/v1/user/${username}/jobs/${jobname}/config`;
$.ajax({
url: url,
type: 'GET',
success: (data) => {
let jobConfigObj = JSON.parse(data);
let timestamp = Date.now();
jobConfigObj.jobName += `_${timestamp}`;
editor.setValue(Object.assign({}, jobDefaultConfig, jobConfigObj));
},
error: (xhr, textStatus, error) => {
const res = JSON.parse(xhr.responseText);
if (res.message === 'ConfigFileNotFound') {
alert('This job\'s config file has not been stored.');
} else {
alert('Error: ' + res.message);
}
},
});
}
} else if (op === 'init') {
try {
const jobConfigObj = JSON.parse(window.sessionStorage.getItem('init-job'));
editor.setValue(Object.assign({}, jobDefaultConfig, jobConfigObj));
} finally {
window.sessionStorage.removeItem('init-job');
}
}
});
});
Expand Down

0 comments on commit 8cb09a1

Please sign in to comment.