Skip to content

Commit c796df7

Browse files
committed
Patternfly-Upgrade
1 parent c556b41 commit c796df7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+722
-3435
lines changed

.env

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
12
BROWSER="chrome"
23

34
# Set CHRIS_UI_URL to the url of the running CUBE API
4-
VITE_CHRIS_UI_URL="https://cube.chrisproject.org/api/v1/"
5-
VITE_CHRIS_UI_USERS_URL="https://cube.chrisproject.org/api/v1/users/"
6-
VITE_CHRIS_UI_AUTH_URL="https://cube.chrisproject.org/api/v1/auth-token/"
5+
VITE_CHRIS_UI_URL="http://localhost:8000/api/v1/"
6+
VITE_CHRIS_UI_USERS_URL="http://localhost:8000/api/v1/users/"
7+
VITE_CHRIS_UI_AUTH_URL="http://localhost:8000/api/v1/auth-token/"
78
VITE_ALPHA_FEATURES='production'
89

910
# Set PFDCM_URL to the root url of the running pfdcm instance

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
legacy-peer-deps=true
1+
legacy-peer-deps=true

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ChRIS_ui production mode server
2+
#
3+
# Build with
4+
#
5+
# docker build -t <name> .
6+
#
7+
# For example if building a local version, you could do:
8+
#
9+
# docker build -t local/chris_ui .
10+
#
11+
# In the case of a proxy (located at say 10.41.13.4:3128), do:
12+
#
13+
# export PROXY="http://10.41.13.4:3128"
14+
# docker build --build-arg http_proxy=${PROXY} -t local/chris_ui .
15+
#
16+
# To run the server up, do:
17+
#
18+
# docker run --name chris_ui -p 3000:3000 -d local/chris_ui
19+
#
20+
# To run an interactive shell inside this container, do:
21+
#
22+
# docker exec -it chris_ui sh
23+
#
24+
# Tips:
25+
# - for access logging, remove "--quiet" from CMD
26+
# - docker-entrypoint.sh must start as root
27+
28+
29+
FROM node:20.7 as builder
30+
31+
WORKDIR /app
32+
COPY . .
33+
34+
RUN npm run -s print-version
35+
RUN npm install
36+
RUN npm run build
37+
38+
39+
FROM node:20.7-alpine
40+
41+
RUN yarn global add sirv-cli
42+
43+
WORKDIR /app
44+
45+
COPY --from=builder /app/build /app
46+
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
47+
48+
ENTRYPOINT ["/docker-entrypoint.sh"]
49+
ENV HOST=0.0.0.0 PORT=3000
50+
CMD ["sirv", "--quiet", "--etag", "--single"]
51+
EXPOSE 3000

Dockerfile_dev

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# Docker file for ChRIS ui development server
3+
#
4+
# Build with
5+
#
6+
# docker build -t <name>:<tag> -f <dockerfile> .
7+
#
8+
# For example if building a local version, you could do:
9+
#
10+
# docker build -t local/chris_ui:dev -f Dockerfile_dev .
11+
#
12+
# In the case of a proxy (located at say 10.41.13.4:3128), do:
13+
#
14+
# export PROXY="http://10.41.13.4:3128"
15+
# docker build --build-arg http_proxy=${PROXY} --build-arg UID=$UID -t local/chris_ui:dev -f Dockerfile_dev .
16+
#
17+
# To run the server up during development, do:
18+
#
19+
# docker run --rm -it -v $(pwd):/home/localuser -p 3000:3000 -u $(id -u):$(id -g) --name chris_ui local/chris_ui:dev
20+
#
21+
# To run an interactive shell inside this container, do:
22+
#
23+
# docker exec -it chris_ui sh
24+
#
25+
26+
27+
28+
FROM node:20.7 as builder
29+
MAINTAINER fnndsc "[email protected]"
30+
31+
# Pass a UID on build command line (see above) to set internal UID
32+
ARG UID=1001
33+
ENV UID=$UID HOME="/home/localuser" VERSION="0.1"
34+
35+
RUN adduser --uid $UID --disabled-password localuser \
36+
&& npm install chrome -g
37+
38+
# Start as user localuser
39+
USER localuser
40+
41+
WORKDIR $HOME
42+
EXPOSE 3000
43+
44+
CMD npm install && npm run dev

docker-entrypoint.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh -e
2+
# Motivation: `npm run build` is very slow, the fastest
3+
# way to get the UI up is `docker pull ... `
4+
# However, the backend url is built-in
5+
# to be http://localhost:8000/api/v1/
6+
# Purpose: Overwrite the URL of backend using a user-specified value.
7+
# `sed` is used to patch the `build/` directory.
8+
9+
target_cube='http://localhost:8000/api/v1/'
10+
target_pfdcm='http://localhost:4005/'
11+
given_cube="${REACT_APP_CHRIS_UI_URL-nil}"
12+
given_pfdcm="${REACT_APP_PFDCM_URL-nil}"
13+
14+
if [ "$(id -u)" != "0" ]; then
15+
if [ "$given_cube" != 'nil' ]; then
16+
echo "ERROR: custom value REACT_APP_CHRIS_UI_URL=$given_cube"
17+
echo "is set, but container user is not root."
18+
exit 1
19+
fi
20+
if [ "$given_pfdcm" != 'nil' ]; then
21+
echo "ERROR: custom value REACT_APP_PFDCM_URL=$given_pfdcm"
22+
echo "is set, but container user is not root."
23+
exit 1
24+
fi
25+
fi
26+
27+
# When running on Podman with default settings, the host IP address is added to /etc/hosts
28+
# by Podman by the name "host.containers.local" which we'll use as the IP address.
29+
if [ "${DISABLE_PODMAN_HOST_IP-no}" = 'no' ] \
30+
&& [ "$given_cube" = 'nil' ] \
31+
&& [ "$given_pfdcm" = 'nil' ]; then
32+
33+
PODMAN_HOST_IP="$(grep -m 1 -F host.containers.internal /etc/hosts | awk '{print $1}')"
34+
if [ -n "$PODMAN_HOST_IP" ]; then
35+
echo "Detected Podman host IP: $PODMAN_HOST_IP"
36+
given_cube="http://$PODMAN_HOST_IP:8000/api/v1/"
37+
given_pfdcm="http://$PODMAN_HOST_IP:4005/"
38+
fi
39+
fi
40+
41+
function replace () {
42+
local target="$1"
43+
local api_url="$2"
44+
45+
if [ "$api_url" != 'nil' ]; then
46+
for build_file in $(find -type f); do
47+
sed -i -e "s#$target#$api_url#g" $build_file
48+
done
49+
fi
50+
}
51+
52+
replace "$target_cube" "$given_cube"
53+
replace "$target_pfdcm" "$given_pfdcm"
54+
55+
exec "$@"

print_version.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# purpose: print out a version string: YYYYMMDD.X+commit(-dirty?)
3+
# YYYYMMDD = current date
4+
# X = number of merge commits since the tag version-0
5+
# commit = HEAD commit short sha
6+
# -drity = suffix indicating there are uncommitted changes
7+
8+
printf "%s.%s+%s%s" \
9+
"$(date '+%Y%m%d')" \
10+
"$(git rev-list --use-bitmap-index --count --merges version-0..HEAD)" \
11+
"$(git rev-parse --short HEAD)" \
12+
"$(git diff --quiet src/ || echo '-dirty')"

src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CookiesProvider } from "react-cookie";
99
import { RootState } from "./store/root/applicationState";
1010
import "@patternfly/react-core/dist/styles/base.css";
1111
import "./app.css";
12+
import "./components/Feeds/Feeds.css"
1213
import { ThemeContext } from "./components/DarkTheme/useTheme";
1314

