Icu 11915 add session in progress field to the table and populate it (#2028)
* initial support for sessions in targets list view
This commit is contained in:
1 parent
7af8e71a2d
commit
f801f595f7
7 files changed
+81
-23
No files matched your search
@@ -569,6 +569,7 @@ target:
|
||||
description: Sorry, we weren't able to find any targets for "{query}".
|
||||
titles:
|
||||
new: New Target
|
||||
active-sessions: Active sessions
|
||||
actions:
|
||||
create: New Target
|
||||
delete: Delete Target
|
||||
|
||||
@@ -27,6 +27,7 @@ export default class ScopesScopeProjectsTargetsIndexController extends Controlle
|
||||
@tracked scopes = [];
|
||||
@tracked page = 1;
|
||||
@tracked pageSize = 10;
|
||||
@tracked sessionsFlyoutActive = false;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -159,6 +160,11 @@ export default class ScopesScopeProjectsTargetsIndexController extends Controlle
|
||||
this.page = 1;
|
||||
}
|
||||
|
||||
@action
|
||||
toggleSessionsFlyout() {
|
||||
this.sessionsFlyoutActive = !this.sessionsFlyoutActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scopes query param to value of selectedScopes
|
||||
* to trigger a query and closes the dropdown
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import {
|
||||
STATUS_SESSION_ACTIVE,
|
||||
STATUS_SESSION_PENDING,
|
||||
} from 'api/models/session';
|
||||
|
||||
export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
|
||||
// =services
|
||||
@@ -73,6 +78,24 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
|
||||
this.can.can('connect target', target),
|
||||
);
|
||||
|
||||
// Retrieve all the 'active' and 'pending' sessions associated with each target.
|
||||
let targetsWithSessions = [];
|
||||
for (const target of targets) {
|
||||
let sessions = await this.store.query('session', {
|
||||
query: {
|
||||
filters: {
|
||||
target_id: { equals: target.id },
|
||||
status: [
|
||||
{ equals: STATUS_SESSION_ACTIVE },
|
||||
{ equals: STATUS_SESSION_PENDING },
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
sessions = orderBy(sessions, 'created_time', 'desc');
|
||||
targetsWithSessions.push({ target, sessions });
|
||||
}
|
||||
|
||||
// Query all targets for defining filtering values
|
||||
const options = { pushToStore: false };
|
||||
let allTargets = await this.store.query('target', {}, options);
|
||||
@@ -82,6 +105,6 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
|
||||
target.authorized_actions.includes('authorize-session'),
|
||||
);
|
||||
|
||||
return { targets, projects, allTargets, totalItems };
|
||||
return { targets: targetsWithSessions, projects, allTargets, totalItems };
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@
|
||||
@columns={{array
|
||||
(hash label=(t 'form.name.label'))
|
||||
(hash label=(t 'form.id.label'))
|
||||
(hash label=(t 'resources.target.titles.active-sessions'))
|
||||
(hash label=(t 'form.type.label'))
|
||||
(hash label=(t 'resources.project.title'))
|
||||
(hash label='')
|
||||
@@ -78,47 +79,59 @@
|
||||
<B.Tr>
|
||||
<B.Td>
|
||||
<span class='hds-font-weight-semibold'>
|
||||
{{#if (can 'read model' B.data)}}
|
||||
{{#if (can 'read model' B.data.target)}}
|
||||
<LinkTo
|
||||
data-test-visit-target={{B.data.id}}
|
||||
data-test-visit-target={{B.data.target.id}}
|
||||
@route='scopes.scope.projects.targets.target'
|
||||
@model={{B.data.id}}
|
||||
@model={{B.data.target.id}}
|
||||
@query={{hash isConnecting=false}}
|
||||
>
|
||||
{{B.data.displayName}}
|
||||
{{B.data.target.displayName}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
{{B.data.displayName}}
|
||||
{{B.data.target.displayName}}
|
||||
{{/if}}
|
||||
{{#if B.data.description}}
|
||||
<p>{{B.data.description}}</p>
|
||||
{{#if B.data.target.description}}
|
||||
<p>{{B.data.target.description}}</p>
|
||||
{{/if}}
|
||||
</span>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<Copyable
|
||||
@text={{B.data.id}}
|
||||
@text={{B.data.target.id}}
|
||||
@buttonText={{t 'actions.copy-to-clipboard'}}
|
||||
@acknowledgeText={{t 'states.copied'}}
|
||||
>
|
||||
<code>{{B.data.id}}</code>
|
||||
<code>{{B.data.target.id}}</code>
|
||||
</Copyable>
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
{{#if B.data.type}}
|
||||
{{#if B.data.sessions.length}}
|
||||
<Hds::Button
|
||||
@text={{t 'actions.yes'}}
|
||||
@color='tertiary'
|
||||
@icon='info'
|
||||
{{on 'click' this.toggleSessionsFlyout}}
|
||||
/>
|
||||
{{/if}}
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
{{#if B.data.target.type}}
|
||||
<Hds::Badge
|
||||
@text={{t (concat 'resources.target.types.' B.data.type)}}
|
||||
@text={{t
|
||||
(concat 'resources.target.types.' B.data.target.type)
|
||||
}}
|
||||
/>
|
||||
{{/if}}
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
<div>
|
||||
<Copyable
|
||||
@text={{B.data.project.id}}
|
||||
@text={{B.data.target.project.id}}
|
||||
@buttonText={{t 'actions.copy-to-clipboard'}}
|
||||
@acknowledgeText={{t 'states.copied'}}
|
||||
>
|
||||
<code>{{B.data.project.id}}</code>
|
||||
<code>{{B.data.target.project.id}}</code>
|
||||
</Copyable>
|
||||
</div>
|
||||
{{#if B.data.project.name}}
|
||||
@@ -126,22 +139,22 @@
|
||||
{{/if}}
|
||||
</B.Td>
|
||||
<B.Td>
|
||||
{{#if (can 'connect target' B.data)}}
|
||||
{{#if (can 'read target' B.data)}}
|
||||
{{#if (can 'connect target' B.data.target)}}
|
||||
{{#if (can 'read target' B.data.target)}}
|
||||
<Hds::Button
|
||||
data-test-targets-connect-button={{B.data.id}}
|
||||
data-test-targets-connect-button={{B.data.target.id}}
|
||||
@text={{t 'resources.session.actions.connect'}}
|
||||
@color='secondary'
|
||||
@route='scopes.scope.projects.targets.target'
|
||||
@model={{B.data.id}}
|
||||
@model={{B.data.target.id}}
|
||||
@query={{hash isConnecting=true}}
|
||||
/>
|
||||
{{else}}
|
||||
<Hds::Button
|
||||
data-test-targets-connect-button={{B.data.id}}
|
||||
data-test-targets-connect-button={{B.data.target.id}}
|
||||
@text={{t 'resources.session.actions.connect'}}
|
||||
@color='secondary'
|
||||
{{on 'click' (fn this.quickConnect B.data)}}
|
||||
{{on 'click' (fn this.quickConnect B.data.target)}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@@ -131,7 +131,7 @@ module('Acceptance | projects | targets | index', function (hooks) {
|
||||
setDefaultClusterUrl(this);
|
||||
|
||||
this.ipcStub.withArgs('isClientDaemonRunning').returns(true);
|
||||
this.stubClientDaemonSearch('targets', 'targets');
|
||||
this.stubClientDaemonSearch('targets', 'targets', 'sessions');
|
||||
});
|
||||
|
||||
test('visiting index while unauthenticated redirects to global authenticate method', async function (assert) {
|
||||
|
||||
@@ -124,7 +124,14 @@ module('Acceptance | projects | targets | target', function (hooks) {
|
||||
setDefaultClusterUrl(this);
|
||||
|
||||
this.ipcStub.withArgs('isClientDaemonRunning').returns(true);
|
||||
this.stubClientDaemonSearch('targets', 'targets');
|
||||
this.stubClientDaemonSearch(
|
||||
'targets',
|
||||
'targets',
|
||||
'targets',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
);
|
||||
});
|
||||
|
||||
test('user can connect to a target with an address', async function (assert) {
|
||||
|
||||
@@ -129,7 +129,7 @@ module('Acceptance | scopes', function (hooks) {
|
||||
setDefaultClusterUrl(this);
|
||||
|
||||
this.ipcStub.withArgs('isClientDaemonRunning').returns(true);
|
||||
this.stubClientDaemonSearch('targets', 'targets');
|
||||
this.stubClientDaemonSearch('targets', 'targets', 'sessions');
|
||||
});
|
||||
|
||||
test('visiting index', async function (assert) {
|
||||
@@ -189,6 +189,14 @@ module('Acceptance | scopes', function (hooks) {
|
||||
'targets',
|
||||
'targets',
|
||||
'targets',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
'sessions',
|
||||
);
|
||||
await visit(urls.targets);
|
||||
|
||||
|
||||
Reference in new issue
Block a user