Commit 514b3b22 authored by Tomáš Pecka's avatar Tomáš Pecka

Announce ALT and WebUI versions in client

This patch announces WebUI and ALT versions in the top bar of
webui-client page. The ALT version is fetched from the ALIB_VERSION
macro in ALT's version.hpp. WebUI version must be passed manually.
Both are stored in a separate json file.

Also cleanup static files, including algorithms.json. It should always
be built against current ALT backend and not stored in the repository.
parent 937efec9
Pipeline #94262 passed with stages
in 10 minutes
......@@ -53,16 +53,18 @@ build:webui:
before_script:
- apk add --no-cache jsoncpp-dev build-base cmake nodejs npm
script:
- mkdir -p webui/algorithmsJSONGenerator/build && cd webui/algorithmsJSONGenerator/build
- mkdir -p webui/json_generators/build && cd webui/json_generators/build
- cmake ..
- make -j$(grep -c processor /proc/cpuinfo)
- ./algorithms_JSON_generator > ../algorithms.json
- ./version-json "$CI_COMMIT_SHORT_SHA" > ../../src/static_jsons/version.json
- ./algorithms-json > ../../src/static_jsons/algorithms.json
- cd ../..
- npm install
- npm run build
artifacts:
paths:
- webui/build
- webui/src/static_jsons
expire_in: 1 hour
# -----------------------------------------------------------------------------
......@@ -85,7 +87,7 @@ test:webui:
stage: test
image: alpine:latest
dependencies:
- build:worker
- build:webui
before_script:
- apk add --no-cache nodejs npm
script:
......@@ -102,7 +104,7 @@ test:webui:
script:
- SERVICE="$(echo $CI_JOB_NAME | cut -d':' -f2)"
- IMAGE="${CI_REGISTRY_IMAGE}/${SERVICE}:latest"
- docker build -f $DOCKERFILE $CONTEXT -t $IMAGE --target $TARGET
- docker build -f $DOCKERFILE $CONTEXT -t $IMAGE --target $TARGET --build-arg VERSION=$CI_COMMIT_SHORT_SHA
- docker push ${IMAGE}
.deploy:latest:
......
FROM gitlab.fit.cvut.cz:5000/algorithms-library-toolkit/automata-library/cli:snapshot as algorithms_json_generator
FROM gitlab.fit.cvut.cz:5000/algorithms-library-toolkit/automata-library/cli:snapshot as static_files_generator
ADD ./webui/algorithmsJSONGenerator /app
ARG VERSION="<unknown>"
ADD ./webui/json_generators /app
ADD cmake ./app/cmake
WORKDIR /app
RUN apk add jsoncpp-dev build-base cmake && \
cmake -DCMAKE_MODULE_PATH=cmake . && \
make && \
./algorithms_JSON_generator > algorithms.json
RUN apk add jsoncpp-dev build-base cmake
RUN cmake . -DCMAKE_MODULE_PATH=cmake && \
make -j2 && \
mkdir -p static_jsons/ && \
./algorithms-json > static_jsons/algorithms.json && \
./version-json "$VERSION" > static_jsons/version.json
#-----------------------------------------------------------------------------------------
......@@ -15,7 +20,7 @@ FROM alpine:3.9 AS builder_webui
ADD ./webui /app
WORKDIR /app
COPY --from=algorithms_json_generator /app/algorithms.json src/algorithms.json
COPY --from=static_files_generator /app/static_jsons/ src/static_jsons/
RUN apk add --no-cache nodejs npm && \
npm install && \
npm run build
......@@ -25,4 +30,4 @@ RUN apk add --no-cache nodejs npm && \
FROM nginx:alpine as webui
COPY webui/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder_webui /app/build /usr/share/nginx/html
\ No newline at end of file
COPY --from=builder_webui /app/build /usr/share/nginx/html
cmake_minimum_required(VERSION 3.11.1)
project(algorithms_JSON_generator)
project(json-generators)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../cmake")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no-as-needed")
add_executable(algorithms_JSON_generator main.cpp)
find_package(ALT REQUIRED)
find_package(JSONCPP REQUIRED)
target_link_libraries(algorithms_JSON_generator
add_executable(algorithms-json algorithms-json.cpp)
target_link_libraries(algorithms-json
${ALT_LIBRARIES}
${JSONCPP_LIBRARIES}
)
target_include_directories(algorithms-json PUBLIC ${ALT_INCLUDE_DIR})
target_include_directories(algorithms_JSON_generator PUBLIC
${ALT_INCLUDE_DIR}
${JSONCPP_INCLUDE_DIR}
)
\ No newline at end of file
add_executable(version-json version-json.cpp)
target_include_directories(version-json PUBLIC ${ALT_INCLUDE_DIR})
#include <cstdio>
#include <version.hpp>
int main ( int argc, char * argv [ ] ) {
if ( argc != 2 ) {
fprintf ( stderr, "WebUI version not specified.\n" );
return ( 1 );
}
printf ( "{\"version\": { \"alt\": \"%s\", \"webui\": \"%s\" } }\n", ALIB_VERSION, argv [ 1 ] );
return 0;
}
This diff is collapsed.
......@@ -2,7 +2,7 @@ import React, { useState, useCallback } from 'react'
import { List, ListItem, TextField, makeStyles } from '@material-ui/core'
import { categorizeAlgorithms } from '../../../../interfaces/AlgorithmCategory'
import { AlgorithmCategoryList } from './AlgorithmCategoryList'
import { algorithms as algorithmsJSON } from '../../../../algorithms.json'
import { algorithms as algorithmsJSON } from '../../../../static_jsons/algorithms.json'
const algorithms = categorizeAlgorithms(algorithmsJSON)
......
......@@ -3,12 +3,14 @@ import {
makeStyles,
AppBar,
Toolbar,
Typography,
IconButton
Popover,
IconButton,
Grid,
} from '@material-ui/core'
import {
ArrowForwardIos as ArrowRightIcon,
ArrowBackIos as ArrowLeftIcon
ArrowBackIos as ArrowLeftIcon,
Info,
} from '@material-ui/icons'
import AlgorithmCanvas from '../AlgorithmCanvas'
import AlgorithmToolbar from './Toolbar/AlgorithmToolbar'
......@@ -18,6 +20,7 @@ import { algorithmUIActions } from '../../reducers/algorithmUI'
import { WebUITheme } from '../../interfaces/Theme'
import { useAlgorithmKeybinds } from '../../hooks/useAlgorithmKeybinds'
import { QueryImporter } from './QueryImporter'
import { WebUIAboutBox } from './WebUIAboutBox'
const { setAlgorithmToolbarOpen } = algorithmUIActions
......@@ -44,7 +47,10 @@ const useStyles = makeStyles<WebUITheme>((theme) => ({
},
toolbar: {
paddingLeft: '0px'
}
},
popover: {
pointerEvents: 'none',
},
}))
export const WebUI = () => {
......@@ -60,6 +66,17 @@ export const WebUI = () => {
dispatch(setAlgorithmToolbarOpen(!toolbarOpen))
}, [dispatch, toolbarOpen])
/* version popover */
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);
const handlePopoverOpen = (event: React.MouseEvent<HTMLElement, MouseEvent>) => {
setAnchorEl(event.currentTarget);
};
const handlePopoverClose = () => {
setAnchorEl(null);
};
const open = Boolean(anchorEl);
return (
<div
className={classes.root}
......@@ -68,15 +85,36 @@ export const WebUI = () => {
>
<AppBar className={classes.appBar} data-shift={toolbarOpen}>
<Toolbar className={classes.toolbar} variant="dense">
<IconButton
color="inherit"
onClick={handleToolbarButtonClick}
>
{toolbarOpen ? <ArrowLeftIcon /> : <ArrowRightIcon />}
</IconButton>
<Typography variant="h6" noWrap>
ALT WebUI
</Typography>
<Grid container justify="space-between">
<IconButton
color="inherit"
onClick={handleToolbarButtonClick}
>
{toolbarOpen ? <ArrowLeftIcon /> : <ArrowRightIcon />}
</IconButton>
<IconButton
color="inherit"
aria-owns={open ? 'mouse-over-popover' : undefined}
aria-haspopup="true"
onMouseEnter={handlePopoverOpen}
onMouseLeave={handlePopoverClose}
>
<Info />
</IconButton>
<Popover
id="mouse-over-popover"
className={classes.popover}
classes={{ paper: classes.paper, }}
open={open}
anchorEl={anchorEl}
anchorOrigin={{ vertical: 'bottom', horizontal: 'left', }}
transformOrigin={{ vertical: 'top', horizontal: 'left', }}
onClose={handlePopoverClose}
disableRestoreFocus
>
<WebUIAboutBox />
</Popover>
</Grid>
</Toolbar>
</AppBar>
<AlgorithmToolbar />
......
import React from 'react'
import { WebUITheme } from '../../interfaces/Theme'
import {
makeStyles,
Paper,
} from '@material-ui/core'
import { version as versionJSON } from '../../static_jsons/version.json'
const useStyles = makeStyles<WebUITheme>((theme) => ({
root: {
padding: '30px',
minWidth: '200px',
},
}));
export const WebUIAboutBox = () => {
const classes = useStyles();
return (
<Paper className={classes.root} elevation={2}>
<dl>
<dt>WebUI</dt>
<dd>{versionJSON.webui}</dd>
<dt>ALT</dt>
<dd>{versionJSON.alt}</dd>
</dl>
</Paper>
)
}
{
"algorithms" : [ ],
"casts" : { }
}
{
"version": {
"webui": "<unknown>",
"alt": "<unknown>"
}
}
import { AlibType } from '../interfaces/Algorithms'
import { casts as castsJSON, algorithms } from '../algorithms.json'
import { casts as castsJSON, algorithms } from '../static_jsons/algorithms.json'
import { removeTemplate } from './removeTemplate'
const casts = Object.fromEntries(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment