Skip to content

Commit

Permalink
Add a simple admin UI to show the session length (#1203)
Browse files Browse the repository at this point in the history
Related to #604

Auto-merge
  • Loading branch information
Martii committed Oct 26, 2017
1 parent 01ff167 commit c91be85
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
31 changes: 30 additions & 1 deletion controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,39 @@ exports.adminProcessCloneView = function (aReq, aRes, aNext) {
isAdminProcessCloneView: true,
clone: clone
}

});
}

exports.adminSessionLengthView = function (aReq, aRes, aNext) {
if (!userIsAdmin(aReq)) {
statusCodePage(aReq, aRes, aNext, {
statusCode: 403,
statusMessage: 'This page is only accessible by admins.'
});
return;
}

aReq.sessionStore.length(function (aErr, aLength) {
if (aErr) {
statusCodePage(aReq, aRes, aNext, {
statusCode: 520,
statusMessage: 'Unknown error.'
});
return;
}

statusCodePage(aReq, aRes, aNext, {
statusCode: 200,
statusMessage: 'session length: ' + aLength,
isCustomView: true,
statusData: {
isAdminSessionLengthView: true,
length: aLength
}
});
});
};

// View everything about current deployed `./package.json`
exports.adminNpmPackageView = function (aReq, aRes, aNext) {
//
Expand Down
1 change: 1 addition & 0 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module.exports = function (aApp) {
aApp.route('/admin/git/short').get(admin.adminGitShortView);
aApp.route('/admin/git/branch').get(admin.adminGitBranchView);
aApp.route('/admin/process/clone').get(admin.adminProcessCloneView);
aApp.route('/admin/session/length').get(admin.adminSessionLengthView);
aApp.route('/admin/npm/package').get(admin.adminNpmPackageView);
aApp.route('/admin/npm/list').get(admin.adminNpmListView);
aApp.route('/admin/api').get(admin.adminApiKeysPage);
Expand Down
3 changes: 3 additions & 0 deletions views/pages/adminPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<a href="/admin/process/clone" class="list-group-item">
<i class="fa fa-fw fa-database"></i> Show clone
</a>
<a href="/admin/session/length" class="list-group-item">
<i class="fa fa-fw fa-database"></i> Show session length
</a>
<a href="/admin/npm/package" class="list-group-item">
<i class="fa fa-fw fa-database"></i> Raw <code>./package.json</code> JSON data
</a>
Expand Down
3 changes: 3 additions & 0 deletions views/pages/statusCodePage.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ <h1 class="status-code text-center">{{statusCode}}</h1>
{{#isAdminProcessCloneView}}
Clone: <strong>{{clone}}</strong>
{{/isAdminProcessCloneView}}
{{#isAdminSessionLengthView}}
Session Length: <strong>{{length}}</strong>
{{/isAdminSessionLengthView}}
{{/statusData}}
{{/isCustomView}}
{{^isCustomView}}
Expand Down

0 comments on commit c91be85

Please sign in to comment.