Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "about" window #56

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.8.2",
"@emotion/styled": "^11.8.1",
"@gridsuite/commons-ui": "^0.42.0",
"@gridsuite/commons-ui": "^0.43.0",
"@hookform/resolvers": "^3.3.1",
"@mui/icons-material": "^5.5.1",
"@mui/lab": "^5.0.0-alpha.75",
Expand Down
39 changes: 3 additions & 36 deletions src/components/app-top-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,43 +59,10 @@ const AppTopBar = ({ user, userManager }) => {
onLogoClick={() => navigate.replace('/')}
user={user}
appsAndUrls={appsAndUrls}
getGlobalVersion={(setGlobalVersion) =>
fetchVersion()
.then((res) => setGlobalVersion(res.deployVersion))
.catch((reason) => {
console.error(
'Error while fetching the version : ' + reason
);
setGlobalVersion(null);
})
}
getAdditionalModules={(setServers) =>
getServersInfos(user?.id_token)
.then((res) =>
setServers(
Object.entries(res).map(([name, infos]) => ({
name:
infos?.build?.name ||
infos?.build?.artifact ||
name,
type: 'server',
version: infos?.build?.version,
gitTag:
infos?.git?.tags ||
infos?.git?.commit?.id[
'describe-short'
],
}))
)
)
.catch((reason) => {
console.error(
'Error while fetching the servers infos : ' +
reason
);
setServers(null);
})
globalVersionPromise={() =>
fetchVersion().then((res) => res?.deployVersion)
}
additionalModulesPromise={getServersInfos}
onThemeClick={handleChangeTheme}
theme={themeLocal}
onLanguageClick={handleChangeLanguage}
Expand Down
9 changes: 7 additions & 2 deletions src/rest/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { backendFetchJson } from '../utils/rest-api';

const API_URL =
'/api/' +
(process.env.REACT_APP_USE_AUTHENTICATION === 'true'
? process.env.REACT_APP_API_GATEWAY + '/study/v1'
: process.env.REACT_APP_SRV_STUDY_URI + '/v1');

export function getServersInfos(token) {
return backendFetchJson(
`${API_URL}/servers/infos`,
`${API_URL}/servers/about`,
{
headers: {
Accept: 'application/json',
Expand All @@ -21,5 +23,8 @@ export function getServersInfos(token) {
cache: 'default',
},
token
);
).catch((reason) => {
console.error('Error while fetching the servers infos : ' + reason);
return reason;
});
}
6 changes: 5 additions & 1 deletion src/utils/rest-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ export function fetchVersion() {
console.info(`Fetching global metadata...`);
return fetchEnv()
.then((env) => fetch(env.appsMetadataServerUrl + '/version.json'))
.then((response) => response.json());
.then((response) => response.json())
.catch((reason) => {
console.error('Error while fetching the version : ' + reason);
return reason;
});
}

export function fetchAppsAndUrls() {
Expand Down
Loading