Skip to content

Commit 3cf45d9

Browse files
authored
fix frontend build (#187)
* remove dependencies on /scripts folder; rewrite build error logging * console.log the correct warning message * elasticsearch end point needs protocol * use document root when not setting hostname * misunderstood how keycloakBaseURL works
1 parent bd3dfa4 commit 3cf45d9

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

frontend/src/app.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface Config{
1313
}
1414

1515
const config:Config = <Config>{};
16-
const hostname = process.env.CLOWDER_REMOTE_HOSTNAME || "";
16+
const hostname = process.env.CLOWDER_REMOTE_HOSTNAME || `${window.location.protocol}//${window.location.host}`;
1717

1818
// TODO when add auth piece remove this env
1919
const apikey = process.env.APIKEY || "";
@@ -33,6 +33,6 @@ config["KeycloakRefresh"] = config.KeycloakBaseURL + "/refresh_token";
3333
config["KeycloakRegister"] = config.KeycloakBaseURL + "/register";
3434

3535
// elasticsearch
36-
config["searchEndpoint"] = config.hostname + "/api/v2/elasticsearch";
36+
config["searchEndpoint"] = `${hostname}/api/v2/elasticsearch`;
3737

3838
export default config;

frontend/src/components/metadata/CreateMetadata.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useEffect} from "react";
22
import {Box, Typography} from "@mui/material";
3-
import metadataConfig from "../../metadata.config";
3+
import {metadataConfig} from "../../metadata.config";
44
import {useSelector, useDispatch} from "react-redux";
55
import {RootState} from "../../types/data";
66
import {fetchMetadataDefinitions} from "../../actions/metadata";

frontend/src/components/metadata/CreateMetadataDefinition.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
88
import { postMetadataDefinitions } from "../../actions/metadata";
99
import Layout from "../Layout";
1010

11-
import widgetTypes from "../../../../scripts/metadata/config/widgetTypes.json";
12-
import inputTypes from "../../../../scripts/metadata/config/inputTypes.json";
11+
import {widgetTypes, inputTypes} from "../../metadata.config";
1312

