Files
threshold-ui/ui/desktop/app/controllers/scopes/scope/projects/sessions/index.js
T

24 lines
708 B
JavaScript
Raw Normal View History

import Controller from '@ember/controller';
export default class ScopesScopeProjectsSessionsIndexController extends Controller {
// =attributes
2021-02-11 10:44:48 -05:00
/**
* A list of sessions filtered to the current user and sorted by created time,
* and active/pending.
* @type {SessionModel[]}
*/
get sorted() {
const sessions = this.model;
const sortedSessions = sessions
2021-02-11 10:44:48 -05:00
// sort by created time
2021-03-05 17:49:47 -05:00
.sortBy('session.created_time')
.reverse();
return [
2021-02-11 10:44:48 -05:00
// then move active sessions to the top
...sortedSessions.filter((session) => session.isCancelable),
2021-02-11 10:44:48 -05:00
// and all others to the end
...sortedSessions.filter((session) => !session.isCancelable),
];
}
}