Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ea5c3fb68 | ||
|
|
5ede96d6ce | ||
|
|
a7fe80a399 | ||
|
|
0b61b6c1b8 | ||
|
|
02989a4366 | ||
|
|
bc6acf7fd1 | ||
|
|
a4e29bc7a7 | ||
|
|
a7982bda06 | ||
|
|
6b3bff1f1d | ||
|
|
e3ca0adf11 | ||
|
|
d62404f164 |
26 changed files with 22 additions and 424 deletions
|
|
@ -12,7 +12,6 @@ ARG CI
|
||||||
ARG BUILDTIME
|
ARG BUILDTIME
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ARG REVISION
|
ARG REVISION
|
||||||
ARG NEXT_PUBLIC_BASE_PATH
|
|
||||||
ENV CI=$CI
|
ENV CI=$CI
|
||||||
|
|
||||||
# Install and build only outside CI
|
# Install and build only outside CI
|
||||||
|
|
@ -23,7 +22,6 @@ RUN if [ "$CI" != "true" ]; then \
|
||||||
NEXT_PUBLIC_BUILDTIME=$BUILDTIME \
|
NEXT_PUBLIC_BUILDTIME=$BUILDTIME \
|
||||||
NEXT_PUBLIC_VERSION=$VERSION \
|
NEXT_PUBLIC_VERSION=$VERSION \
|
||||||
NEXT_PUBLIC_REVISION=$REVISION \
|
NEXT_PUBLIC_REVISION=$REVISION \
|
||||||
NEXT_PUBLIC_BASE_PATH=$NEXT_PUBLIC_BASE_PATH \
|
|
||||||
pnpm run build; \
|
pnpm run build; \
|
||||||
else \
|
else \
|
||||||
echo "✅ Using prebuilt app from CI context"; \
|
echo "✅ Using prebuilt app from CI context"; \
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
- Repositories:
|
|
||||||
- DeckForge:
|
|
||||||
- abbr: DF
|
|
||||||
href: https://bitbucket.org/zlalani/ppt-tool
|
|
||||||
- GMAL Scope Builder:
|
|
||||||
- abbr: GSB
|
|
||||||
href: https://bitbucket.org/zlalani/gmal-scope-builder
|
|
||||||
- Homepage:
|
|
||||||
- abbr: HP
|
|
||||||
href: https://bitbucket.org/zlalani/homepage
|
|
||||||
- OliVAS:
|
|
||||||
- abbr: OL
|
|
||||||
href: https://bitbucket.org/zlalani/olivas
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
local:
|
|
||||||
socket: /var/run/docker.sock
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
---
|
|
||||||
- AI Tools:
|
|
||||||
- DeckForge:
|
|
||||||
icon: mdi-presentation
|
|
||||||
href: https://optical-dev.oliver.solutions/ppt-tool
|
|
||||||
description: AI presentation generator
|
|
||||||
container: ppt-tool-web-1
|
|
||||||
server: local
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/ppt-tool
|
|
||||||
showStats: true
|
|
||||||
widget:
|
|
||||||
type: deploy
|
|
||||||
service: ppt-tool
|
|
||||||
label: DeckForge
|
|
||||||
|
|
||||||
- GMAL Scope Builder:
|
|
||||||
icon: mdi-briefcase-outline
|
|
||||||
href: https://optical-dev.oliver.solutions/gsb
|
|
||||||
description: AI ratecard & team scoping
|
|
||||||
container: gmal-scope-builder-backend-1
|
|
||||||
server: local
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/gsb/
|
|
||||||
showStats: true
|
|
||||||
widget:
|
|
||||||
type: deploy
|
|
||||||
service: gmal-scope-builder
|
|
||||||
label: Scope Builder
|
|
||||||
|
|
||||||
- Semblance:
|
|
||||||
icon: mdi-account-group-outline
|
|
||||||
href: https://optical-dev.oliver.solutions/semblance
|
|
||||||
description: Synthetic personas & focus groups
|
|
||||||
container: semblance-backend-1
|
|
||||||
server: local
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/semblance/
|
|
||||||
showStats: true
|
|
||||||
widget:
|
|
||||||
type: deploy
|
|
||||||
service: semblance
|
|
||||||
label: Semblance
|
|
||||||
|
|
||||||
- CC Dashboard:
|
|
||||||
icon: mdi-view-dashboard-outline
|
|
||||||
href: https://optical-dev.oliver.solutions/cc-dashboard
|
|
||||||
description: API key & project management
|
|
||||||
container: cc-dashboard-app-1
|
|
||||||
server: local
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/cc-dashboard/
|
|
||||||
showStats: true
|
|
||||||
widget:
|
|
||||||
type: deploy
|
|
||||||
service: cc-dashboard
|
|
||||||
label: CC Dashboard
|
|
||||||
|
|
||||||
- OliVAS:
|
|
||||||
icon: mdi-robot-outline
|
|
||||||
href: https://optical-dev.oliver.solutions
|
|
||||||
description: OliVAS backend API
|
|
||||||
container: olivas-backend-1
|
|
||||||
server: local
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/api/health
|
|
||||||
showStats: true
|
|
||||||
widget:
|
|
||||||
type: deploy
|
|
||||||
service: olivas
|
|
||||||
label: OliVAS
|
|
||||||
|
|
||||||
- Infrastructure:
|
|
||||||
- Homepage:
|
|
||||||
icon: mdi-home-outline
|
|
||||||
href: https://optical-dev.oliver.solutions/homepage
|
|
||||||
description: This dashboard
|
|
||||||
container: homepage-app-1
|
|
||||||
server: local
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/homepage
|
|
||||||
showStats: true
|
|
||||||
widget:
|
|
||||||
type: deploy
|
|
||||||
service: homepage
|
|
||||||
label: Homepage
|
|
||||||
|
|
||||||
- Deploy API:
|
|
||||||
icon: mdi-rocket-launch-outline
|
|
||||||
href: https://optical-dev.oliver.solutions/deploy-api/docs
|
|
||||||
description: One-click deploy service
|
|
||||||
siteMonitor: https://optical-dev.oliver.solutions/deploy-api/services
|
|
||||||
|
|
||||||
- PostgreSQL × 4:
|
|
||||||
icon: mdi-database-outline
|
|
||||||
description: "ppt-tool · olivas · cc-dashboard · gmal"
|
|
||||||
href: https://optical-dev.oliver.solutions
|
|
||||||
|
|
||||||
- Redis + MongoDB:
|
|
||||||
icon: mdi-server-outline
|
|
||||||
description: ppt-tool (Redis) · semblance (Mongo)
|
|
||||||
href: https://optical-dev.oliver.solutions
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
---
|
|
||||||
title: Optical Dev
|
|
||||||
language: en
|
|
||||||
theme: dark
|
|
||||||
color: zinc
|
|
||||||
|
|
||||||
# Full-width layout, equal card heights, hide noise
|
|
||||||
fullWidth: true
|
|
||||||
useEqualHeights: true
|
|
||||||
headerStyle: clean
|
|
||||||
cardBlur: md
|
|
||||||
statusStyle: dot
|
|
||||||
hideVersion: true
|
|
||||||
disableUpdateCheck: true
|
|
||||||
target: _blank
|
|
||||||
|
|
||||||
# Layout sections
|
|
||||||
layout:
|
|
||||||
Widgets:
|
|
||||||
style: row
|
|
||||||
columns: 2
|
|
||||||
AI Tools:
|
|
||||||
style: row
|
|
||||||
columns: 5
|
|
||||||
useEqualHeights: true
|
|
||||||
Infrastructure:
|
|
||||||
style: row
|
|
||||||
columns: 4
|
|
||||||
useEqualHeights: true
|
|
||||||
Repositories:
|
|
||||||
style: row
|
|
||||||
columns: 4
|
|
||||||
iconsOnly: false
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
- resources:
|
|
||||||
cpu: true
|
|
||||||
memory: true
|
|
||||||
disk: /
|
|
||||||
label: optical-dev server
|
|
||||||
expanded: true
|
|
||||||
cputemp: false
|
|
||||||
|
|
||||||
- datetime:
|
|
||||||
text_size: xl
|
|
||||||
format:
|
|
||||||
timeStyle: short
|
|
||||||
dateStyle: short
|
|
||||||
hourCycle: h23
|
|
||||||
30
deploy.sh
30
deploy.sh
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
DEPLOY_DIR="/opt/homepage"
|
|
||||||
REPO="git@bitbucket.org:zlalani/homepage.git"
|
|
||||||
|
|
||||||
echo "=== Homepage Deploy ==="
|
|
||||||
|
|
||||||
if [ ! -d "$DEPLOY_DIR/.git" ]; then
|
|
||||||
echo "Cloning repository..."
|
|
||||||
git clone "$REPO" "$DEPLOY_DIR"
|
|
||||||
cd "$DEPLOY_DIR"
|
|
||||||
else
|
|
||||||
echo "Pulling latest changes..."
|
|
||||||
cd "$DEPLOY_DIR"
|
|
||||||
git pull origin dev
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p config
|
|
||||||
|
|
||||||
echo "Building and starting container..."
|
|
||||||
docker compose build --no-cache
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
echo "Waiting for healthcheck..."
|
|
||||||
sleep 15
|
|
||||||
docker compose ps
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Done. Homepage available at https://optical-dev.oliver.solutions/homepage"
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
services:
|
|
||||||
app:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
NEXT_PUBLIC_BASE_PATH: /homepage
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:3001:3000"
|
|
||||||
volumes:
|
|
||||||
- ./config:/app/config
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
environment:
|
|
||||||
HOSTNAME: "::"
|
|
||||||
HOMEPAGE_ALLOWED_HOSTS: "optical-dev.oliver.solutions"
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/healthcheck || exit 1"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 3s
|
|
||||||
start_period: 30s
|
|
||||||
retries: 3
|
|
||||||
|
|
@ -129,7 +129,7 @@ A progressive web app is an app that can be installed on a device and provide us
|
||||||
|
|
||||||
More information on PWAs can be found in [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps).
|
More information on PWAs can be found in [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps).
|
||||||
|
|
||||||
## App icons
|
### App icons
|
||||||
|
|
||||||
You can set custom icons for installable apps. More information about how you can set them can be found in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/icons).
|
You can set custom icons for installable apps. More information about how you can set them can be found in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/icons).
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ For icon `src` you can pass either full URL or a local path relative to the `/ap
|
||||||
|
|
||||||
### Shortcuts
|
### Shortcuts
|
||||||
|
|
||||||
Shortcuts can e used to specify links to tabs, to be preselected when the homepage is opened as an app.
|
Shortcuts can be used to specify links to tabs, to be preselected when the homepage is opened as an app.
|
||||||
More information about how you can set them can be found in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/shortcuts).
|
More information about how you can set them can be found in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/shortcuts).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ The Glances widget allows you to monitor the resources (CPU, memory, storage, te
|
||||||
cpu: true # optional, enabled by default, disable by setting to false
|
cpu: true # optional, enabled by default, disable by setting to false
|
||||||
mem: true # optional, enabled by default, disable by setting to false
|
mem: true # optional, enabled by default, disable by setting to false
|
||||||
cputemp: true # disabled by default
|
cputemp: true # disabled by default
|
||||||
|
unit: imperial # optional for temp, default is metric
|
||||||
uptime: true # disabled by default
|
uptime: true # disabled by default
|
||||||
disk: / # disabled by default, use mount point of disk(s) in glances. Can also be a list (see below)
|
disk: / # disabled by default, use mount point of disk(s) in glances. Can also be a list (see below)
|
||||||
diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk
|
diskUnits: bytes # optional, bytes (default) or bbytes. Only applies to disk
|
||||||
|
|
@ -31,5 +32,3 @@ disk:
|
||||||
- /boot
|
- /boot
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
_Added in v0.4.18, updated in v0.6.11, v0.6.21_
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ You can display general connectivity status from your Unifi (Network) Controller
|
||||||
|
|
||||||
An optional 'site' parameter can be supplied, if it is not the widget will use the default site for the controller.
|
An optional 'site' parameter can be supplied, if it is not the widget will use the default site for the controller.
|
||||||
|
|
||||||
!!! hint
|
!!! tip
|
||||||
|
|
||||||
If you enter e.g. incorrect credentials and receive an "API Error", you may need to recreate the container to clear the cache.
|
If you enter e.g. incorrect credentials and receive an "API Error", you may need to recreate the container to clear the cache.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ An optional 'site' parameter can be supplied, if it is not the widget will use t
|
||||||
|
|
||||||
Allowed fields: `["uptime", "wan", "lan", "lan_users", "lan_devices", "wlan", "wlan_users", "wlan_devices"]` (maximum of four). Fields unsupported by the unifi device will not be shown.
|
Allowed fields: `["uptime", "wan", "lan", "lan_users", "lan_devices", "wlan", "wlan_users", "wlan_devices"]` (maximum of four). Fields unsupported by the unifi device will not be shown.
|
||||||
|
|
||||||
!!! hint
|
!!! tip
|
||||||
|
|
||||||
If you enter e.g. incorrect credentials and receive an "API Error", you may need to recreate the container or restart the service to clear the cache.
|
If you enter e.g. incorrect credentials and receive an "API Error", you may need to recreate the container or restart the service to clear the cache.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@ widget:
|
||||||
password: your_password
|
password: your_password
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! hint
|
!!! tip
|
||||||
|
|
||||||
If you enter incorrect credentials and receive an "API Error", you may need to recreate the container or restart the service to clear the cache.
|
If you enter incorrect credentials and receive an "API Error", you may need to recreate the container or restart the service to clear the cache.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ const { i18n } = require("./next-i18next.config");
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
|
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "homepage",
|
"name": "homepage",
|
||||||
"version": "1.10.1",
|
"version": "1.12.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { MdRefresh } from "react-icons/md";
|
||||||
|
|
||||||
export default function Revalidate() {
|
export default function Revalidate() {
|
||||||
const revalidate = () => {
|
const revalidate = () => {
|
||||||
fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/revalidate`).then((res) => {
|
fetch("/api/revalidate").then((res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
import { useState } from "react";
|
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
const STATUS_COLORS = {
|
|
||||||
idle: "text-theme-500 dark:text-theme-400",
|
|
||||||
running: "text-blue-500 dark:text-blue-400",
|
|
||||||
success: "text-emerald-500 dark:text-emerald-400",
|
|
||||||
failed: "text-red-500 dark:text-red-400",
|
|
||||||
};
|
|
||||||
|
|
||||||
const STATUS_LABELS = {
|
|
||||||
idle: "Never deployed",
|
|
||||||
running: "Deploying...",
|
|
||||||
success: "Deployed",
|
|
||||||
failed: "Failed",
|
|
||||||
};
|
|
||||||
|
|
||||||
function formatTime(iso) {
|
|
||||||
if (!iso) return null;
|
|
||||||
const d = new Date(iso);
|
|
||||||
return d.toLocaleString("en-GB", { dateStyle: "short", timeStyle: "short", hourCycle: "h23" });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Deploy({ options }) {
|
|
||||||
const { service, label, apiBase = "/deploy-api" } = options ?? {};
|
|
||||||
const bp = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
|
||||||
// SWR middleware already prepends bp, so statusUrl must NOT include it
|
|
||||||
const statusUrl = service ? `${apiBase}/status/${service}` : null;
|
|
||||||
|
|
||||||
const { data, mutate } = useSWR(statusUrl, {
|
|
||||||
refreshInterval: (d) => (d?.status === "running" ? 2000 : 10000),
|
|
||||||
});
|
|
||||||
|
|
||||||
const [triggering, setTriggering] = useState(false);
|
|
||||||
|
|
||||||
const status = data?.status ?? "idle";
|
|
||||||
const lastRun = data?.last_run ? formatTime(data.last_run) : null;
|
|
||||||
const isRunning = status === "running";
|
|
||||||
|
|
||||||
const handleDeploy = async () => {
|
|
||||||
if (isRunning || triggering) return;
|
|
||||||
setTriggering(true);
|
|
||||||
try {
|
|
||||||
await fetch(`${bp}${apiBase}/deploy/${service}`, { method: "POST" });
|
|
||||||
await mutate();
|
|
||||||
} finally {
|
|
||||||
setTriggering(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!service) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center text-theme-500 text-xs p-2">
|
|
||||||
<span>No service configured</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center p-2 gap-1 w-full">
|
|
||||||
<div className={`text-xs font-semibold ${STATUS_COLORS[status] ?? STATUS_COLORS.idle}`}>
|
|
||||||
{isRunning ? (
|
|
||||||
<span className="animate-pulse">{STATUS_LABELS.running}</span>
|
|
||||||
) : (
|
|
||||||
STATUS_LABELS[status] ?? status
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{lastRun && (
|
|
||||||
<div className="text-theme-500 dark:text-theme-400 text-xs opacity-75">{lastRun}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handleDeploy}
|
|
||||||
disabled={isRunning || triggering}
|
|
||||||
className={[
|
|
||||||
"mt-1 px-3 py-1 rounded text-xs font-medium transition-colors",
|
|
||||||
isRunning || triggering
|
|
||||||
? "bg-theme-300 dark:bg-theme-600 text-theme-500 dark:text-theme-400 cursor-not-allowed"
|
|
||||||
: "bg-theme-500 hover:bg-theme-600 dark:bg-theme-600 dark:hover:bg-theme-500 text-white cursor-pointer",
|
|
||||||
].join(" ")}
|
|
||||||
>
|
|
||||||
{isRunning ? "Running..." : `Deploy ${label ?? service}`}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -106,7 +106,7 @@ export default function Search({ options }) {
|
||||||
query.trim().length > 0 &&
|
query.trim().length > 0 &&
|
||||||
query.trim() !== searchSuggestions[0]
|
query.trim() !== searchSuggestions[0]
|
||||||
) {
|
) {
|
||||||
fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/search/searchSuggestion?query=${encodeURIComponent(query)}&providerName=${selectedProvider.name}`, {
|
fetch(`/api/search/searchSuggestion?query=${encodeURIComponent(query)}&providerName=${selectedProvider.name}`, {
|
||||||
signal: abortController.signal,
|
signal: abortController.signal,
|
||||||
})
|
})
|
||||||
.then(async (searchSuggestionResult) => {
|
.then(async (searchSuggestionResult) => {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ const widgetMappings = {
|
||||||
longhorn: dynamic(() => import("components/widgets/longhorn/longhorn")),
|
longhorn: dynamic(() => import("components/widgets/longhorn/longhorn")),
|
||||||
kubernetes: dynamic(() => import("components/widgets/kubernetes/kubernetes")),
|
kubernetes: dynamic(() => import("components/widgets/kubernetes/kubernetes")),
|
||||||
stocks: dynamic(() => import("components/widgets/stocks/stocks")),
|
stocks: dynamic(() => import("components/widgets/stocks/stocks")),
|
||||||
deploy: dynamic(() => import("components/widgets/deploy/deploy"), { ssr: false }),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Widget({ widget, style }) {
|
export default function Widget({ widget, style }) {
|
||||||
|
|
|
||||||
|
|
@ -67,18 +67,11 @@ const tailwindSafelist = [
|
||||||
"2xl:h-0 2xl:h-1 2xl:h-2 2xl:h-3 2xl:h-4 2xl:h-5 2xl:h-6 2xl:h-7 2xl:h-8 2xl:h-9 2xl:h-10 2xl:h-11 2xl:h-12 2xl:h-13 2xl:h-14 2xl:h-15 2xl:h-16 2xl:h-17 2xl:h-18 2xl:h-19 2xl:h-20 2xl:h-21 2xl:h-22 2xl:h-23 2xl:h-24 2xl:h-25 2xl:h-26 2xl:h-27 2xl:h-28 2xl:h-29 2xl:h-30 2xl:h-31 2xl:h-32 2xl:h-33 2xl:h-34 2xl:h-35 2xl:h-36 2xl:h-37 2xl:h-38 2xl:h-39 2xl:h-40 2xl:h-41 2xl:h-42 2xl:h-43 2xl:h-44 2xl:h-45 2xl:h-46 2xl:h-47 2xl:h-48 2xl:h-49 2xl:h-50 2xl:h-51 2xl:h-52 2xl:h-53 2xl:h-54 2xl:h-55 2xl:h-56 2xl:h-57 2xl:h-58 2xl:h-59 2xl:h-60 2xl:h-61 2xl:h-62 2xl:h-63 2xl:h-64 2xl:h-65 2xl:h-66 2xl:h-67 2xl:h-68 2xl:h-69 2xl:h-70 2xl:h-71 2xl:h-72 2xl:h-73 2xl:h-74 2xl:h-75 2xl:h-76 2xl:h-77 2xl:h-78 2xl:h-79 2xl:h-80 2xl:h-81 2xl:h-82 2xl:h-83 2xl:h-84 2xl:h-85 2xl:h-86 2xl:h-87 2xl:h-88 2xl:h-89 2xl:h-90 2xl:h-91 2xl:h-92 2xl:h-93 2xl:h-94 2xl:h-95 2xl:h-96",
|
"2xl:h-0 2xl:h-1 2xl:h-2 2xl:h-3 2xl:h-4 2xl:h-5 2xl:h-6 2xl:h-7 2xl:h-8 2xl:h-9 2xl:h-10 2xl:h-11 2xl:h-12 2xl:h-13 2xl:h-14 2xl:h-15 2xl:h-16 2xl:h-17 2xl:h-18 2xl:h-19 2xl:h-20 2xl:h-21 2xl:h-22 2xl:h-23 2xl:h-24 2xl:h-25 2xl:h-26 2xl:h-27 2xl:h-28 2xl:h-29 2xl:h-30 2xl:h-31 2xl:h-32 2xl:h-33 2xl:h-34 2xl:h-35 2xl:h-36 2xl:h-37 2xl:h-38 2xl:h-39 2xl:h-40 2xl:h-41 2xl:h-42 2xl:h-43 2xl:h-44 2xl:h-45 2xl:h-46 2xl:h-47 2xl:h-48 2xl:h-49 2xl:h-50 2xl:h-51 2xl:h-52 2xl:h-53 2xl:h-54 2xl:h-55 2xl:h-56 2xl:h-57 2xl:h-58 2xl:h-59 2xl:h-60 2xl:h-61 2xl:h-62 2xl:h-63 2xl:h-64 2xl:h-65 2xl:h-66 2xl:h-67 2xl:h-68 2xl:h-69 2xl:h-70 2xl:h-71 2xl:h-72 2xl:h-73 2xl:h-74 2xl:h-75 2xl:h-76 2xl:h-77 2xl:h-78 2xl:h-79 2xl:h-80 2xl:h-81 2xl:h-82 2xl:h-83 2xl:h-84 2xl:h-85 2xl:h-86 2xl:h-87 2xl:h-88 2xl:h-89 2xl:h-90 2xl:h-91 2xl:h-92 2xl:h-93 2xl:h-94 2xl:h-95 2xl:h-96",
|
||||||
];
|
];
|
||||||
|
|
||||||
const basePathMiddleware = (useSWRNext) => (key, fetcher, config) => {
|
|
||||||
const bp = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
|
||||||
const adjustedKey = bp && typeof key === "string" ? `${bp}${key}` : key;
|
|
||||||
return useSWRNext(adjustedKey, fetcher, config);
|
|
||||||
};
|
|
||||||
|
|
||||||
function MyApp({ Component, pageProps }) {
|
function MyApp({ Component, pageProps }) {
|
||||||
return (
|
return (
|
||||||
<SWRConfig
|
<SWRConfig
|
||||||
value={{
|
value={{
|
||||||
fetcher: (resource, init) => fetch(resource, init).then((res) => res.json()),
|
fetcher: (resource, init) => fetch(resource, init).then((res) => res.json()),
|
||||||
use: [basePathMiddleware],
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Head>
|
<Head>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ export default function Document() {
|
||||||
<Head>
|
<Head>
|
||||||
<meta name="mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
<link rel="manifest" href="/site.webmanifest?v=4" crossOrigin="use-credentials" />
|
<link rel="manifest" href="/site.webmanifest?v=4" crossOrigin="use-credentials" />
|
||||||
<link rel="preload" href={`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/config/custom.css`} as="style" />
|
<link rel="preload" href="/api/config/custom.css" as="style" />
|
||||||
<link rel="stylesheet" href={`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/config/custom.css`} /> {/* eslint-disable-line @next/next/no-css-tags */}
|
<link rel="stylesheet" href="/api/config/custom.css" /> {/* eslint-disable-line @next/next/no-css-tags */}
|
||||||
</Head>
|
</Head>
|
||||||
<body>
|
<body>
|
||||||
<Main />
|
<Main />
|
||||||
|
|
|
||||||
|
|
@ -63,15 +63,14 @@ export async function getStaticProps() {
|
||||||
const widgets = await widgetsResponse();
|
const widgets = await widgetsResponse();
|
||||||
const language = normalizeLanguage(settings.language);
|
const language = normalizeLanguage(settings.language);
|
||||||
|
|
||||||
const bp = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
initialSettings: settings,
|
initialSettings: settings,
|
||||||
fallback: {
|
fallback: {
|
||||||
[`${bp}/api/services`]: services,
|
"/api/services": services,
|
||||||
[`${bp}/api/bookmarks`]: bookmarks,
|
"/api/bookmarks": bookmarks,
|
||||||
[`${bp}/api/widgets`]: widgets,
|
"/api/widgets": widgets,
|
||||||
[`${bp}/api/hash`]: false,
|
"/api/hash": false,
|
||||||
},
|
},
|
||||||
...(await serverSideTranslations(language)),
|
...(await serverSideTranslations(language)),
|
||||||
},
|
},
|
||||||
|
|
@ -84,10 +83,10 @@ export async function getStaticProps() {
|
||||||
props: {
|
props: {
|
||||||
initialSettings: {},
|
initialSettings: {},
|
||||||
fallback: {
|
fallback: {
|
||||||
[`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/services`]: [],
|
"/api/services": [],
|
||||||
[`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/bookmarks`]: [],
|
"/api/bookmarks": [],
|
||||||
[`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/widgets`]: [],
|
"/api/widgets": [],
|
||||||
[`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/hash`]: false,
|
"/api/hash": false,
|
||||||
},
|
},
|
||||||
...(await serverSideTranslations("en")),
|
...(await serverSideTranslations("en")),
|
||||||
},
|
},
|
||||||
|
|
@ -121,7 +120,7 @@ function Index({ initialSettings, fallback }) {
|
||||||
setStale(true);
|
setStale(true);
|
||||||
localStorage.setItem("hash", hashData.hash);
|
localStorage.setItem("hash", hashData.hash);
|
||||||
|
|
||||||
fetch(`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/revalidate`).then((res) => {
|
fetch("/api/revalidate").then((res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
@ -435,7 +434,7 @@ function Home({ initialSettings }) {
|
||||||
<meta name="color-scheme" content="dark light"></meta>
|
<meta name="color-scheme" content="dark light"></meta>
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<Script src={`${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/config/custom.js`} />
|
<Script src="/api/config/custom.js" />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
|
||||||
|
|
@ -435,11 +435,6 @@ export function cleanServiceGroups(groups) {
|
||||||
|
|
||||||
// grafana
|
// grafana
|
||||||
alerts,
|
alerts,
|
||||||
|
|
||||||
// deploy
|
|
||||||
service: deployService,
|
|
||||||
label: deployLabel,
|
|
||||||
apiBase: deployApiBase,
|
|
||||||
} = widgetData;
|
} = widgetData;
|
||||||
|
|
||||||
let fieldsList = fields;
|
let fieldsList = fields;
|
||||||
|
|
@ -690,11 +685,6 @@ export function cleanServiceGroups(groups) {
|
||||||
if (type === "grafana") {
|
if (type === "grafana") {
|
||||||
if (alerts) widget.alerts = alerts;
|
if (alerts) widget.alerts = alerts;
|
||||||
}
|
}
|
||||||
if (type === "deploy") {
|
|
||||||
if (deployService) widget.service = deployService;
|
|
||||||
if (deployLabel) widget.label = deployLabel;
|
|
||||||
if (deployApiBase) widget.apiBase = deployApiBase;
|
|
||||||
}
|
|
||||||
if (type === "unraid") {
|
if (type === "unraid") {
|
||||||
if (pool1) widget.pool1 = pool1;
|
if (pool1) widget.pool1 = pool1;
|
||||||
if (pool2) widget.pool2 = pool2;
|
if (pool2) widget.pool2 = pool2;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export function formatProxyUrl(widget, endpoint, queryParams) {
|
||||||
if (queryParams) {
|
if (queryParams) {
|
||||||
params.append("query", JSON.stringify(queryParams));
|
params.append("query", JSON.stringify(queryParams));
|
||||||
}
|
}
|
||||||
return `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/api/services/proxy?${params.toString()}`;
|
return `/api/services/proxy?${params.toString()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function asJson(data) {
|
export function asJson(data) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ const components = {
|
||||||
iframe: dynamic(() => import("./iframe/component")),
|
iframe: dynamic(() => import("./iframe/component")),
|
||||||
customapi: dynamic(() => import("./customapi/component")),
|
customapi: dynamic(() => import("./customapi/component")),
|
||||||
deluge: dynamic(() => import("./deluge/component")),
|
deluge: dynamic(() => import("./deluge/component")),
|
||||||
deploy: dynamic(() => import("./deploy/component")),
|
|
||||||
develancacheui: dynamic(() => import("./develancacheui/component")),
|
develancacheui: dynamic(() => import("./develancacheui/component")),
|
||||||
diskstation: dynamic(() => import("./diskstation/component")),
|
diskstation: dynamic(() => import("./diskstation/component")),
|
||||||
dispatcharr: dynamic(() => import("./dispatcharr/component")),
|
dispatcharr: dynamic(() => import("./dispatcharr/component")),
|
||||||
|
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
import { useState } from "react";
|
|
||||||
import useSWR from "swr";
|
|
||||||
|
|
||||||
const STATUS_COLORS = {
|
|
||||||
idle: "text-theme-500 dark:text-theme-400",
|
|
||||||
running: "text-blue-500 dark:text-blue-400",
|
|
||||||
success: "text-emerald-500 dark:text-emerald-400",
|
|
||||||
failed: "text-red-500 dark:text-red-400",
|
|
||||||
};
|
|
||||||
|
|
||||||
const STATUS_LABELS = {
|
|
||||||
idle: "Never deployed",
|
|
||||||
running: "Deploying...",
|
|
||||||
success: "Deployed",
|
|
||||||
failed: "Failed",
|
|
||||||
};
|
|
||||||
|
|
||||||
function formatTime(iso) {
|
|
||||||
if (!iso) return null;
|
|
||||||
const d = new Date(iso);
|
|
||||||
return d.toLocaleString("en-GB", { dateStyle: "short", timeStyle: "short", hourCycle: "h23" });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function DeployComponent({ service }) {
|
|
||||||
const { service: svcName, label, apiBase = "/deploy-api" } = service?.widget ?? {};
|
|
||||||
const bp = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
|
||||||
// SWR middleware already prepends bp, so statusUrl must NOT include it
|
|
||||||
const statusUrl = svcName ? `${apiBase}/status/${svcName}` : null;
|
|
||||||
|
|
||||||
const { data, mutate } = useSWR(statusUrl, {
|
|
||||||
refreshInterval: (d) => (d?.status === "running" ? 2000 : 10000),
|
|
||||||
});
|
|
||||||
|
|
||||||
const [triggering, setTriggering] = useState(false);
|
|
||||||
|
|
||||||
const status = data?.status ?? "idle";
|
|
||||||
const lastRun = data?.last_run ? formatTime(data.last_run) : null;
|
|
||||||
const isRunning = status === "running";
|
|
||||||
|
|
||||||
const handleDeploy = async () => {
|
|
||||||
if (isRunning || triggering) return;
|
|
||||||
setTriggering(true);
|
|
||||||
try {
|
|
||||||
await fetch(`${bp}${apiBase}/deploy/${svcName}`, { method: "POST" });
|
|
||||||
await mutate();
|
|
||||||
} finally {
|
|
||||||
setTriggering(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!svcName) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-row items-center justify-between px-2 py-1 gap-2 w-full">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<span className={`text-xs font-semibold ${STATUS_COLORS[status] ?? STATUS_COLORS.idle}`}>
|
|
||||||
{isRunning ? <span className="animate-pulse">{STATUS_LABELS.running}</span> : (STATUS_LABELS[status] ?? status)}
|
|
||||||
</span>
|
|
||||||
{lastRun && (
|
|
||||||
<span className="text-theme-500 dark:text-theme-400 text-xs opacity-60">{lastRun}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handleDeploy}
|
|
||||||
disabled={isRunning || triggering}
|
|
||||||
className={[
|
|
||||||
"px-3 py-1 rounded text-xs font-medium transition-colors shrink-0",
|
|
||||||
isRunning || triggering
|
|
||||||
? "bg-theme-300 dark:bg-theme-600 text-theme-500 dark:text-theme-400 cursor-not-allowed"
|
|
||||||
: "bg-theme-500 hover:bg-theme-600 dark:bg-theme-600 dark:hover:bg-theme-500 text-white cursor-pointer",
|
|
||||||
].join(" ")}
|
|
||||||
>
|
|
||||||
{isRunning ? "Running..." : `Deploy ${label ?? svcName}`}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue