Skip to content

Commit

Permalink
Merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
turegjorup committed Oct 23, 2024
2 parents d6ee0be + d4d31a5 commit 5057edd
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 13 deletions.
6 changes: 4 additions & 2 deletions .docker/vhost.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ server {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://node:3000;
add_header Cache-Control "public, max-age=604800";
expires 7d;

add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
add_header Pragma "no-cache";
add_header Expires "0";
}

location /client/ws {
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

## Unreleased

## [2.1.1] - 2024-10-23

- [#138](https://github.com/os2display/display-client/pull/138)
- Avoided setting ER105 in url when no token exists in local storage.
- [#137](https://github.com/os2display/display-client/pull/137)
- Add `no-cache´ directive to nginx setup.

## [2.1.0] - 2024-10-23

- [#135](https://github.com/os2display/display-client/pull/135)
Expand Down
7 changes: 5 additions & 2 deletions infrastructure/itkdev/etc/confd/templates/default.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ server {
server_name localhost;
root /var/www/html;

add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
add_header Pragma "no-cache";
add_header Expires "0";

location {{ getenv "APP_SCREEN_CLIENT_PATH" "/" }} {
rewrite ^{{ getenv "APP_SCREEN_CLIENT_PATH" "/" }}(.*) /$1 break;
index index.html;
autoindex off;
add_header Cache-Control "public, max-age=604800";
expires 7d;

try_files $uri $uri/ =404;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ server {
server_name localhost;
root /var/www/html;

add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
add_header Pragma "no-cache";
add_header Expires "0";

location {{ getenv "APP_SCREEN_CLIENT_PATH" "/" }} {
rewrite ^{{ getenv "APP_SCREEN_CLIENT_PATH" "/" }}(.*) /$1 break;
index index.html;
autoindex off;
add_header Cache-Control "public, max-age=604800";
expires 7d;

try_files $uri $uri/ =404;
}

Expand Down
6 changes: 3 additions & 3 deletions public/online-check/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

body {
background-color: #333333;
background-color: #000000;
margin-top: 10%;
text-align: center;
font-family: Arial,Helvetica,sans-serif;
Expand Down Expand Up @@ -71,7 +71,7 @@

const checkOnlineStatus = async () => {
try {
const online = await fetch("1pixel.png?no_cache=" + Date.now());
const online = await fetch("1pixel.png?ts=" + Date.now());
return online.status >= 200 && online.status < 300; // either true or false
} catch (err) {
return false; // definitely offline
Expand All @@ -87,7 +87,7 @@
helpDisplay.textContent = "Redirecting to client...";

setTimeout(async () => {
window.location.assign("../");
window.location.assign("../?ts="+ Date.now());
}, 3000
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ body {
color: white;
padding: 0;
margin: 0;
font-family: monospace;
font-size: 2em;
}

.bind-key-container {
Expand Down
19 changes: 15 additions & 4 deletions src/service/token-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ class TokenService {
getExpireState = () => {
const expire = appStorage.getTokenExpire();
const issueAt = appStorage.getTokenIssueAt();
const token = appStorage.getToken();

if (expire === null) {
return constants.NO_EXPIRE;
}
if (issueAt === null) {
return constants.NO_ISSUED_AT;
}
if (token === null) {
return constants.NO_TOKEN;
}

const timeDiff = expire - issueAt;
const nowSeconds = Math.floor(new Date().getTime() / 1000);
Expand Down Expand Up @@ -121,11 +132,11 @@ class TokenService {
checkToken = () => {
const expiredState = this.getExpireState();

if (expiredState === constants.TOKEN_EXPIRED) {
if ([constants.NO_EXPIRE, constants.NO_ISSUED_AT, constants.NO_TOKEN].includes(expiredState)) {
// Ignore. No token saved in storage.
} else if (expiredState === constants.TOKEN_EXPIRED) {
statusService.setError(constants.ERROR_TOKEN_EXPIRED);
} else if (
expiredState === constants.TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED
) {
} else if (expiredState === constants.TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED) {
statusService.setError(
constants.ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED
);
Expand Down
3 changes: 3 additions & 0 deletions src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const constants = {
ERROR_RELEASE_FILE_NOT_LOADED: 'ER104', // Release file could not be loaded.
ERROR_TOKEN_EXPIRED: 'ER105', // Token is expired.
ERROR_TOKEN_VALID_SHOULD_HAVE_BEEN_REFRESHED: 'ER106', // Token is valid but should have been refreshed.
NO_TOKEN: 'NO_TOKEN',
NO_EXPIRE: 'NO_EXPIRE',
NO_ISSUED_AT: 'NO_ISSUED_AT',
};

export default constants;

0 comments on commit 5057edd

Please sign in to comment.