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

Commit

Permalink
Web portal: add "My jobs" filter button. (#2111)
Browse files Browse the repository at this point in the history
* Web portal: add "My jobs" filter button.

* reorder buttons in jobs page

* save my-jobs state to cookie, default show all jobs
  • Loading branch information
Gerhut authored Feb 12, 2019
1 parent 6b2842f commit 947de1f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/webportal/src/app/job/job-view/job-view.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const loadJobs = (specifiedVc) => {
return `<a class="table-job-name" href="view.html?username=${namespace || username}&jobName=${name}"><div class="table-job-name">${name}</div></a>`;
}
}},
{title: 'User', data: 'username', responsivePriority: 2},
{title: 'User', name: 'user', data: 'username', responsivePriority: 2},
{title: 'Virtual Cluster', data: 'virtualCluster', responsivePriority: 3, render(virtualCluster) {
let vcName = virtualCluster || 'default';
return '<a href="virtual-clusters.html?vcName=' + vcName + '">' + vcName + '</a>';
Expand Down Expand Up @@ -297,6 +297,46 @@ const loadJobs = (specifiedVc) => {
'<\'row\'<\'col-sm-12\'tr>>' +
'<\'row\'<\'col-sm-5\'i><\'col-sm-7\'p>>',
'buttons': [
{
// Show my jobs
text: 'My jobs',
enabled: (function() {
let token;
userAuth.checkToken(function(t) {
token = t;
}, false);
return Boolean(token);
}()),
init(dt, node) {
if (cookies.get('my-jobs')) {
if (!cookies.get('user')) {
cookies.remove('my-jobs');
} else {
dt.button(node).active(true);
dt.column('user:name').search(cookies.get('user'));
setTimeout(function() {
dt.draw();
}, 0);
}
}
},
action(e, dt, node) {
const button = dt.button(node);
if (button.active()) {
cookies.remove('my-jobs');
button.active(false);
dt.column('user:name').search('');
} else {
cookies.set('my-jobs', '1');
button.active(true);
dt.column('user:name').search(cookies.get('user'));
}
setTimeout(function() {
dt.draw();
}, 0);
},
},
'pageLength',
{
text: 'Select displayed jobs',
action: function(e, dt) {
Expand All @@ -320,7 +360,6 @@ const loadJobs = (specifiedVc) => {
}
},
},
'pageLength',
],
'select': {
style: 'multi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const userLogout = () => {
cookies.remove('token');
cookies.remove('admin');
cookies.remove('hasGitHubPAT');
cookies.remove('my-jobs');
window.location.replace('/login.html');
};

Expand Down

0 comments on commit 947de1f

Please sign in to comment.