1413
export const CreateMetadataDefinitionPage = (): JSX.Element => {
1514
return (
@@ -24,7 +23,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
2423
const dispatch = useDispatch();
2524
// @ts-ignore
2625
const saveMetadataDefinitions = (metadata: object) => dispatch(postMetadataDefinitions(metadata));
27-
26+
2827
const [activeStep, setActiveStep] = React.useState(0);
2928
const [parsedInput, setParsedInput] = React.useState("");
3029
const [formInput, setFormInput] = React.useState({
@@ -49,14 +48,14 @@ export const CreateMetadataDefinition = (): JSX.Element => {
4948
// Handle input change of name, description, context high level fields
5049
if (idx == -1) {
5150
data[key] = value
52-
51+
5352
} else {
5453
if (key == "list" || key == "required") {
5554
data["fields"][idx][key] = !data["fields"][idx][key]
56-
55+
5756
} else if (key == "type" || key == "options") {
5857
data["fields"][idx].config[key] = value
59-
58+
6059
} else if (key == "name" || key == "widgetType") {
6160
data["fields"][idx][key] = value
6261
}
@@ -78,7 +77,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
7877
}
7978

8079
let newfield = formInput["fields"]
81-
80+
8281
// Add newfield to ith idx of list
8382
newfield.splice(idx + 1, 0, newitem)
8483

@@ -270,10 +269,10 @@ export const CreateMetadataDefinition = (): JSX.Element => {
270269

271270
{formInput.fields.map((input, idx) => {
272271
return (<Step key={idx}>
273-
{idx == 0 ?
272+
{idx == 0 ?
274273
<StepButton color="inherit" onClick={() => {setActiveStep(idx + 1)}}>
275274
<StepLabel>Add metadata entry*
276-
{idx == activeStep - 1 ?
275+
{idx == activeStep - 1 ?
277276
<IconButton color="primary" size="small" onClick={() => addNewField(idx)}>
278277
<AddBoxIcon />
279278
</IconButton>
@@ -283,7 +282,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
283282
:
284283
<StepButton color="inherit" onClick={() => {setActiveStep(idx + 1)}}>
285284
<StepLabel>Add additional entry
286-
{idx == activeStep - 1 ?
285+
{idx == activeStep - 1 ?
287286
<>
288287
<IconButton color="primary" size="small" onClick={() => addNewField(idx)}>
289288
<AddBoxIcon />
@@ -292,7 +291,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
292291
<DeleteOutlineIcon />
293292
</IconButton>
294293
</>
295-
:
294+
:
296295
<IconButton size="small" onClick={() => removeField(idx)}>
297296
<DeleteOutlineIcon />
298297
</IconButton>}
@@ -303,11 +302,11 @@ export const CreateMetadataDefinition = (): JSX.Element => {
303302
<Grid container>
304303
<Grid xs={4} md={4}>
305304
<FormGroup row>
306-
<FormControlLabel control={<Checkbox
305+
<FormControlLabel control={<Checkbox
307306
checked={input.list}
308307
onChange={(event) => { handleInputChange(idx, "list", event.target.value); }}
309308
/>} label="Contains List" />
310-
<FormControlLabel control={<Checkbox
309+
<FormControlLabel control={<Checkbox
311310
checked={input.required}
312311
onChange={(event) => { handleInputChange(idx, "required", event.target.value); }}
313312
/>} label="Required" />
@@ -364,7 +363,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
364363
})}
365364
</TextField>
366365
{/*
367-
* TODO: Expand to support different config data type actions
366+
* TODO: Expand to support different config data type actions
368367
* https://github.com/clowder-framework/clowder2/issues/169
369368
*/}
370369
{(input.config.type == "enum") ? <>

frontend/src/components/metadata/DisplayMetadata.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useEffect} from "react";
22
import {Box, Grid, Typography} from "@mui/material";
3-
import metadataConfig from "../../metadata.config";
3+
import {metadataConfig} from "../../metadata.config";
44
import {useSelector, useDispatch} from "react-redux";
55
import {RootState} from "../../types/data";
66
import {fetchDatasetMetadata, fetchFileMetadata, fetchMetadataDefinitions} from "../../actions/metadata";

frontend/src/components/metadata/EditMetadata.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useEffect} from "react";
22
import {Box, Typography} from "@mui/material";
3-
import metadataConfig from "../../metadata.config";
3+
import {metadataConfig} from "../../metadata.config";
44
import {useSelector, useDispatch} from "react-redux";
55
import {RootState} from "../../types/data";
66
import {fetchDatasetMetadata, fetchFileMetadata, fetchMetadataDefinitions} from "../../actions/metadata";

frontend/src/metadata.config.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,28 @@ import {MetadataTextField} from "./components/metadata/widgets/MetadataTextField
33
import {MetadataDateTimePicker} from "./components/metadata/widgets/MetadataDateTimePicker";
44
import {MetadataSelect} from "./components/metadata/widgets/MetadataSelect";
55

6-
const configMetadata = {
6+
export const metadataConfig = {
77
"TextField": <MetadataTextField />,
88
"DateTimePicker": <MetadataDateTimePicker />,
99
"Select": <MetadataSelect />,
1010
// TODO need to write a fallback
1111
"NA": <MetadataTextField />
1212
};
1313

14-
export default configMetadata
14+
export const inputTypes = {
15+
"int": "Integer",
16+
"float": "Floating point",
17+
"str": "String",
18+
"bool": "Boolean",
19+
"date": "Date",
20+
"time": "Time",
21+
"dict": "Dictionary",
22+
"enum": "List",
23+
"tuple": "Tuple"
24+
}
25+
26+
export const widgetTypes ={
27+
"TextField": "Text Input",
28+
"DateTimePicker": "Date Time Picker",
29+
"Select": "Dropdown"
30+
}

frontend/tools/build.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ webpack(config).run((error, stats) => {
1919
const jsonStats = stats.toJson();
2020

2121
if (stats.hasErrors()) {
22-
return jsonStats.errors.map(error => console.log(chalkError(error)));
23-
}
22+
jsonStats.errors.map(error => console.log(chalkError(error['details'])));
23+
return jsonStats.errors.length;
24+
}
2425

2526
if (stats.hasWarnings()) {
2627
console.log(chalkWarning("Webpack generated the following warnings: "));
27-
jsonStats.warnings.map(warning => console.log(chalkWarning(warning)));
28+
jsonStats.warnings.map(warning => console.log(chalkWarning(warning['message'])));
2829
}
2930

3031
console.log(`Webpack stats: ${stats}`);

0 commit comments

Comments
 (0)