Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/idpSettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"authority": "http://172.17.0.1:9090/",
"client_id": "my-client-2",
"client_id": "gridexplore-local",
"redirect_uri": "http://localhost:3000/sign-in-callback",
"post_logout_redirect_uri": "http://localhost:3000/logout-callback",
"silent_redirect_uri": "http://localhost:3000/silent-renew-callback",
Expand Down
5 changes: 5 additions & 0 deletions src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
CardErrorBoundary,
getPreLoginPath,
initializeAuthenticationProd,
useAnnouncementsSubscriber,
} from '@gridsuite/commons-ui';

import { useMatch } from 'react-router-dom';
Expand All @@ -39,6 +40,8 @@ import {
fetchConfigParameter,
fetchConfigParameters,
fetchValidateUser,
getAnnouncementsWsUrl,
getToken,
} from '../utils/rest-api';
import {
APP_NAME,
Expand Down Expand Up @@ -79,6 +82,8 @@ const App = () => {

const location = useLocation();

useAnnouncementsSubscriber(getAnnouncementsWsUrl(), getToken());

const updateParams = useCallback(
(params) => {
console.debug('received UI parameters : ', params);
Expand Down
22 changes: 14 additions & 8 deletions src/utils/rest-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const PREFIX_FILTERS_QUERIES =
process.env.REACT_APP_API_GATEWAY + '/filter/v1/filters';
const PREFIX_STUDY_QUERIES = process.env.REACT_APP_API_GATEWAY + '/study';

function getToken() {
export function getToken() {
const state = store.getState();
return state.user.id_token;
return state.user?.id_token;
}

export const getRequestParamFromList = (params, paramName) => {
Expand All @@ -41,10 +41,18 @@ export const getRequestParamFromList = (params, paramName) => {
);
};

export const getWsBase = () =>
document.baseURI
.replace(/^http:\/\//, 'ws://')
.replace(/^https:\/\//, 'wss://');

export function getAnnouncementsWsUrl() {
const webSocketBaseUrl = getWsBase();
return webSocketBaseUrl + PREFIX_CONFIG_NOTIFICATION_WS + '/global';
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be inlined

}

export function connectNotificationsWsUpdateConfig() {
const webSocketBaseUrl = document.baseURI
.replace(/^http:\/\//, 'ws://')
.replace(/^https:\/\//, 'wss://');
const webSocketBaseUrl = getWsBase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

const webSocketUrl =
webSocketBaseUrl +
PREFIX_CONFIG_NOTIFICATION_WS +
Expand Down Expand Up @@ -798,9 +806,7 @@ export function newScriptFromFiltersContingencyList(
* @returns {ReconnectingWebSocket}
*/
export function connectNotificationsWsUpdateDirectories() {
const webSocketBaseUrl = document.baseURI
.replace(/^http:\/\//, 'ws://')
.replace(/^https:\/\//, 'wss://');
const webSocketBaseUrl = getWsBase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

const webSocketUrl =
webSocketBaseUrl +
PREFIX_NOTIFICATION_WS +
Expand Down