Skip to content

Commit

Permalink
Merge pull request #168 from edlerd/ui-infra
Browse files Browse the repository at this point in the history
Add infrastrucutre for UI and first pages for client management
  • Loading branch information
edlerd authored Oct 25, 2023
2 parents a56b33e + 7894406 commit 790eae7
Show file tree
Hide file tree
Showing 41 changed files with 7,015 additions and 5,690 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ build: cmd/ui/dist
cmd/ui/dist:
@echo "copy dist npm files into cmd/ui folder"
mkdir -p cmd/ui/dist
# TODO: Uncomment when ui is added
# cp -r $(UI_FOLDER)ui/dist cmd/ui/
cp -r $(UI_FOLDER)ui/dist cmd/ui/

npm-build:
$(MAKE) -C ui/ build
Expand Down
1 change: 1 addition & 0 deletions ui/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT=8411
39 changes: 39 additions & 0 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "react"],
globals: {},
env: {
node: true,
browser: true,
es6: true,
es2020: true,
jest: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict",
],
settings: {
react: {
version: "detect",
},
},
parserOptions: {
project: "./tsconfig.json",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
root: true,
rules: {
"linebreak-style": ["error", "unix"],
semi: ["error", "always"],
"object-curly-spacing": ["error", "always"],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
},
};
83 changes: 83 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# [generated] Bracketed sections updated by Yeoman generator
# generator-canonical-webteam@3.4.1

# [os] OS & editor files
Desktop.ini
Thumbs.db
._*
*.DS_Store
*~
\#*\#
.AppleDouble
.LSOverride
.spelling
.vscode
.idea

# [cache] Cache and backup
*.bak
*-cache/

# [data] Local data
*.sqlite*
*.log
logs/
pids
*.pid
*.seed
.*-metadata

# [deps] Local dependencies
.bundle/
node_modules/
vendor/
bower_components/
vendor/
# Normally lockfiles would be committed, but we use yarn instead of NPM for locking dependencies
package-lock.json

# [build] Built files
/build/
/parts/
/prime/
/stage/
*.egg-info
.snapcraft/
*.snap
_site/
*.*.map

# [env] Local environment settings
.docker-project
.*.hash
.envrc
.env.local
env/
env[23]/
virtual/
venv/
.venv/
.dotrun.json

# [sass] Files generated by Sass
*.css

node_modules/
bower_components/
*.log

build/
dist/

*.crt
*.key
*.pem
*.csr
*.pfx

# tests
/test-results/
/playwright-report/
/playwright/.cache/

haproxy-local.cfg
1 change: 1 addition & 0 deletions ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
11 changes: 11 additions & 0 deletions ui/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": ["stylelint-config-standard-scss", "stylelint-prettier/recommended"],
"plugins": ["stylelint-order", "stylelint-scss"],
"rules": {
"order/properties-alphabetical-order": true,
"at-rule-no-unknown": null,
"scss/at-rule-no-unknown": true,
"selector-class-pattern": null,
"no-invalid-position-at-import-rule": null
}
}
9 changes: 5 additions & 4 deletions ui/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
NPM?=npm
YARN?=yarn


build: install
$(NPM) run build --frozen=lockfile
$(YARN) install --frozen=lockfile
$(YARN) build
.PHONY=build

install:
$(NPM) install
$(YARN) install
.PHONY=install

test:
$(NPM) ci
$(YARN) ci
.PHONY=test
45 changes: 31 additions & 14 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,42 @@

This is the Admin UI for the Canonical identity platform.

### `npm dev`
### Development server

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
Haproxy needs to be installed

The page will reload when you make changes.\
You may also see any lint errors in the console.
apt install haproxy

### `npm test`
and configured

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
vim /etc/haproxy/haproxy.cfg

### `npm run build`
use this content for the file

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
global
daemon

defaults
mode http

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
frontend iam_frontend
bind 172.17.0.1:8000
default_backend iam_admin_be

backend iam_admin_be
server admin_be 127.0.0.1:8000

and restart it

service haproxy restart

Start the build server as described in the main README.md in the root of this repo

make dev

Install dotrun as described in https://github.com/canonical/dotrun#installation Launch it from the `ui/` directory of this repo

dotrun

browse to https://localhost:8411/ to reach iam-admin-ui.
29 changes: 29 additions & 0 deletions ui/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
esmodules: true,
},
},
],
"@babel/react",
],
env: {
test: {
presets: [
[
"@babel/env",
{
targets: {
node: "current",
},
},
],
"jest",
],
plugins: ["transform-es2015-modules-commonjs"],
},
},
};
6 changes: 6 additions & 0 deletions ui/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/env bash
set -e

echo "Listening on http://localhost:8411"

haproxy -f haproxy.cfg -db
20 changes: 20 additions & 0 deletions ui/haproxy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
global
daemon

defaults
mode http
timeout connect 50000
timeout client 500000
timeout server 500000

frontend iam_frontend
bind 0.0.0.0:8411
acl is_api path_beg /api/
use_backend api if is_api
default_backend iam_admin_ui

backend iam_admin_ui
server yarn_serve 127.0.0.1:3000

backend api
server kube_api_url 172.17.0.1:8000
19 changes: 19 additions & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>

<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>Identity Platform Admin</title>
<link rel="shortcut icon" href="https://assets.ubuntu.com/v1/49a1a858-favicon-32x32.png" type="image/x-icon" />

<script>const global = globalThis;</script>
</head>
<body>

<div id="app"></div>
<script type="module" src="./src/index.tsx"></script>

</body>
</html>
Loading

0 comments on commit 790eae7

Please sign in to comment.