1415
interface AllProps {

src/api/filesystem.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import ChrisAPIClient from "./chrisapiclient";
2+
import { fetchResource } from "./common";
3+
4+
export const ls = async (path?: string) => {
5+
let folders = [];
6+
let files = [];
7+
if (!path) return { folders, files };
8+
9+
try {
10+
const client = ChrisAPIClient.getClient();
11+
const uploads = await client.getFileBrowserPaths({
12+
path,
13+
});
14+
15+
16+
folders =
17+
uploads.data && uploads.data[0].subfolders
18+
? JSON.parse(uploads.data[0].subfolders)
19+
: [];
20+
const pathList = await client.getFileBrowserPath(path);
21+
22+
let files = [];
23+
if (pathList) {
24+
const pagination = {
25+
limit: 100,
26+
offset: 0,
27+
};
28+
const fn = pathList.getFiles;
29+
const boundFn = fn.bind(pathList);
30+
const data = await fetchResource(pagination, boundFn);
31+
files = data.resource;
32+
}
33+
return { folders, files };
34+
} catch (error) {
35+
return { folders, files };
36+
}
37+
};
38+
39+
export const mkdir = (path: string) => {
40+
console.log("Directory");
41+
};
42+
43+
export const find = async (space: string, search: string) => {
44+
const client = ChrisAPIClient.getClient();
45+
if (space === "feeds") {
46+
const payload = {
47+
limit: 10,
48+
offset: 0,
49+
files_fname_icontains: search,
50+
};
51+
const fn = client.getFeeds;
52+
const boundFn = fn.bind(client);
53+
return await fetchResource(payload, boundFn);
54+
}
55+
56+
if (space === "pacs") {
57+
const payload = {
58+
limit: 10,
59+
offset: 0,
60+
fname_icontains_topdir_unique: search,
61+
};
62+
const fn = client.getPACSFiles;
63+
const boundFn = fn.bind(client);
64+
return await fetchResource(payload, boundFn);
65+
}
66+
};
67+
68+
69+

src/app.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,29 @@
5757
.pf-v5-c-breadcrumb__item {
5858
font-size: inherit;
5959
}
60+
61+
62+
63+
.series-actions {
64+
margin: -1em -1em 1em -1em;
65+
height: 8em;
66+
overflow: hidden;
67+
position: relative;
68+
}
69+
70+
.action-button-container {
71+
position: absolute;
72+
top: 0;
73+
width: 100%;
74+
height: 100%;
75+
padding: 1em;
76+
text-align: center;
77+
}
78+
79+
.action-button-container[class~="hover"] {
80+
opacity: 0;
81+
transition: opacity 0.25s ease;
82+
&:hover {
83+
opacity: 1;
84+
}
85+
}

src/components/CreateFeed/ChooseConfig.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ const ChooseConfig = ({ handleFileUpload, user }: chooseConfigProps) => {
6262
setShowDragAndDrop(true);
6363
}
6464
},
65-
[]
65+
[],
6666
);
6767

6868
const handleKeyDown = useCallback(
6969
(e: any) => {
70-
if (e.target.closest("INPUT.required-params__textInput")) return;
70+
if (e.target.closest("INPUT")) return;
7171
switch (e.code) {
7272
case "KeyG":
7373
handleClick(e, "fs_plugin");
@@ -102,7 +102,7 @@ const ChooseConfig = ({ handleFileUpload, user }: chooseConfigProps) => {
102102
params?.required.length,
103103
requiredInput,
104104
selectedConfig,
105-
]
105+
],
106106
);
107107

108108
const onCloseClick = () => {
@@ -149,7 +149,7 @@ const ChooseConfig = ({ handleFileUpload, user }: chooseConfigProps) => {
149149
type: Types.SelectedConfig,
150150
payload: {
151151
selectedConfig: state.selectedConfig.filter(
152-
(value: string) => value !== "swift_storage"
152+
(value: string) => value !== "swift_storage",
153153
),
154154
},
155155
});
@@ -162,7 +162,7 @@ const ChooseConfig = ({ handleFileUpload, user }: chooseConfigProps) => {
162162
type: Types.SelectedConfig,
163163
payload: {
164164
selectedConfig: state.selectedConfig.filter(
165-
(value: any) => value !== "fs_plugin"
165+
(value: any) => value !== "fs_plugin",
166166
),
167167
},
168168
});
@@ -206,7 +206,7 @@ const ChooseConfig = ({ handleFileUpload, user }: chooseConfigProps) => {
206206
type: Types.SelectedConfig,
207207
payload: {
208208
selectedConfig: state.selectedConfig.filter(
209-
(value: any) => value !== "swift_storage"
209+
(value: any) => value !== "swift_storage",
210210
),
211211
},
212212
});

0 commit comments

Comments
 (0)