diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 609f74266..f787cf133 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -135,6 +135,11 @@ session: title_plural: Sessions active_plural: Active Sessions description: A session is a connection to a target initiated through Boundary. + status: + active: Active + pending: Pending + canceling: Canceling + terminated: Terminated messages: none: title: No Sessions diff --git a/ui/admin/app/routes/scopes/scope/sessions.js b/ui/admin/app/routes/scopes/scope/sessions.js index 2df7c8b4b..402704e55 100644 --- a/ui/admin/app/routes/scopes/scope/sessions.js +++ b/ui/admin/app/routes/scopes/scope/sessions.js @@ -6,6 +6,7 @@ import { task, timeout } from 'ember-concurrency'; import { A } from '@ember/array'; import { notifySuccess, notifyError } from 'core/decorators/notify'; import config from '../../../config/environment'; +import { resourceFilterParam } from 'core/decorators/resource-filter-param'; const POLL_TIMEOUT_SECONDS = config.sessionPollingTimeoutSeconds; @@ -16,9 +17,12 @@ export default class ScopesScopeSessionsRoute extends Route { @service intl; @service notify; @service session; + @service resourceFilterStore; // =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 @@ -53,7 +57,13 @@ export default class ScopesScopeSessionsRoute extends Route { */ async model() { const { id: scope_id } = this.modelFor('scopes.scope'); - const sessions = await this.store.query('session', { scope_id }); + const { status } = this; + const sessions = await this.resourceFilterStore.queryBy( + 'session', + { status }, + { scope_id } + ); + const sessionAggregates = await all( sessions.map(session => hash({ session, @@ -109,4 +119,21 @@ export default class ScopesScopeSessionsRoute extends Route { await session.cancelSession(); } + /** + * 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/admin/app/templates/scopes/scope/sessions/index.hbs b/ui/admin/app/templates/scopes/scope/sessions/index.hbs index 01aa8f737..d5052b1ee 100644 --- a/ui/admin/app/templates/scopes/scope/sessions/index.hbs +++ b/ui/admin/app/templates/scopes/scope/sessions/index.hbs @@ -13,21 +13,58 @@ - - {{#if @model}} - {{#if (feature-flag 'filter')}} + {{#if (feature-flag 'filter')}} + {{#if + (or + @model (has-resource-filter-param-selections 'scopes.scope.sessions') + ) + }} - -
+ + {{#with + (resource-filter-param 'scopes.scope.sessions' 'status') + as |filter| + }} -
+ as |dropdown| + > + + + + + + + {{/with}} + + {{#if + (has-resource-filter-param-selections 'scopes.scope.sessions') + }} + {{t 'actions.clear-all-filters'}} + + {{/if}}
{{/if}} - + {{/if}} + {{#if @model}} @@ -99,8 +136,15 @@ + {{else if (has-resource-filter-param-selections 'scopes.scope.sessions')}} + + + + {{t 'descriptions.no-results'}} + + + {{else}} - - {{/if}} -
- \ No newline at end of file