Skip to content

Commit b0f7402

Browse files
committed
1241: Fixed issues with screen status
1 parent e55675e commit b0f7402

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
55

66
## [Unreleased]
77

8+
- [#281](https://github.com/os2display/display-admin-client/pull/281)
9+
- Fixed screen status bugs.
810
- [#274](https://github.com/os2display/display-admin-client/pull/274)
911
- Added screen status to screen list.
1012
- Refactored screen status on screen edit.

src/components/screen/screen-status.jsx

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,70 @@ function ScreenStatus({ screen, handleInput = () => {}, mode = "default" }) {
124124
);
125125
}
126126

127+
if (
128+
status.releaseTimestamp === null ||
129+
status.releaseVersion === null ||
130+
status.latestRequestDateTime === null
131+
) {
132+
return (
133+
<FontAwesomeIcon
134+
icon={faInfoCircle}
135+
className="text-warning"
136+
title={t("no-info")}
137+
/>
138+
);
139+
}
140+
127141
const latestRequest = dayjs(status.latestRequestDateTime);
128-
const inOneHour = dayjs().add(1, "hours");
142+
const oneHourAgo = dayjs().subtract(1, "hours");
143+
144+
if (status?.clientMeta?.tokenExpired) {
145+
return (
146+
<FontAwesomeIcon
147+
icon={faExclamationCircle}
148+
className="text-danger"
149+
title={t("token-expired")}
150+
/>
151+
);
152+
}
129153

130-
if (status?.clientMeta?.tokenExpired || latestRequest > inOneHour) {
154+
if (latestRequest < oneHourAgo) {
131155
return (
132-
<FontAwesomeIcon icon={faExclamationCircle} className="text-danger" />
156+
<FontAwesomeIcon
157+
icon={faExclamationCircle}
158+
className="text-danger"
159+
title={t("no-communication-since", {
160+
ts: latestRequest.format("D/M YYYY HH:mm"),
161+
})}
162+
/>
133163
);
134164
}
135165

136166
if (clientRelease) {
137167
if (status?.releaseVersion !== clientRelease?.releaseVersion) {
138-
return <FontAwesomeIcon icon={faInfoCircle} className="text-warning" />;
168+
return (
169+
<FontAwesomeIcon
170+
icon={faInfoCircle}
171+
className="text-warning"
172+
title={t("release-warning")}
173+
/>
174+
);
139175
}
140176

141177
if (status?.releaseTimestamp !== clientRelease?.releaseTimestamp) {
142-
return <FontAwesomeIcon icon={faInfoCircle} className="text-warning" />;
178+
return (
179+
<FontAwesomeIcon
180+
icon={faInfoCircle}
181+
className="text-warning"
182+
title={t("release-warning")}
183+
/>
184+
);
143185
}
144186
}
145187

146188
return (
147189
<div>
148-
<FontAwesomeIcon icon={faCheckCircle} className="text-success" />
190+
<FontAwesomeIcon icon={faCheckCircle} className="text-success" title={t('ok')} />
149191
</div>
150192
);
151193
}
@@ -209,14 +251,14 @@ function ScreenStatus({ screen, handleInput = () => {}, mode = "default" }) {
209251
{status?.latestRequestDateTime && (
210252
<li>
211253
{t("latest-request")}:{" "}
212-
{dayjs(status?.latestRequestDateTime).format(
254+
{dayjs(status.latestRequestDateTime).format(
213255
"D/M YYYY HH:mm"
214256
)}
215257
</li>
216258
)}
217259
{status?.releaseVersion && (
218260
<li>
219-
{t("release-version")}: {status?.releaseVersion}
261+
{t("release-version")}: {status.releaseVersion}
220262
{notRunningLatestRelease && (
221263
<>
222264
{" "}
@@ -228,7 +270,7 @@ function ScreenStatus({ screen, handleInput = () => {}, mode = "default" }) {
228270
{status?.releaseTimestamp && (
229271
<li>
230272
{t("release-timestamp")}:{" "}
231-
{dayjs(status?.releaseTimestamp * 1000).format(
273+
{dayjs(status.releaseTimestamp * 1000).format(
232274
"D/M YYYY HH:mm"
233275
)}
234276
{notRunningLatestRelease && (

src/components/screen/util/campaign-icon.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
* @param {number} props.delay Delay the fetch.
2020
* @returns {object} The campaign icon.
2121
*/
22-
function CampaignIcon({ id, delay }) {
22+
function CampaignIcon({ id, delay = 1000 }) {
2323
const { t } = useTranslation("common", { keyPrefix: "campaign-icon" });
2424
const dispatch = useDispatch();
2525
const [isOverriddenByCampaign, setIsOverriddenByCampaign] = useState(null);
@@ -103,10 +103,6 @@ function CampaignIcon({ id, delay }) {
103103
: t("not-overridden-by-campaign");
104104
}
105105

106-
CampaignIcon.defaultProps = {
107-
delay: 1000,
108-
};
109-
110106
CampaignIcon.propTypes = {
111107
id: PropTypes.string.isRequired,
112108
delay: PropTypes.number,

src/components/util/list/list.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ function List({
227227
switch (screenStatusParam) {
228228
case "active":
229229
setExists({ screenUser: true });
230-
setScreenUserLatestRequest({ after: anHourAgo.valueOf() });
230+
setScreenUserLatestRequest({ after: anHourAgo.toISOString() });
231231
break;
232232
case "inactive":
233233
setExists({ screenUser: true });
234-
setScreenUserLatestRequest({ before: anHourAgo.valueOf() });
234+
setScreenUserLatestRequest({ before: anHourAgo.toISOString() });
235235
break;
236236
case "not-connected":
237237
setExists({ screenUser: false });

src/translations/da/common.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
"latest-release-timestamp": "Seneste udgivelsestidspunkt",
8181
"latest-request-warning": "Skærmen har ikke kommunikeret i mere end en time.",
8282
"release-warning": "Skærmen kører ikke seneste udgivelse.",
83-
"newest": "Nyeste"
83+
"newest": "Nyeste",
84+
"no-info": "Endnu ikke aktiv",
85+
"no-communication-since": "Inaktiv siden: {{ts}}",
86+
"ok": "Aktiv"
8487
},
8588
"screen-list": {
8689
"columns": {
@@ -118,7 +121,7 @@
118121
},
119122
"roles": {
120123
"ROLE_USER": "Bruger",
121-
"ROLE_SCREEN": "Skærm",
124+
"ROLE_SCREEN": "Skærm",
122125
"ROLE_EDITOR": "Redaktør",
123126
"ROLE_EXTERNAL_USER": "Ekstern bruger",
124127
"ROLE_EXTERNAL_USER_ADMIN": "Ekstern brugeradministrator",
@@ -380,7 +383,7 @@
380383
"published": "Udgivet",
381384
"number-of-slides": "Slides tilknyttede"
382385
},
383-
"more-playlists":"Hent flere spillelister",
386+
"more-playlists": "Hent flere spillelister",
384387
"edit-playlists-help-text": "Hvis du vil redigere en spilleliste, åbnes dette i en ny fane.",
385388
"remove-from-list": "Fjern fra liste",
386389
"info-modal": {

0 commit comments

Comments
 (0)