diff --git a/ui/desktop/app/routes/scopes/scope/projects/sessions.js b/ui/desktop/app/routes/scopes/scope/projects/sessions.js index 799785f5b..a7ce4bff7 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/sessions.js +++ b/ui/desktop/app/routes/scopes/scope/projects/sessions.js @@ -4,6 +4,7 @@ import { task, timeout } from 'ember-concurrency'; import config from '../../../../config/environment'; import { action } from '@ember/object'; import { notifySuccess, notifyError } from 'core/decorators/notify'; +import { resourceFilterParam } from 'core/decorators/resource-filter-param'; const POLL_TIMEOUT_SECONDS = config.sessionPollingTimeoutSeconds; @@ -17,6 +18,8 @@ export default class ScopesScopeProjectsSessionsRoute extends Route { // =attributes + @resourceFilterParam(['active', 'pending', 'canceling', 'terminated']) status; + /** * A simple Ember Concurrency-based polling task that refreshes the route * every POLL_TIMEOUT_SECONDS seconds. This is necessary to display changes @@ -50,10 +53,11 @@ export default class ScopesScopeProjectsSessionsRoute extends Route { * @return {Promise{[{session: SessionModel, target: TargetModel}]}} */ async model() { + const { status } = this; const { id: scope_id } = this.modelFor('scopes.scope'); const { user_id } = this.session.data.authenticated; await this.store.query('target', { recursive: true, scope_id }); - return await this.resourceFilterStore.queryBy('session', { user_id }, { + return await this.resourceFilterStore.queryBy('session', { user_id , status }, { recursive: true, scope_id }); @@ -86,4 +90,22 @@ export default class ScopesScopeProjectsSessionsRoute extends Route { await session.cancelSession(); await this.ipc.invoke('stop', { session_id: session.id }); } + + /** + * Sets the specified resource filter field to the specified value. + * @param {string} field + * @param value + */ + @action + filterBy(field, value) { + this[field] = value; + } + + /** + * Clears and filter selections. + */ + @action + clearAllFilters() { + this.status = []; + } } diff --git a/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs b/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs index 49b3b5423..2ebe5491b 100644 --- a/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs +++ b/ui/desktop/app/templates/scopes/scope/projects/sessions/index.hbs @@ -9,9 +9,64 @@ + {{#if (feature-flag 'filter')}} + {{#if + (or + @model + (has-resource-filter-param-selections + 'scopes.scope.projects.sessions' + ) + ) + }} + + + {{#with + (resource-filter-param 'scopes.scope.projects.sessions' 'status') + as |filter| + }} + + + + + + + + {{/with}} + + {{#if + (has-resource-filter-param-selections + 'scopes.scope.projects.sessions' + ) + }} + {{t 'actions.clear-all-filters'}} + + {{/if}} + + + {{/if}} + {{/if}} {{#if this.sorted}} - @@ -87,9 +142,17 @@ {{/each}} - + {{else if (has-resource-filter-param-selections + 'scopes.scope.projects.sessions' + )}} + + + + {{t 'descriptions.no-results'}} + + + {{else}} - - {{/if}} - \ No newline at end of file