Skip to content

Commit b7dead5

Browse files
[O2B-1128] Implemented status history legend on environment overview (#1354)
* [O2B-1128] Implemented tooltip legend for status history on environment overview * [O2B-1128] moved multiple popover triggers into a single trigger * [O2B-1128] removed balloon check on statusHistory column because test expected a single popover trigger * [O2B-1128] incorporated the PR suggestions * [O2B-1128] fix typo * Minor improvements * Fix histogram * Display tooltip on the table header * Fix linter * Fix tests --------- Co-authored-by: Martin Boulais <31805063+martinboulais@users.noreply.github.com>
1 parent 623b24d commit b7dead5

14 files changed

Lines changed: 101 additions & 94 deletions

File tree

docs/data-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Concerning the **Update mode** of the fields:
196196
| `id` | Environment id | `Dxi029djX`, `EIDO13i3D` | AT COE | `id` | Insert |
197197
| `createdAt` | When the environment is created | | AT COE | `id` | Insert |
198198
| `toredownAt` | When the environment is stopped | | AT EOE | `id` | Update |
199-
| `status` | Actual status of the envrionment | `STOPPED`, `STARTED` | | `id` | Update |
199+
| `status` | Actual status of the envrionment | `DEPLOYED`, `STARTED` | | `id` | Update |
200200
| `statusMessage` | A bigger message to show more detail about the status | `Environment sucessfully closed`, `Error creating envrionment: bad configuration` | | `id` | Update |
201201

202202
### LhcFills

lib/database/seeders/20230124105627-environment-history.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
},
3636
{
3737
environment_id: 'TDI59So3d',
38-
status: 'STOPPED',
38+
status: 'DEPLOYED',
3939
status_message: 'Environment has been stopped',
4040
created_at: new Date('2019-08-09 18:00:00'),
4141
updated_at: new Date('2019-08-09 18:00:00'),

lib/public/app.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ html, body {
7171
.w-85 { width: 85%; }
7272
.w-90 { width: 90%; }
7373
.w-95 { width: 95%; }
74-
.w-100 { width: 100%; }
7574
.mw-100 { max-width: 100%; }
7675
.mh-100 { max-height: 100%; }
7776
.w-30rem { width: 30rem; }
@@ -82,6 +81,9 @@ html, body {
8281
width: unset;
8382
}
8483

84+
/* cursors */
85+
.cursor-info { cursor: help; }
86+
8587
/* specific margins */
8688
.ml1 { margin-left: var(--space-xs); }
8789
.ml2 { margin-left: var(--space-s); }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
import { tooltip } from './tooltip.js';
14+
import { h, info } from '/js/src/index.js';
15+
16+
/**
17+
* Display an info icon with a tooltip displayed on hover
18+
*
19+
* @param {Component} content the content of the help tooltip
20+
* @return {Component} the info icon with tooltip
21+
*/
22+
export const infoTooltip = (content) => tooltip(
23+
h('.cursor-help.h-100.w-100', { style: 'cursor: help' }, info()),
24+
content,
25+
);

lib/public/components/common/table/headers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ export const headers = (columns, models) => {
3232
const { sort: sortModel = null, filter: filterModel = null } = models || {};
3333

3434
return h('thead', h(`tr${isInlineFilter ? '.va-top' : ''}`, columns.map((column) => {
35-
const { size, name, sortable, key, inlineFilter } = column;
35+
const { size, name, sortable, key, inlineFilter, information } = column;
3636
const classes = [size || null, column.classes || null];
3737

3838
// Name needs to be empty for a popover, otherwise the name when hovering will be blocking the popover.
3939
const attributes = {
4040
scope: 'col',
41-
title: column.information ? '' : name,
41+
title: information || undefined,
4242
};
4343
let content = [name];
4444
if (sortModel && sortable) {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { coloredEnvironmentStatusComponent } from '../../views/Environments/ColoredEnvironmentStatusComponent.js';
15+
import { h } from '/js/src/index.js';
16+
import { STATUS_ACRONYMS } from '../../domain/enums/statusAcronyms.js';
17+
18+
/**
19+
* Returns a legend for the environment status history acronyms.
20+
*
21+
* @return {Component} the resulting environment status history legend component
22+
*/
23+
export const environmentStatusHistoryLegendComponent = () =>
24+
h('', [
25+
h('h5', 'Status History Legend'),
26+
Object.keys(STATUS_ACRONYMS).map((status) =>
27+
h('.flex-row.justify-between', [
28+
h('', status),
29+
h('', STATUS_ACRONYMS[status]),
30+
])),
31+
]);
32+
33+
/**
34+
* Returns a tooltip legend for the environment status history acronyms.
35+
*
36+
* @param {{status: string, acronym: string}[]} statusHistory list of history items (full status and their acronym)
37+
* @return {Component} the resulting environment status history component
38+
*/
39+
export const environmentStatusHistoryComponent = (statusHistory) => statusHistory.flatMap((value) => [
40+
coloredEnvironmentStatusComponent(value.status, value.acronym),
41+
'-',
42+
]).slice(0, -1);

lib/public/views/Environments/ActiveColumns/environmentsActiveColumns.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import { displayEnvironmentStatus } from '../format/displayEnvironmentStatus.js'
1818
import { buttonLinkWithDropdown } from '../../../components/common/selection/infoLoggerButtonGroup/buttonLinkWithDropdown.js';
1919
import { CopyToClipboardComponent } from '../../../components/common/selection/infoLoggerButtonGroup/CopyToClipboardComponent.js';
2020
import { infologgerLinksComponents } from '../../../components/common/infologger/infologgerLinksComponents.js';
21-
import { displayEnvironmentStatusHistory } from '../format/displayEnvironmentStatusHistory.js';
21+
import { coloredEnvironmentStatusComponent } from '../ColoredEnvironmentStatusComponent.js';
22+
import { STATUS_ACRONYMS } from '../../../domain/enums/statusAcronyms.js';
23+
import { environmentStatusHistoryLegendComponent } from '../../../components/environments/environmentStatusHistoryComponent.js';
24+
import { infoTooltip } from '../../../components/common/popover/infoTooltip.js';
2225

2326
/**
2427
* List of active columns for a generic Environments component
@@ -73,13 +76,16 @@ export const environmentsActiveColumns = {
7376
noEllipsis: true,
7477
format: (_, environment) => displayEnvironmentStatus(environment),
7578
},
76-
statusHistory: {
77-
name: 'Status History',
79+
historyItems: {
80+
name: h('.flex-row.g2.items-center', ['Status History', infoTooltip(environmentStatusHistoryLegendComponent())]),
7881
visible: true,
7982
sortable: false,
8083
size: 'w-20',
81-
title: true,
82-
format: (_, environment) => displayEnvironmentStatusHistory(environment),
84+
format: (historyItems) => historyItems
85+
.flatMap(({ status }) => [
86+
coloredEnvironmentStatusComponent(status, STATUS_ACRONYMS[status]),
87+
'-',
88+
]).slice(0, -1),
8389
balloon: true,
8490
},
8591
};

lib/public/views/Environments/ColoredEnvironmentStatusComponent.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,25 @@
1212
*/
1313

1414
import { h } from '/js/src/index.js';
15+
import { STATUS_ACRONYMS } from '../../domain/enums/statusAcronyms.js';
1516

1617
/**
1718
* Returns a component displaying a colored environment status
1819
*
1920
* @param {string} status The environment status color to display
2021
* @param {string} content Optional custom content to show in given status color
2122
*
22-
* @return {vnode} the formatted status
23+
* @return {Component} the formatted status
2324
*/
24-
export const coloredEnvironmentStatusComponent = (status, content = status) => h(statusToCssClassMapping[status] ?? '', content);
25+
export const coloredEnvironmentStatusComponent = (status, content = status) => {
26+
if (!(status in STATUS_ACRONYMS)) {
27+
return null;
28+
}
29+
return h('span', { class: statusToCssClassMapping[status] ?? '' }, content);
30+
};
2531

2632
const statusToCssClassMapping = {
27-
RUNNING: '.success',
28-
ERROR: '.danger',
29-
CONFIGURED: '.warning',
33+
RUNNING: 'success',
34+
ERROR: 'danger',
35+
CONFIGURED: 'warning',
3036
};

lib/public/views/Environments/format/displayEnvironmentStatusHistory.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

lib/public/views/Environments/format/displayEnvironmentStatusHistoryOverview.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)