Skip to content

Commit abccc3c

Browse files
committed
feat: init svelte/tailwind frontend (#4)
1 parent 9dd9faf commit abccc3c

Some content is hidden

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

68 files changed

+199
-109
lines changed

frontend/src/base/Head.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
<meta name="robots" content="noindex, nofollow">
99
<meta name="color-scheme" content="light dark" />
1010
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src *; style-src 'self' 'unsafe-inline'">
11-
<link href="/css/global.css" rel="stylesheet" type="text/css" crossorigin="anonymous" referrerpolicy="no-referrer">
11+
<link href="/static/css/global.css" rel="stylesheet" type="text/css" crossorigin="anonymous" referrerpolicy="no-referrer">
1212
<link href="/static/dist/tailwind.min.css" rel="stylesheet" type="text/css" crossorigin="anonymous" referrerpolicy="no-referrer">

scripts/frontend/build.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ FORCE_UPDATE="${FORCE_UPDATE:-0}"
77
cd "$(dirname "$0")/"
88

99
REPO_BASE="$(pwd)/../.."
10-
SRC_DIR="${REPO_BASE}/frontend/"
10+
SRC_DIR="${REPO_BASE}/frontend"
1111
DST_DIR="${REPO_BASE}/src/oxl_ansible_webui/aw/static_dev/dist"
12-
mkdir -p "$DST_DIR"
12+
UPDATE_NOW="${SRC_DIR}/src/.update_now"
1313

14-
echo "$FORCE_UPDATE"
1514
if [[ "$FORCE_UPDATE" == '1' ]]
1615
then
17-
touch "${REPO_BASE}/frontend/src/.update_now"
16+
touch "$UPDATE_NOW"
1817
fi
1918

2019
function check_src_changes() {
21-
recent_changes="$(find "${SRC_DIR}/src/" -type f -mmin -0.5 | wc -l)"
20+
recent_changes="$(find "${SRC_DIR}/src/" -type f -mmin -0.3 | wc -l)"
2221
if [[ "$recent_changes" == '0' ]]
2322
then
2423
exit 0
@@ -27,6 +26,7 @@ function check_src_changes() {
2726

2827
check_src_changes
2928

29+
mkdir -p "$DST_DIR"
3030
bash build_tailwind.sh "$SRC_DIR" "$DST_DIR" &
3131

3232
cd "$SRC_DIR"
@@ -54,3 +54,4 @@ do
5454
done
5555
done
5656
echo "--- $(date +%H:%M:%S) FRONTEND UPDATED ---"
57+
rm -f "$UPDATE_NOW"

scripts/frontend/build_tailwind.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ set -euo pipefail
55
SRC_DIR="$1"
66
DST_DIR="$2"
77

8+
SRC_TW="${SRC_DIR}/dist/tailwind.min.css"
9+
810
cd "$SRC_DIR"
9-
npx tailwindcss -i "${SRC_DIR}/src/tailwind.css" -o "${SRC_DIR}/dist/tailwind.min.css" --minify 2>/dev/null
11+
npx tailwindcss -i "${SRC_DIR}/src/tailwind.css" -o "$SRC_TW" --minify 2>/dev/null
1012

1113
# v4
1214
# npx @tailwindcss/cli -i "${SRC_DIR}/src/tailwind.css" -o "${SRC_DIR}/dist/tailwind.min.css" --minify 2>/dev/null
1315

14-
cp "${SRC_DIR}/dist/tailwind.min.css" "${DST_DIR}/tailwind.min.css"
16+
if [ -f "$SRC_TW" ]
17+
then
18+
cp "$SRC_TW" "${DST_DIR}/tailwind.min.css"
19+
fi

scripts/frontend/run_updater.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ cd "$(dirname "$0")"
66

77
REPO_BASE="$(pwd)/../.."
88

9-
PATH_STATIC_DEV="${REPO_BASE}/src/oxl_ansible_webui/aw/static_dev"
10-
rm -f "${PATH_STATIC_DEV}/dist/"*.js
11-
rm -f "${PATH_STATIC_DEV}/dist/"*.css
12-
rm -f "${REPO_BASE}/frontend/vite.config.ts.time"*
9+
SRC_DIR="${REPO_BASE}/frontend"
10+
DST_DIR="${REPO_BASE}/src/oxl_ansible_webui/aw/static_dev/dist"
1311

14-
mkdir -p "${PATH_STATIC_DEV}"
15-
mkdir -p "${PATH_STATIC_DEV}/vendor"
16-
mkdir -p "${PATH_STATIC_DEV}/dist"
12+
mkdir -p "${DST_DIR}"
13+
rm -f "${DST_DIR}/"*.js
14+
rm -f "${DST_DIR}/"*.css
15+
rm -f "${SRC_DIR}/vite.config.ts.time"*
1716

1817
echo '### RUNNING FRONTEND UPDATER ###'
19-
touch "${REPO_BASE}/frontend/src/.update_now"
18+
touch "${SRC_DIR}/src/.update_now"
2019
while true
2120
do
2221
bash "$(pwd)/build.sh" || true

scripts/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7+
export PYTHONPATH=''
8+
79
echo ''
810
echo 'UNIT TESTS'
911
echo ''
@@ -30,6 +32,7 @@ fi
3032

3133

3234
echo 'Starting Ansible-WebUI..'
35+
trap "pkill -f oxl_ansible_webui; exit" INT
3336
export AW_ENV='dev'
3437
# shellcheck disable=SC2155
3538
export AW_DB="/tmp/$(date +%s).aw.db"

scripts/update_version.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
#git pull || true
8-
#last_tag="$(git describe --tags --abbrev=0)"
9-
#echo "${last_tag}.dev" > "$(dirname "$0")/../VERSION"
7+
git pull 2>/dev/null || true
8+
last_tag="$(git describe --tags --abbrev=0)"
9+
echo "${last_tag}.dev" > "$(dirname "$0")/../VERSION"
Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
<!DOCTYPE html>
2-
{% load util %}
3-
{% load static %}
42
<html lang="en">
53
<head>
6-
{% include "./head.html" %}
7-
<!-- START custom header additions -->
8-
{% block extrahead %}
9-
{% endblock %}
10-
<!-- END custom header additions -->
4+
<title>Ansible WebUI</title>
5+
<link href="/static/css/global.css" rel="stylesheet" type="text/css" crossorigin="anonymous" referrerpolicy="no-referrer">
6+
<link href="/static/dist/tailwind.min.css" rel="stylesheet" type="text/css" crossorigin="anonymous" referrerpolicy="no-referrer">
117
</head>
128
<body>
13-
{% include "./nav.html" %}
14-
{% include "./error/js_disabled.html" %}
15-
<main class="aw-main">
16-
<div id="aw-api-error" class="aw-error-msg aw-mark-warn"></div>
17-
<div id="aw-ui-error" class="aw-error-msg aw-mark-warn">{{ request.GET|get_value:"error"|ignore_none }}</div>
18-
<div id="aw-api-result" class="aw-success-msg aw-mark-ok"></div>
9+
<noscript>
10+
<div class="noscript-error">
11+
You need to enable Javascript to use this app!
12+
</div>
13+
</noscript>
14+
<div id="nav" class="dark:bg-gray-600"></div>
15+
<div id="main" class="dark:bg-gray-600 w-full h-full">
1916
{% block content %}
2017
{% endblock %}
21-
{% if show_update_time %}
22-
<div id="aw-last-update"></div>
23-
{% endif %}
24-
<iframe hidden="hidden" id="aw-api-error-full" src="about:blank" width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="auto"></iframe>
25-
</main>
26-
<br>
27-
<div class="aw-footer-wrapper">
28-
<footer class="aw-footer">
29-
<div class="aw-footer-text">
30-
<div>
31-
© {% now 'Y' %} OXL | Version {% get_version %}{% if user.is_authenticated %} | User: {{ request.user }}{% endif %}
32-
</div>
33-
</div>
34-
</footer>
3518
</div>
19+
<div id="footer-bg" class="dark:bg-gray-600"></div>
20+
<div id="footer" class="dark:bg-gray-600"></div>
21+
<script type="module" src="/static/dist/index.js"></script>
3622
</body>
37-
</html>
23+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% extends "./body.html" %}
2+
{% block content %}
3+
{% endblock %}

src/oxl_ansible_webui/aw/templates/head.html

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% extends "./body.html" %}
2+
{% block content %}
3+
{% endblock %}

0 commit comments

Comments
 (0)