Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #124 from att/static-web-page/US63/conditional-mai…
Browse files Browse the repository at this point in the history
…n-page

Static web page/us63/conditional main page
  • Loading branch information
yeudit authored Feb 18, 2024
2 parents f82f8a4 + 7fba709 commit 026de17
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v2

- name: Build Docker image
run: docker build ./portal --file ./portal/Dockerfile --tag my-website-image
run: docker build ./portal --file ./portal/Dockerfile --build-arg BUILD_ENV=gh-pages --tag my-website-image

- name: Run Docker container
run: |
Expand Down
5 changes: 5 additions & 0 deletions portal/.env.gh-pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REACT_APP__ENVIRONMENT=gh-pages
REACT_APP__BASE_API_URL=''
REACT_APP__DASHBOARD_LINK_HOST=http://localhost:3000
REACT_APP__PUBLIC_URL='qujata'
PUBLIC_URL='qujata'
9 changes: 8 additions & 1 deletion portal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM nginx:1.25-alpine3.18

RUN apk --no-cache add --update nodejs npm
ARG BUILD_ENV

## Replace the default nginx index page with our portal
RUN rm -rf /usr/share/nginx/html/*
Expand All @@ -9,7 +10,13 @@ RUN mkdir /usr/share/nginx/html/qujata
COPY . .
RUN npm install -g yarn
RUN yarn install
RUN yarn build && cp -r build/* /usr/share/nginx/html/qujata && cp build/index.html /usr/share/nginx/html/qujata/index.html.tpl && chmod 755 -R /usr/share/nginx/html/qujata
RUN yarn add env-cmd
RUN if [ "$BUILD_ENV" = "gh-pages" ]; then \
yarn build:gh-pages; \
else \
yarn build; \
fi \
&& cp -r build/* /usr/share/nginx/html/qujata && cp build/index.html /usr/share/nginx/html/qujata/index.html.tpl && chmod 755 -R /usr/share/nginx/html/qujata

COPY nginx.conf /etc/nginx/nginx.conf

Expand Down
2 changes: 2 additions & 0 deletions portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"chartjs-plugin-annotation": "^3.0.1",
"classnames": "^2.3.2",
"date-fns": "^3.3.0",
"env-cmd": "^10.1.0",
"filesize": "^10.1.0",
"lodash": "^4.17.21",
"react": "^18.2.0",
Expand Down Expand Up @@ -61,6 +62,7 @@
"start:mock:client": "cross-env REACT_SERVER_TARGET=http://localhost:2011 yarn start",
"start:mock:server": "cd ./mock-server && yarn serve",
"build": "yarn react-scripts build",
"build:gh-pages": "env-cmd -f .env.gh-pages yarn react-scripts build",
"build:ci": "yarn react-scripts build",
"test": "react-scripts test",
"test:coverage": "react-scripts test --coverage --watchAll=false",
Expand Down
1 change: 1 addition & 0 deletions portal/src/environments/environment.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface IEnvironment {
baseApiUrl: string;
dashboardLinkHost: string;
environment: string;
}
7 changes: 7 additions & 0 deletions portal/src/gh-pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Reports } from "./reports";

export const GHPages: React.FC = () => (
<Reports />
);

// export default GHPages;
48 changes: 48 additions & 0 deletions portal/src/gh-pages/reports.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useState, useEffect, ChangeEvent } from "react";
interface File {
path: string;
name: string;
}
export const Reports: React.FC = () => {
const [files, setFiles] = useState<File[]>([]);
const [selectedFile, setSelectedFile] = useState<string | null>(null);
const [fileContent, setFileContent] = useState<string>("");
useEffect(() => {
const apiUrl = 'https://api.github.com/repos/att/qujata/contents/reports?ref=main';
fetch(apiUrl)
.then(response => response.json())
.then((data: File[]) => {
setFiles(data);
if (data[0]) { // Check if there are any files
setSelectedFile(data[0].path); // Set the first file as the default selected file
}
})
.catch(error => console.error("Error fetching files: ", error));
}, []);
useEffect(() => {
if (selectedFile) {
fetch(`https://raw.githubusercontent.com/att/qujata/main/${selectedFile}`)
.then(response => response.json())
.then((data: any) => {
const fileContent = JSON.stringify(data, null, 2); // Decode the base64 content
setFileContent(fileContent);
})
.catch(error => console.error("Error fetching file content: ", error));
}
}, [selectedFile]); // This useEffect hook is dependent on selectedFile
const handleFileChange = (e: ChangeEvent<HTMLSelectElement>) => {
const value = e.target.value;
setSelectedFile(value);
};
return (
<div><select value={selectedFile || ''} onChange={handleFileChange}>
{files.map((file, index) => (
<option key={index} value={file.path}>
{file.name}
</option>
))}
</select><br/><br/><pre>
{fileContent}
</pre></div>
);
}
11 changes: 9 additions & 2 deletions portal/src/routes/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ import { Outlet } from 'react-router-dom';
import { tabs } from '../app/shared/constants/navigation-tabs.const';
import { Spinner, SpinnerSize } from '../app/shared/components/att-spinner';
import { useSpinnerContext } from '../app/shared/context/spinner';
import { Environment } from '../environments/environment';
import { GHPages } from "../gh-pages";

export default function Root() {
const { isSpinnerOn } = useSpinnerContext();
return (

<>
<GlobalHeader tabs={tabs} />
<GlobalHeader tabs={ Environment.environment === 'gh-pages' ? [] : tabs} />
{isSpinnerOn && renderSpinner()}
<Outlet />
{
Environment.environment === 'gh-pages' ? (<GHPages />) :(<Outlet />)
}


</>
);
}
Expand Down
52 changes: 52 additions & 0 deletions reports/1707053064011.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"id": 1,
"name": "test1",
"description": "test1",
"start_time": "Thu, 14 Dec 2023 15:37:31 GMT",
"end_time": "Thu, 14 Dec 2023 15:38:39 GMT",
"environment_info": {
"codeRelease": "1.1.0",
"cpu": "RELACE_WITH_CPU",
"cpuArchitecture": "RELACE_WITH_CPU_ARCHITECTURE",
"cpuClockSpeed": "RELACE_WITH_CLOCK_SPEED",
"cpuCores": 0,
"nodeSize": "RELACE_WITH_NODE_SIZE",
"operatingSystem": "RELACE_WITH_OPERATING_SYSTEM",
"resourceName": "RELACE_WITH_RESOURCE_NAME"
},

"testRuns": [
{
"algorithm": "bikel1",
"iterations": 200,
"results": {
"averageCPU": 4.1,
"averageMemory": 200
}
},
{
"algorithm": "bikel1",
"iterations": 400,
"results": {
"averageCPU": 4.9,
"averageMemory": 150
}
},
{
"algorithm": "kyber512",
"iterations": 1000,
"results": {
"averageCPU": 4.5,
"averageMemory": 249
}
},
{
"algorithm": "kyber512",
"iterations": 2000,
"results": {
"averageCPU": 0.0,
"averageMemory": 0
}
}
]
}
52 changes: 52 additions & 0 deletions reports/1707053090601.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"id": 2,
"name": "test2",
"description": "test2",
"start_time": "Thu, 15 Dec 2023 15:37:31 GMT",
"end_time": "Thu, 15 Dec 2023 15:38:39 GMT",
"environment_info": {
"codeRelease": "1.2.0",
"cpu": "RELACE_WITH_CPU",
"cpuArchitecture": "RELACE_WITH_CPU_ARCHITECTURE",
"cpuClockSpeed": "RELACE_WITH_CLOCK_SPEED",
"cpuCores": 0,
"nodeSize": "RELACE_WITH_NODE_SIZE",
"operatingSystem": "RELACE_WITH_OPERATING_SYSTEM",
"resourceName": "RELACE_WITH_RESOURCE_NAME"
},

"testRuns": [
{
"algorithm": "bikel1",
"iterations": 200,
"results": {
"averageCPU": 4.0,
"averageMemory": 210
}
},
{
"algorithm": "bikel1",
"iterations": 400,
"results": {
"averageCPU": 4.8,
"averageMemory": 125
}
},
{
"algorithm": "kyber512",
"iterations": 1000,
"results": {
"averageCPU": 4.3,
"averageMemory": 237
}
},
{
"algorithm": "kyber512",
"iterations": 2000,
"results": {
"averageCPU": 0.0,
"averageMemory": 0
}
}
]
}

0 comments on commit 026de17

Please sign in to comment.