Skip to content

Commit be65173

Browse files
committed
remove data from base voltages config metadata
1 parent 478e1e8 commit be65173

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/services/appsMetadata.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
import { Metadata, StudyMetadata } from '../utils';
7+
import { BaseVoltageConfig, Metadata, StudyMetadata } from '../utils';
88

99
// https://github.com/gridsuite/deployment/blob/main/docker-compose/docker-compose.base.yml
1010
// https://github.com/gridsuite/deployment/blob/main/k8s/resources/common/config/apps-metadata.json
@@ -39,14 +39,21 @@ export function isStudyMetadata(metadata: Metadata): metadata is StudyMetadata {
3939

4040
export async function fetchStudyMetadata(): Promise<StudyMetadata> {
4141
console.info(`Fetching study metadata...`);
42-
const studyMetadata = (await fetchAppsMetadata()).filter(isStudyMetadata);
42+
const studyMetadata = (await fetchAppsMetadata()).find(isStudyMetadata);
4343
if (!studyMetadata) {
4444
throw new Error('Study entry could not be found in metadata');
4545
} else {
46-
return studyMetadata[0]; // There should be only one study metadata
46+
return studyMetadata; // There should be only one study metadata
4747
}
4848
}
4949

50+
export async function fetchBaseVoltagesConfig(): Promise<BaseVoltageConfig[]> {
51+
console.info(`Fetching apps' base voltages configuration...`);
52+
const env = await fetchEnv();
53+
const res = await fetch(`${env.appsMetadataServerUrl}/apps-metadata-base-voltages.json`);
54+
return res.json();
55+
}
56+
5057
export async function fetchFavoriteAndDefaultCountries(): Promise<{
5158
favoriteCountries: string[];
5259
defaultCountry?: string;

src/utils/types/metadata.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,20 @@ export type Metadata = {
1919
resources?: MetaDataRessources[];
2020
};
2121

22-
type ThemeColors = Record<string, string>;
22+
export type StudyMetadata = Metadata & {
23+
name: 'Study';
24+
predefinedEquipmentProperties?: {
25+
[networkElementType: string]: PredefinedProperties;
26+
};
27+
defaultParametersValues?: {
28+
enableDeveloperMode?: boolean;
29+
};
30+
defaultCountry?: string;
31+
favoriteCountries?: string[];
32+
substationPropertiesGlobalFilters?: Map<string, string[]>; // used to generate user specific global filters
33+
};
2334

35+
type ThemeColors = Record<string, string>;
2436
type SldAndNadColors = {
2537
darkThemeColors: ThemeColors;
2638
lightThemeColors: ThemeColors;
@@ -31,22 +43,7 @@ export type BaseVoltageConfig = {
3143
vlValue: number;
3244
minValue: number;
3345
maxValue: number;
34-
label: string;
3546
mapColor: string;
3647
sldAndNadColors: SldAndNadColors;
37-
profile: string;
38-
};
39-
40-
export type StudyMetadata = Metadata & {
41-
name: 'Study';
42-
predefinedEquipmentProperties?: {
43-
[networkElementType: string]: PredefinedProperties;
44-
};
45-
defaultParametersValues?: {
46-
enableDeveloperMode?: boolean;
47-
};
48-
defaultCountry?: string;
49-
favoriteCountries?: string[];
50-
substationPropertiesGlobalFilters?: Map<string, string[]>; // used to generate user specific global filters
51-
baseVoltagesConfig?: BaseVoltageConfig[]; // use to define the voltage ranges and their colors
5248
};
49+
export type BaseVoltagesConfig = BaseVoltageConfig[]; // used to define the voltage ranges and their colors

0 commit comments

Comments
 (0)