mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-26 14:01:16 -07:00
Compare commits
3
Commits
9491b660fa
..
v2.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5873f8e7d5 | ||
|
|
6099837373 | ||
|
|
21bf7ed8e2 |
@@ -10,7 +10,6 @@ version-resolver:
|
|||||||
- 'breaking-change'
|
- 'breaking-change'
|
||||||
minor:
|
minor:
|
||||||
labels:
|
labels:
|
||||||
- 'minor'
|
|
||||||
- 'enhancement'
|
- 'enhancement'
|
||||||
- 'feature'
|
- 'feature'
|
||||||
patch:
|
patch:
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ on:
|
|||||||
]
|
]
|
||||||
branches: [ dev ]
|
branches: [ dev ]
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
synchronize-with-crowdin:
|
synchronize-with-crowdin:
|
||||||
name: Crowdin Sync
|
name: Crowdin Sync
|
||||||
@@ -23,7 +19,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- name: crowdin action
|
- name: crowdin action
|
||||||
uses: crowdin/github-action@8f01d54f70f1713ee3f09d82c2bbb2daeac28689 # v2
|
uses: crowdin/github-action@c7af9bc98b01694653031fef2a0dc6c7888ce9bc # v2
|
||||||
with:
|
with:
|
||||||
upload_translations: false
|
upload_translations: false
|
||||||
download_translations: true
|
download_translations: true
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ on:
|
|||||||
env:
|
env:
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +27,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -102,7 +101,7 @@ jobs:
|
|||||||
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
|
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
- name: Setup Docker buildx
|
||||||
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
|
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
@@ -23,7 +25,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version-file: ".python-version"
|
python-version-file: ".python-version"
|
||||||
- name: Install uv
|
- name: Install uv
|
||||||
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
uses: astral-sh/setup-uv@ae62891fec2bb8e7d6c99fc78c9fec3a63790f8d # v10.0.0
|
||||||
- run: sudo apt-get install pngquant
|
- run: sudo apt-get install pngquant
|
||||||
- name: Test Docs Build
|
- name: Test Docs Build
|
||||||
run: uv run --frozen zensical build --clean
|
run: uv run --frozen zensical build --clean
|
||||||
@@ -31,10 +33,6 @@ jobs:
|
|||||||
name: Build & Deploy Docs
|
name: Build & Deploy Docs
|
||||||
if: github.repository == 'gethomepage/homepage' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
if: github.repository == 'gethomepage/homepage' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
environment:
|
environment:
|
||||||
name: github-pages
|
name: github-pages
|
||||||
url: ${{ steps.deployment.outputs.page_url }}
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
@@ -45,7 +43,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version-file: ".python-version"
|
python-version-file: ".python-version"
|
||||||
- name: Install uv
|
- name: Install uv
|
||||||
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
uses: astral-sh/setup-uv@ae62891fec2bb8e7d6c99fc78c9fec3a63790f8d # v10.0.0
|
||||||
- run: sudo apt-get install pngquant
|
- run: sudo apt-get install pngquant
|
||||||
- name: Build Docs
|
- name: Build Docs
|
||||||
run: uv run --frozen zensical build --clean
|
run: uv run --frozen zensical build --clean
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ on:
|
|||||||
discussion:
|
discussion:
|
||||||
types: [labeled]
|
types: [labeled]
|
||||||
|
|
||||||
permissions: {}
|
permissions:
|
||||||
|
discussions: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
close-needs-discussion:
|
close-needs-discussion:
|
||||||
name: Issues Need Discussion
|
name: Issues Need Discussion
|
||||||
if: github.event_name == 'issues' && github.event.label.name == 'needs-discussion'
|
if: github.event_name == 'issues' && github.event.label.name == 'needs-discussion'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -49,8 +49,6 @@ jobs:
|
|||||||
name: Discussions Need Information
|
name: Discussions Need Information
|
||||||
if: github.event_name == 'discussion' && github.event.label.name == 'needs-information'
|
if: github.event_name == 'discussion' && github.event.label.name == 'needs-information'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
discussions: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
merge_group:
|
merge_group:
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Linting Checks
|
name: Linting Checks
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ name: PR Quality
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
issues: read
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ on:
|
|||||||
types: [labeled]
|
types: [labeled]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
issues: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ on:
|
|||||||
- cron: '0 3 * * *'
|
- cron: '0 3 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions: {}
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
discussions: write
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: lock
|
group: lock
|
||||||
@@ -14,9 +17,6 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
name: 'Stale'
|
name: 'Stale'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@1e223db275d687790206a7acac4d1a11bd6fe629 # v10
|
- uses: actions/stale@1e223db275d687790206a7acac4d1a11bd6fe629 # v10
|
||||||
with:
|
with:
|
||||||
@@ -31,10 +31,6 @@ jobs:
|
|||||||
lock-threads:
|
lock-threads:
|
||||||
name: 'Lock Old Threads'
|
name: 'Lock Old Threads'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
discussions: write
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: dessant/lock-threads@89ae32b08ed1a541efecbab17912962a5e38981c # v6.0.2
|
- uses: dessant/lock-threads@89ae32b08ed1a541efecbab17912962a5e38981c # v6.0.2
|
||||||
with:
|
with:
|
||||||
@@ -60,8 +56,6 @@ jobs:
|
|||||||
close-answered-discussions:
|
close-answered-discussions:
|
||||||
name: 'Close Answered Discussions'
|
name: 'Close Answered Discussions'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
discussions: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -118,8 +112,6 @@ jobs:
|
|||||||
close-outdated-discussions:
|
close-outdated-discussions:
|
||||||
name: 'Close Outdated Discussions'
|
name: 'Close Outdated Discussions'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
discussions: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -211,8 +203,6 @@ jobs:
|
|||||||
close-unsupported-feature-requests:
|
close-unsupported-feature-requests:
|
||||||
name: 'Close Unsupported Feature Requests'
|
name: 'Close Unsupported Feature Requests'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
discussions: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
vitest:
|
vitest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ To ensure cohesiveness of various widgets, the following should be used as a gui
|
|||||||
- Note that we reserve the right to decline widgets for projects that are very young (eg < ~1y) or those with a small reach (eg low GitHub stars). Again, this is in an effort to keep overall widget maintenance under control.
|
- Note that we reserve the right to decline widgets for projects that are very young (eg < ~1y) or those with a small reach (eg low GitHub stars). Again, this is in an effort to keep overall widget maintenance under control.
|
||||||
- Widgets should be only one row of blocks
|
- Widgets should be only one row of blocks
|
||||||
- Widgets should be no more than 4 blocks wide and generally conform to the styling / design choices of other widgets
|
- Widgets should be no more than 4 blocks wide and generally conform to the styling / design choices of other widgets
|
||||||
- Use `withWidgetFields(service, defaultFields)` from `utils/widget-fields` to apply default fields and cap configured fields without mutating the service. The helper limits widgets to 4 fields.
|
|
||||||
- Minimize the number of API calls
|
- Minimize the number of API calls
|
||||||
- Avoid the use of custom proxy unless absolutely necessary
|
- Avoid the use of custom proxy unless absolutely necessary
|
||||||
- Widgets should be 'read-only', as in they should not make write changes using the relevant tool's API. Homepage widgets are designed to surface information, not to be a (usually worse) replacement for the tool itself.
|
- Widgets should be 'read-only', as in they should not make write changes using the relevant tool's API. Homepage widgets are designed to surface information, not to be a (usually worse) replacement for the tool itself.
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ See the [crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro/#machines
|
|||||||
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
|
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
|
Without the `limit24h` option, the widget will fetch all alerts which is limited to 100 by the API to avoid performance issues.
|
||||||
`alerts` counts alerts raised by your own engine in the last 24 hours. Alerts originating from the
|
|
||||||
CrowdSec community blocklist are excluded.
|
|
||||||
|
|
||||||
Allowed fields: `["alerts", "bans"]`.
|
Allowed fields: `["alerts", "bans"]`.
|
||||||
|
|
||||||
@@ -21,4 +19,5 @@ widget:
|
|||||||
url: http://crowdsechostorip:port
|
url: http://crowdsechostorip:port
|
||||||
username: localhost # machine_id in crowdsec
|
username: localhost # machine_id in crowdsec
|
||||||
password: password
|
password: password
|
||||||
|
limit24h: true # optional, limits alerts to last 24h. Default: false
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ widget:
|
|||||||
url: https://proxmoxbackupserver.host:port
|
url: https://proxmoxbackupserver.host:port
|
||||||
username: api_token_id
|
username: api_token_id
|
||||||
password: api_token_secret
|
password: api_token_secret
|
||||||
datastore: datastore_name #optional; if omitted, will display a combination of all datastores used / total
|
datastore: datastore_name #optional; if ommitted, will display a combination of all datastores used / total
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -65,6 +65,24 @@ export default defineConfig([
|
|||||||
allowElseIf: true,
|
allowElseIf: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Keep the pre-eslint-plugin-react-hooks v6 lint policy until rules are adopted incrementally
|
||||||
|
"react-hooks/config": "off",
|
||||||
|
"react-hooks/error-boundaries": "off",
|
||||||
|
"react-hooks/exhaustive-deps": "warn",
|
||||||
|
"react-hooks/gating": "off",
|
||||||
|
"react-hooks/globals": "off",
|
||||||
|
"react-hooks/immutability": "off",
|
||||||
|
"react-hooks/incompatible-library": "off",
|
||||||
|
"react-hooks/preserve-manual-memoization": "off",
|
||||||
|
"react-hooks/purity": "off",
|
||||||
|
"react-hooks/refs": "off",
|
||||||
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
"react-hooks/set-state-in-effect": "off",
|
||||||
|
"react-hooks/set-state-in-render": "off",
|
||||||
|
"react-hooks/static-components": "off",
|
||||||
|
"react-hooks/unsupported-syntax": "off",
|
||||||
|
"react-hooks/use-memo": "off",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Vitest tests often intentionally place imports after `vi.mock(...)` to ensure
|
// Vitest tests often intentionally place imports after `vi.mock(...)` to ensure
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homepage",
|
"name": "homepage",
|
||||||
"version": "2.1.0",
|
"version": "2.1.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><circle cx="5" cy="5" r="4"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 96 B |
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Wag asseblief"
|
"wait": "Wag asseblief"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Soek…",
|
"placeholder": "Soek…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "SVE",
|
"cpu": "SVE",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "الرجاء الإنتظار"
|
"wait": "الرجاء الإنتظار"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "بحث …",
|
"placeholder": "بحث …"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "المعالج",
|
"cpu": "المعالج",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Моля изчакайте"
|
"wait": "Моля изчакайте"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Търсене…",
|
"placeholder": "Търсене…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Процесор",
|
"cpu": "Процесор",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Si us plau, espereu"
|
"wait": "Si us plau, espereu"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Cerca…",
|
"placeholder": "Cerca…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Počkejte prosím"
|
"wait": "Počkejte prosím"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Hledat…",
|
"placeholder": "Hledat…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Využití procesoru",
|
"cpu": "Využití procesoru",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Vent venligst"
|
"wait": "Vent venligst"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Søg…",
|
"placeholder": "Søg…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Bitte warten"
|
"wait": "Bitte warten"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Suche…",
|
"placeholder": "Suche…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Παρακαλώ περιμένετε"
|
"wait": "Παρακαλώ περιμένετε"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Αναζήτηση…",
|
"placeholder": "Αναζήτηση…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Επεξεργαστής",
|
"cpu": "Επεξεργαστής",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Please wait"
|
"wait": "Please wait"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Search…",
|
"placeholder": "Search…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Bonvolu atendi"
|
"wait": "Bonvolu atendi"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Serĉi…",
|
"placeholder": "Serĉi…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Ĉefprocesoro",
|
"cpu": "Ĉefprocesoro",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Espera, por favor"
|
"wait": "Espera, por favor"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Buscar…",
|
"placeholder": "Buscar…"
|
||||||
"provider": "Motor de búsqueda: {{name}}",
|
|
||||||
"select_provider": "Seleccionar motores de búsqueda"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Itxaron mesedez"
|
"wait": "Itxaron mesedez"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Bilatu…",
|
"placeholder": "Bilatu…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Odota, ole hyvä"
|
"wait": "Odota, ole hyvä"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Hae…",
|
"placeholder": "Hae…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Veuillez patienter"
|
"wait": "Veuillez patienter"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Recherche…",
|
"placeholder": "Recherche…"
|
||||||
"provider": "Moteur de recherche : {{name}}",
|
|
||||||
"select_provider": "Sélectionnez un moteur de recherche"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "המתן בבקשה"
|
"wait": "המתן בבקשה"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "חיפוש…",
|
"placeholder": "חיפוש…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "מעבד",
|
"cpu": "מעבד",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Please wait"
|
"wait": "Please wait"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Search…",
|
"placeholder": "Search…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Pričekaj"
|
"wait": "Pričekaj"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Traži …",
|
"placeholder": "Traži …"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Kérjük várjon"
|
"wait": "Kérjük várjon"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Keresés…",
|
"placeholder": "Keresés…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Processzor",
|
"cpu": "Processzor",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Harap tunggu"
|
"wait": "Harap tunggu"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Telusuri…",
|
"placeholder": "Telusuri…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Attendi per favore"
|
"wait": "Attendi per favore"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Cerca…",
|
"placeholder": "Cerca…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "お待ちください"
|
"wait": "お待ちください"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "検索…",
|
"placeholder": "検索…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "잠시만 기다리세요"
|
"wait": "잠시만 기다리세요"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "검색…",
|
"placeholder": "검색…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
@@ -474,7 +472,7 @@
|
|||||||
"users": "사용자",
|
"users": "사용자",
|
||||||
"loginsLast24H": "로그인 (24시간)",
|
"loginsLast24H": "로그인 (24시간)",
|
||||||
"failedLoginsLast24H": "실패한 로그인 (24시간)",
|
"failedLoginsLast24H": "실패한 로그인 (24시간)",
|
||||||
"authorizationsLast24H": "인증(24시간)"
|
"authorizationsLast24H": "Auths (24h)"
|
||||||
},
|
},
|
||||||
"proxmox": {
|
"proxmox": {
|
||||||
"mem": "메모리",
|
"mem": "메모리",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Lūdzu, uzgaidiet"
|
"wait": "Lūdzu, uzgaidiet"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Meklēt…",
|
"placeholder": "Meklēt…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Sila tunggu"
|
"wait": "Sila tunggu"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Carian…",
|
"placeholder": "Carian…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Even geduld"
|
"wait": "Even geduld"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Zoeken…",
|
"placeholder": "Zoeken…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Vennligst vent"
|
"wait": "Vennligst vent"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Søk…",
|
"placeholder": "Søk…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Proszę czekać"
|
"wait": "Proszę czekać"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Szukaj…",
|
"placeholder": "Szukaj…"
|
||||||
"provider": "Wyszukiwarka: {{name}}",
|
|
||||||
"select_provider": "Wybierz wyszukiwarkę"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Procesor",
|
"cpu": "Procesor",
|
||||||
@@ -474,7 +472,7 @@
|
|||||||
"users": "Użytkownicy",
|
"users": "Użytkownicy",
|
||||||
"loginsLast24H": "Logowania (24h)",
|
"loginsLast24H": "Logowania (24h)",
|
||||||
"failedLoginsLast24H": "Nieudane logowania (24h)",
|
"failedLoginsLast24H": "Nieudane logowania (24h)",
|
||||||
"authorizationsLast24H": "Uwierzytelnienia (24h)"
|
"authorizationsLast24H": "Auths (24h)"
|
||||||
},
|
},
|
||||||
"proxmox": {
|
"proxmox": {
|
||||||
"mem": "RAM",
|
"mem": "RAM",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Por favor aguarde"
|
"wait": "Por favor aguarde"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Pesquisar…",
|
"placeholder": "Pesquisar…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Por favor, aguarde"
|
"wait": "Por favor, aguarde"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Pesquisar…",
|
"placeholder": "Pesquisar…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Va rugăm așteptați"
|
"wait": "Va rugăm așteptați"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Caută…",
|
"placeholder": "Caută…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Procesor",
|
"cpu": "Procesor",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Пожалуйста, подождите"
|
"wait": "Пожалуйста, подождите"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Поиск…",
|
"placeholder": "Поиск…"
|
||||||
"provider": "Поисковая система: {{name}}",
|
|
||||||
"select_provider": "Выберите поисковую систему"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "ЦП",
|
"cpu": "ЦП",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Počkajte prosím"
|
"wait": "Počkajte prosím"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Hľadať…",
|
"placeholder": "Hľadať…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Prosimo počakajte"
|
"wait": "Prosimo počakajte"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Iskanje…",
|
"placeholder": "Iskanje…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Молим сачекајте"
|
"wait": "Молим сачекајте"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Претражи…",
|
"placeholder": "Претражи…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "Процесор",
|
"cpu": "Процесор",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Vänligen vänta"
|
"wait": "Vänligen vänta"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Sök…",
|
"placeholder": "Sök…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "దయచేసి వేచి ఉండండి"
|
"wait": "దయచేసి వేచి ఉండండి"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "వెతకండి…",
|
"placeholder": "వెతకండి…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "సీపియూ",
|
"cpu": "సీపియూ",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "โปรดรอ"
|
"wait": "โปรดรอ"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "ค้นหา…",
|
"placeholder": "ค้นหา…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "ซีพียู",
|
"cpu": "ซีพียู",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Lütfen bekleyin"
|
"wait": "Lütfen bekleyin"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Ara…",
|
"placeholder": "Ara…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "İşlemci",
|
"cpu": "İşlemci",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Будь ласка, зачекайте"
|
"wait": "Будь ласка, зачекайте"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Пошук…",
|
"placeholder": "Пошук…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "ЦП",
|
"cpu": "ЦП",
|
||||||
|
|||||||
+200
-202
@@ -21,7 +21,7 @@
|
|||||||
"seconds": "giây"
|
"seconds": "giây"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"signout": "Đăng xuất"
|
"signout": "Sign out"
|
||||||
},
|
},
|
||||||
"widget": {
|
"widget": {
|
||||||
"missing_type": "Thiếu loại Widget: {{type}}",
|
"missing_type": "Thiếu loại Widget: {{type}}",
|
||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "Vui lòng chờ"
|
"wait": "Vui lòng chờ"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Tìm kiếm…",
|
"placeholder": "Tìm kiếm…"
|
||||||
"provider": "Công cụ tìm kiếm: {{name}}",
|
|
||||||
"select_provider": "Chọn công cụ tìm kiếm"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
@@ -50,7 +48,7 @@
|
|||||||
"free": "Dư",
|
"free": "Dư",
|
||||||
"used": "Đã dùng",
|
"used": "Đã dùng",
|
||||||
"load": "\n",
|
"load": "\n",
|
||||||
"temp": "Tạm thời",
|
"temp": "TEMP",
|
||||||
"max": "Tối đa",
|
"max": "Tối đa",
|
||||||
"uptime": "UP"
|
"uptime": "UP"
|
||||||
},
|
},
|
||||||
@@ -66,24 +64,24 @@
|
|||||||
"wlan_devices": "Thiết bị trong mạng WLAN",
|
"wlan_devices": "Thiết bị trong mạng WLAN",
|
||||||
"lan_users": "Người dùng mạng LAN",
|
"lan_users": "Người dùng mạng LAN",
|
||||||
"wlan_users": "Người dùng mạng WLAN",
|
"wlan_users": "Người dùng mạng WLAN",
|
||||||
"up": "Hoạt động",
|
"up": "UP",
|
||||||
"down": "Không hoạt động",
|
"down": "DOWN",
|
||||||
"wait": "Vui lòng chờ",
|
"wait": "Vui lòng chờ",
|
||||||
"empty_data": "Trạng thái hệ thống phụ không xác định"
|
"empty_data": "Trạng thái hệ thống phụ không xác định"
|
||||||
},
|
},
|
||||||
"unifi_drive": {
|
"unifi_drive": {
|
||||||
"healthy": "Bình thường",
|
"healthy": "Healthy",
|
||||||
"degraded": "Suy giảm",
|
"degraded": "Degraded",
|
||||||
"no_data": "Không có dữ liệu"
|
"no_data": "No storage data available"
|
||||||
},
|
},
|
||||||
"duplicati": {
|
"duplicati": {
|
||||||
"jobs": "Tác vụ",
|
"jobs": "Jobs",
|
||||||
"stored": "Đã lưu",
|
"stored": "Stored",
|
||||||
"lastBackup": "Lần chạy cuối",
|
"lastBackup": "Last Run",
|
||||||
"nextRun": "Lần chạy tiếp theo",
|
"nextRun": "Next Run",
|
||||||
"running": "Đang chạy",
|
"running": "Running",
|
||||||
"warnings": "Cảnh báo",
|
"warnings": "Warnings",
|
||||||
"errors": "Lỗi"
|
"errors": "Errors"
|
||||||
},
|
},
|
||||||
"docker": {
|
"docker": {
|
||||||
"rx": "RX",
|
"rx": "RX",
|
||||||
@@ -98,8 +96,8 @@
|
|||||||
"starting": "Đang bắt đầu",
|
"starting": "Đang bắt đầu",
|
||||||
"unhealthy": "Bất thường",
|
"unhealthy": "Bất thường",
|
||||||
"not_found": "Không tìm thấy",
|
"not_found": "Không tìm thấy",
|
||||||
"exited": "Đã thoát",
|
"exited": "Exited",
|
||||||
"partial": "Một phần"
|
"partial": "Partial"
|
||||||
},
|
},
|
||||||
"ping": {
|
"ping": {
|
||||||
"error": "Lỗi",
|
"error": "Lỗi",
|
||||||
@@ -120,35 +118,35 @@
|
|||||||
"playing": "Đang chơi",
|
"playing": "Đang chơi",
|
||||||
"transcoding": "Chuyển định dạng",
|
"transcoding": "Chuyển định dạng",
|
||||||
"bitrate": "Bitrate",
|
"bitrate": "Bitrate",
|
||||||
"no_active": "Không có luồng đang hoạt động",
|
"no_active": "No Active Streams",
|
||||||
"movies": "Phim ảnh",
|
"movies": "Phim ảnh",
|
||||||
"series": "Series",
|
"series": "Series",
|
||||||
"episodes": "Tập",
|
"episodes": "Episodes",
|
||||||
"songs": "Bài hát"
|
"songs": "Bài hát"
|
||||||
},
|
},
|
||||||
"jellyfin": {
|
"jellyfin": {
|
||||||
"playing": "Đang phát",
|
"playing": "Playing",
|
||||||
"transcoding": "Đang chuyển mã",
|
"transcoding": "Transcoding",
|
||||||
"bitrate": "Tốc độ bit",
|
"bitrate": "Bitrate",
|
||||||
"no_active": "Không có luồng đang hoạt động",
|
"no_active": "No Active Streams",
|
||||||
"movies": "Phim",
|
"movies": "Movies",
|
||||||
"series": "Series",
|
"series": "Series",
|
||||||
"episodes": "Tập",
|
"episodes": "Episodes",
|
||||||
"songs": "Bài hát",
|
"songs": "Songs",
|
||||||
"albums": "Album"
|
"albums": "Albums"
|
||||||
},
|
},
|
||||||
"esphome": {
|
"esphome": {
|
||||||
"offline": "Offline",
|
"offline": "Offline",
|
||||||
"offline_alt": "Offline",
|
"offline_alt": "Offline",
|
||||||
"online": "Online",
|
"online": "Online",
|
||||||
"total": "Tổng cộng",
|
"total": "Total",
|
||||||
"unknown": "Không xác định"
|
"unknown": "Không xác định"
|
||||||
},
|
},
|
||||||
"evcc": {
|
"evcc": {
|
||||||
"pv_power": "Công suất phát",
|
"pv_power": "Production",
|
||||||
"battery_soc": "Pin",
|
"battery_soc": "Pin",
|
||||||
"grid_power": "Lưới",
|
"grid_power": "Lưới",
|
||||||
"home_power": "Công suất tiêu thụ",
|
"home_power": "Consumption",
|
||||||
"charge_power": "Bộ sạc",
|
"charge_power": "Bộ sạc",
|
||||||
"kilowatt": "kW"
|
"kilowatt": "kW"
|
||||||
},
|
},
|
||||||
@@ -156,7 +154,7 @@
|
|||||||
"download": "Tải xuống",
|
"download": "Tải xuống",
|
||||||
"upload": "Tải lên",
|
"upload": "Tải lên",
|
||||||
"leech": "",
|
"leech": "",
|
||||||
"seed": "Seeder"
|
"seed": "Seed"
|
||||||
},
|
},
|
||||||
"freshrss": {
|
"freshrss": {
|
||||||
"subscriptions": "Đăng ký",
|
"subscriptions": "Đăng ký",
|
||||||
@@ -175,115 +173,115 @@
|
|||||||
"maxDown": "Tải xuống tối đa",
|
"maxDown": "Tải xuống tối đa",
|
||||||
"maxUp": "Tải lên tối đa",
|
"maxUp": "Tải lên tối đa",
|
||||||
"down": "Down",
|
"down": "Down",
|
||||||
"up": "Tải lên",
|
"up": "Up",
|
||||||
"received": "Đã nhận",
|
"received": "Received",
|
||||||
"sent": "Đã gửi",
|
"sent": "Sent",
|
||||||
"externalIPAddress": "Địa chỉ IP bên ngoài",
|
"externalIPAddress": "Ext. IP",
|
||||||
"externalIPv6Address": "Địa chỉ IPv6 bên ngoài",
|
"externalIPv6Address": "Ext. IPv6",
|
||||||
"externalIPv6Prefix": "Tiền tố IPv6 bên ngoài"
|
"externalIPv6Prefix": "Ext. IPv6-Prefix"
|
||||||
},
|
},
|
||||||
"caddy": {
|
"caddy": {
|
||||||
"upstreams": "Máy chủ backend",
|
"upstreams": "Upstreams",
|
||||||
"requests": "Yêu cầu hiện tại",
|
"requests": "Current requests",
|
||||||
"requests_failed": "Yêu cầu thất bại"
|
"requests_failed": "Failed requests"
|
||||||
},
|
},
|
||||||
"changedetectionio": {
|
"changedetectionio": {
|
||||||
"totalObserved": "Tổng số đã theo dõi",
|
"totalObserved": "Total Observed",
|
||||||
"diffsDetected": "Số thay đổi đã phát hiện"
|
"diffsDetected": "Diffs Detected"
|
||||||
},
|
},
|
||||||
"channelsdvrserver": {
|
"channelsdvrserver": {
|
||||||
"shows": "Chương trình",
|
"shows": "Shows",
|
||||||
"recordings": "Bản ghi",
|
"recordings": "Recordings",
|
||||||
"scheduled": "Đã lên lịch",
|
"scheduled": "Scheduled",
|
||||||
"passes": "Quy tắc ghi"
|
"passes": "Passes"
|
||||||
},
|
},
|
||||||
"tautulli": {
|
"tautulli": {
|
||||||
"playing": "Đang phát",
|
"playing": "Playing",
|
||||||
"transcoding": "Đang chuyển mã",
|
"transcoding": "Transcoding",
|
||||||
"bitrate": "Tốc độ bit",
|
"bitrate": "Bitrate",
|
||||||
"no_active": "Không có luồng đang hoạt động",
|
"no_active": "No Active Streams",
|
||||||
"plex_connection_error": "Kiểm tra kết nối Plex"
|
"plex_connection_error": "Check Plex Connection"
|
||||||
},
|
},
|
||||||
"tracearr": {
|
"tracearr": {
|
||||||
"no_active": "Không có luồng đang hoạt động",
|
"no_active": "No Active Streams",
|
||||||
"streams": "Luồng",
|
"streams": "Streams",
|
||||||
"transcodes": "Luồng chuyển mã",
|
"transcodes": "Transcodes",
|
||||||
"directplay": "Phát trực tiếp",
|
"directplay": "Direct Play",
|
||||||
"bitrate": "Tốc độ bit"
|
"bitrate": "Bitrate"
|
||||||
},
|
},
|
||||||
"omada": {
|
"omada": {
|
||||||
"connectedAp": "AP đã kết nối",
|
"connectedAp": "Connected APs",
|
||||||
"activeUser": "Thiết bị đang hoạt động",
|
"activeUser": "Active devices",
|
||||||
"alerts": "Cảnh báo",
|
"alerts": "Alerts",
|
||||||
"connectedGateways": "Gateway đã kết nối",
|
"connectedGateways": "Connected gateways",
|
||||||
"connectedSwitches": "Switch đã kết nối"
|
"connectedSwitches": "Connected switches"
|
||||||
},
|
},
|
||||||
"nzbget": {
|
"nzbget": {
|
||||||
"rate": "Tốc độ",
|
"rate": "Rate",
|
||||||
"remaining": "Còn lại",
|
"remaining": "Remaining",
|
||||||
"downloaded": "Đã tải"
|
"downloaded": "Đã tải"
|
||||||
},
|
},
|
||||||
"plex": {
|
"plex": {
|
||||||
"streams": "Luồng đang hoạt động",
|
"streams": "Active Streams",
|
||||||
"albums": "Album",
|
"albums": "Albums",
|
||||||
"movies": "Phim",
|
"movies": "Movies",
|
||||||
"tv": "Chương trình TV"
|
"tv": "TV Shows"
|
||||||
},
|
},
|
||||||
"sabnzbd": {
|
"sabnzbd": {
|
||||||
"rate": "Tốc độ",
|
"rate": "Rate",
|
||||||
"queue": "Hàng chờ",
|
"queue": "Hàng chờ",
|
||||||
"timeleft": "Thời gian còn lại"
|
"timeleft": "Thời gian còn lại"
|
||||||
},
|
},
|
||||||
"rutorrent": {
|
"rutorrent": {
|
||||||
"active": "Hoạt động",
|
"active": "Hoạt động",
|
||||||
"upload": "Tải lên",
|
"upload": "Upload",
|
||||||
"download": "Tải xuống"
|
"download": "Download"
|
||||||
},
|
},
|
||||||
"transmission": {
|
"transmission": {
|
||||||
"download": "Tải xuống",
|
"download": "Download",
|
||||||
"upload": "Tải lên",
|
"upload": "Upload",
|
||||||
"leech": "Leecher",
|
"leech": "Leech",
|
||||||
"seed": "Seeder"
|
"seed": "Seed"
|
||||||
},
|
},
|
||||||
"qbittorrent": {
|
"qbittorrent": {
|
||||||
"download": "Tải xuống",
|
"download": "Download",
|
||||||
"upload": "Tải lên",
|
"upload": "Upload",
|
||||||
"leech": "Leecher",
|
"leech": "Leech",
|
||||||
"seed": "Seeder"
|
"seed": "Seed"
|
||||||
},
|
},
|
||||||
"qnap": {
|
"qnap": {
|
||||||
"cpuUsage": "Mức sử dụng CPU",
|
"cpuUsage": "CPU Usage",
|
||||||
"memUsage": "Mức sử dụng bộ nhớ",
|
"memUsage": "MEM Usage",
|
||||||
"systemTempC": "Nhiệt độ hệ thống",
|
"systemTempC": "System Temp",
|
||||||
"poolUsage": "Mức sử dụng pool",
|
"poolUsage": "Pool Usage",
|
||||||
"volumeUsage": "Mức sử dụng volume",
|
"volumeUsage": "Volume Usage",
|
||||||
"invalid": "Không hợp lệ"
|
"invalid": "Invalid"
|
||||||
},
|
},
|
||||||
"deluge": {
|
"deluge": {
|
||||||
"download": "Tải xuống",
|
"download": "Download",
|
||||||
"upload": "Tải lên",
|
"upload": "Upload",
|
||||||
"leech": "Leecher",
|
"leech": "Leech",
|
||||||
"seed": "Seeder"
|
"seed": "Seed"
|
||||||
},
|
},
|
||||||
"develancacheui": {
|
"develancacheui": {
|
||||||
"cachehitbytes": "Dung lượng cache hit",
|
"cachehitbytes": "Cache Hit Bytes",
|
||||||
"cachemissbytes": "Dung lượng cache miss"
|
"cachemissbytes": "Cache Miss Bytes"
|
||||||
},
|
},
|
||||||
"downloadstation": {
|
"downloadstation": {
|
||||||
"download": "Tải xuống",
|
"download": "Download",
|
||||||
"upload": "Tải lên",
|
"upload": "Upload",
|
||||||
"leech": "Leecher",
|
"leech": "Leech",
|
||||||
"seed": "Seeder"
|
"seed": "Seed"
|
||||||
},
|
},
|
||||||
"sonarr": {
|
"sonarr": {
|
||||||
"wanted": "Cần tải",
|
"wanted": "Wanted",
|
||||||
"queued": "Queued",
|
"queued": "Queued",
|
||||||
"series": "Phim bộ",
|
"series": "Series",
|
||||||
"queue": "Queue",
|
"queue": "Queue",
|
||||||
"unknown": "Unknown"
|
"unknown": "Unknown"
|
||||||
},
|
},
|
||||||
"radarr": {
|
"radarr": {
|
||||||
"wanted": "Cần tải",
|
"wanted": "Wanted",
|
||||||
"missing": "Missing",
|
"missing": "Missing",
|
||||||
"queued": "Queued",
|
"queued": "Queued",
|
||||||
"movies": "Movies",
|
"movies": "Movies",
|
||||||
@@ -291,12 +289,12 @@
|
|||||||
"unknown": "Unknown"
|
"unknown": "Unknown"
|
||||||
},
|
},
|
||||||
"lidarr": {
|
"lidarr": {
|
||||||
"wanted": "Cần tải",
|
"wanted": "Wanted",
|
||||||
"queued": "Queued",
|
"queued": "Queued",
|
||||||
"artists": "Artists"
|
"artists": "Artists"
|
||||||
},
|
},
|
||||||
"readarr": {
|
"readarr": {
|
||||||
"wanted": "Cần tải",
|
"wanted": "Wanted",
|
||||||
"queued": "Queued",
|
"queued": "Queued",
|
||||||
"books": "Sách"
|
"books": "Sách"
|
||||||
},
|
},
|
||||||
@@ -336,66 +334,66 @@
|
|||||||
"latency": "Latency"
|
"latency": "Latency"
|
||||||
},
|
},
|
||||||
"speedtest": {
|
"speedtest": {
|
||||||
"upload": "Tải lên",
|
"upload": "Upload",
|
||||||
"download": "Tải xuống",
|
"download": "Download",
|
||||||
"ping": "Ping"
|
"ping": "Ping"
|
||||||
},
|
},
|
||||||
"portainer": {
|
"portainer": {
|
||||||
"running": "Đang chạy",
|
"running": "Running",
|
||||||
"stopped": "Đã dừng",
|
"stopped": "Stopped",
|
||||||
"total": "Tổng cộng"
|
"total": "Total"
|
||||||
},
|
},
|
||||||
"suwayomi": {
|
"suwayomi": {
|
||||||
"download": "Đã tải xuống",
|
"download": "Downloaded",
|
||||||
"nondownload": "Chưa tải xuống",
|
"nondownload": "Non-Downloaded",
|
||||||
"read": "Đã đọc",
|
"read": "Read",
|
||||||
"unread": "Chưa đọc",
|
"unread": "Unread",
|
||||||
"downloadedread": "Đã tải xuống & Đã đọc",
|
"downloadedread": "Downloaded & Read",
|
||||||
"downloadedunread": "Đã tải xuống & Chưa đọc",
|
"downloadedunread": "Downloaded & Unread",
|
||||||
"nondownloadedread": "Chưa tải xuống & Đã đọc",
|
"nondownloadedread": "Non-Downloaded & Read",
|
||||||
"nondownloadedunread": "Chưa tải xuống & Chưa đọc"
|
"nondownloadedunread": "Non-Downloaded & Unread"
|
||||||
},
|
},
|
||||||
"tailscale": {
|
"tailscale": {
|
||||||
"address": "Địa chỉ",
|
"address": "Address",
|
||||||
"expires": "Hết hạn",
|
"expires": "Expires",
|
||||||
"never": "Không bao giờ",
|
"never": "Never",
|
||||||
"user": "Người dùng",
|
"user": "User",
|
||||||
"hostname": "Tên máy chủ",
|
"hostname": "Hostname",
|
||||||
"name": "Tên",
|
"name": "Name",
|
||||||
"client_version": "Phiên bản máy khách",
|
"client_version": "Client Version",
|
||||||
"os": "Hệ điều hành",
|
"os": "OS",
|
||||||
"created": "Đã tạo",
|
"created": "Created",
|
||||||
"authorized": "Đã cấp quyền",
|
"authorized": "Authorized",
|
||||||
"is_external": "Là bên ngoài",
|
"is_external": "Is External",
|
||||||
"update_available": "Có bản cập nhật",
|
"update_available": "Update Available",
|
||||||
"tags": "Thẻ",
|
"tags": "Tags",
|
||||||
"last_seen": "Lần cuối nhìn thấy",
|
"last_seen": "Last Seen",
|
||||||
"now": "Bây giờ",
|
"now": "Now",
|
||||||
"years": "{{number}} năm",
|
"years": "{{number}}y",
|
||||||
"weeks": "{{number}} tuần",
|
"weeks": "{{number}}w",
|
||||||
"days": "{{number}} ngày",
|
"days": "{{number}}d",
|
||||||
"hours": "{{number}} giờ",
|
"hours": "{{number}}h",
|
||||||
"minutes": "{{number}} phút",
|
"minutes": "{{number}}m",
|
||||||
"seconds": "{{number}} giây",
|
"seconds": "{{number}}s",
|
||||||
"ago": "{{value}} trước",
|
"ago": "{{value}} Ago",
|
||||||
"true": "Có",
|
"true": "Yes",
|
||||||
"false": "Không"
|
"false": "No"
|
||||||
},
|
},
|
||||||
"technitium": {
|
"technitium": {
|
||||||
"totalQueries": "Tổng số truy vấn",
|
"totalQueries": "Queries",
|
||||||
"totalNoError": "Thành công",
|
"totalNoError": "Success",
|
||||||
"totalServerFailure": "Lỗi máy chủ",
|
"totalServerFailure": "Failures",
|
||||||
"totalNxDomain": "NX Domain",
|
"totalNxDomain": "NX Domains",
|
||||||
"totalRefused": "Bị từ chối",
|
"totalRefused": "Refused",
|
||||||
"totalAuthoritative": "Authoritative",
|
"totalAuthoritative": "Authoritative",
|
||||||
"totalRecursive": "Recursive",
|
"totalRecursive": "Recursive",
|
||||||
"totalCached": "Được lưu trong bộ nhớ đệm",
|
"totalCached": "Cached",
|
||||||
"totalBlocked": "Bị chặn",
|
"totalBlocked": "Blocked",
|
||||||
"totalDropped": "Bị loại bỏ",
|
"totalDropped": "Dropped",
|
||||||
"totalClients": "Số máy khách"
|
"totalClients": "Clients"
|
||||||
},
|
},
|
||||||
"tdarr": {
|
"tdarr": {
|
||||||
"queue": "Hàng đợi",
|
"queue": "Queue",
|
||||||
"processed": "Processed",
|
"processed": "Processed",
|
||||||
"errored": "Errored",
|
"errored": "Errored",
|
||||||
"saved": "Saved"
|
"saved": "Saved"
|
||||||
@@ -412,7 +410,7 @@
|
|||||||
"unknown": "Unknown"
|
"unknown": "Unknown"
|
||||||
},
|
},
|
||||||
"navidrome": {
|
"navidrome": {
|
||||||
"nothing_streaming": "Không có luồng đang hoạt động",
|
"nothing_streaming": "No Active Streams",
|
||||||
"please_wait": "Please Wait"
|
"please_wait": "Please Wait"
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
@@ -455,9 +453,9 @@
|
|||||||
"domain_count": "Domains"
|
"domain_count": "Domains"
|
||||||
},
|
},
|
||||||
"medusa": {
|
"medusa": {
|
||||||
"wanted": "Cần tải",
|
"wanted": "Wanted",
|
||||||
"queued": "Queued",
|
"queued": "Queued",
|
||||||
"series": "Phim bộ"
|
"series": "Series"
|
||||||
},
|
},
|
||||||
"minecraft": {
|
"minecraft": {
|
||||||
"players": "Players",
|
"players": "Players",
|
||||||
@@ -474,66 +472,66 @@
|
|||||||
"users": "Users",
|
"users": "Users",
|
||||||
"loginsLast24H": "Logins (24h)",
|
"loginsLast24H": "Logins (24h)",
|
||||||
"failedLoginsLast24H": "Failed Logins (24h)",
|
"failedLoginsLast24H": "Failed Logins (24h)",
|
||||||
"authorizationsLast24H": "Lượt ủy quyền (24 giờ)"
|
"authorizationsLast24H": "Auths (24h)"
|
||||||
},
|
},
|
||||||
"proxmox": {
|
"proxmox": {
|
||||||
"mem": "Bộ nhớ",
|
"mem": "MEM",
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
"lxc": "LXC",
|
"lxc": "LXC",
|
||||||
"vms": "VM"
|
"vms": "VMs"
|
||||||
},
|
},
|
||||||
"pulse": {
|
"pulse": {
|
||||||
"nodes": "Node",
|
"nodes": "Nodes",
|
||||||
"vms": "VM",
|
"vms": "VMs",
|
||||||
"lxcs": "LXC"
|
"lxcs": "LXCs"
|
||||||
},
|
},
|
||||||
"glances": {
|
"glances": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
"load": "Tải hệ thống",
|
"load": "Load",
|
||||||
"wait": "Vui lòng đợi",
|
"wait": "Please wait",
|
||||||
"temp": "Nhiệt độ",
|
"temp": "TEMP",
|
||||||
"_temp": "Nhiệt độ",
|
"_temp": "Temp",
|
||||||
"warn": "Cảnh báo",
|
"warn": "Warn",
|
||||||
"uptime": "Thời gian hoạt động",
|
"uptime": "UP",
|
||||||
"total": "Tổng cộng",
|
"total": "Total",
|
||||||
"free": "Còn trống",
|
"free": "Free",
|
||||||
"used": "Đã sử dụng",
|
"used": "Used",
|
||||||
"days": "ngày",
|
"days": "d",
|
||||||
"hours": "giờ",
|
"hours": "h",
|
||||||
"crit": "Nghiêm trọng",
|
"crit": "Crit",
|
||||||
"read": "Đọc",
|
"read": "Read",
|
||||||
"write": "Ghi",
|
"write": "Write",
|
||||||
"gpu": "GPU",
|
"gpu": "GPU",
|
||||||
"mem": "Bộ nhớ",
|
"mem": "Mem",
|
||||||
"swap": "Swap"
|
"swap": "Swap"
|
||||||
},
|
},
|
||||||
"quicklaunch": {
|
"quicklaunch": {
|
||||||
"bookmark": "Dấu trang",
|
"bookmark": "Bookmark",
|
||||||
"service": "Dịch vụ",
|
"service": "Service",
|
||||||
"search": "Tìm kiếm",
|
"search": "Search",
|
||||||
"custom": "Tùy chỉnh",
|
"custom": "Custom",
|
||||||
"visit": "Truy cập",
|
"visit": "Visit",
|
||||||
"url": "URL",
|
"url": "URL",
|
||||||
"searchsuggestion": "Gợi ý"
|
"searchsuggestion": "Suggestion"
|
||||||
},
|
},
|
||||||
"wmo": {
|
"wmo": {
|
||||||
"0-day": "Trời nắng",
|
"0-day": "Sunny",
|
||||||
"0-night": "Trời quang",
|
"0-night": "Clear",
|
||||||
"1-day": "Chủ yếu có nắng",
|
"1-day": "Mainly Sunny",
|
||||||
"1-night": "Chủ yếu trời quang",
|
"1-night": "Mainly Clear",
|
||||||
"2-day": "Có mây từng phần",
|
"2-day": "Partly Cloudy",
|
||||||
"2-night": "Có mây từng phần",
|
"2-night": "Partly Cloudy",
|
||||||
"3-day": "Nhiều mây",
|
"3-day": "Cloudy",
|
||||||
"3-night": "Nhiều mây",
|
"3-night": "Cloudy",
|
||||||
"45-day": "Có sương mù",
|
"45-day": "Foggy",
|
||||||
"45-night": "Có sương mù",
|
"45-night": "Foggy",
|
||||||
"48-day": "Có sương mù",
|
"48-day": "Foggy",
|
||||||
"48-night": "Có sương mù",
|
"48-night": "Foggy",
|
||||||
"51-day": "Mưa phùn nhẹ",
|
"51-day": "Light Drizzle",
|
||||||
"51-night": "Mưa phùn nhẹ",
|
"51-night": "Light Drizzle",
|
||||||
"53-day": "Mưa phùn",
|
"53-day": "Drizzle",
|
||||||
"53-night": "Mưa phùn",
|
"53-night": "Drizzle",
|
||||||
"55-day": "Mưa phùn lớn",
|
"55-day": "Heavy Drizzle",
|
||||||
"55-night": "Heavy Drizzle",
|
"55-night": "Heavy Drizzle",
|
||||||
"56-day": "Light Freezing Drizzle",
|
"56-day": "Light Freezing Drizzle",
|
||||||
"56-night": "Light Freezing Drizzle",
|
"56-night": "Light Freezing Drizzle",
|
||||||
@@ -741,14 +739,14 @@
|
|||||||
"m": "m"
|
"m": "m"
|
||||||
},
|
},
|
||||||
"atsumeru": {
|
"atsumeru": {
|
||||||
"series": "Bộ truyện",
|
"series": "Series",
|
||||||
"archives": "Archives",
|
"archives": "Archives",
|
||||||
"chapters": "Chapters",
|
"chapters": "Chapters",
|
||||||
"categories": "Categories"
|
"categories": "Categories"
|
||||||
},
|
},
|
||||||
"komga": {
|
"komga": {
|
||||||
"libraries": "Libraries",
|
"libraries": "Libraries",
|
||||||
"series": "Bộ truyện",
|
"series": "Series",
|
||||||
"books": "Books"
|
"books": "Books"
|
||||||
},
|
},
|
||||||
"diskstation": {
|
"diskstation": {
|
||||||
@@ -761,9 +759,9 @@
|
|||||||
"streams": "Streams"
|
"streams": "Streams"
|
||||||
},
|
},
|
||||||
"mylar": {
|
"mylar": {
|
||||||
"series": "Phim bộ",
|
"series": "Series",
|
||||||
"issues": "Issues",
|
"issues": "Issues",
|
||||||
"wanted": "Cần tải"
|
"wanted": "Wanted"
|
||||||
},
|
},
|
||||||
"photoprism": {
|
"photoprism": {
|
||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
@@ -846,7 +844,7 @@
|
|||||||
"books": "Books",
|
"books": "Books",
|
||||||
"authors": "Authors",
|
"authors": "Authors",
|
||||||
"categories": "Categories",
|
"categories": "Categories",
|
||||||
"series": "Bộ sách"
|
"series": "Series"
|
||||||
},
|
},
|
||||||
"booklore": {
|
"booklore": {
|
||||||
"libraries": "Libraries",
|
"libraries": "Libraries",
|
||||||
@@ -861,7 +859,7 @@
|
|||||||
"downloadSpeed": "Speed"
|
"downloadSpeed": "Speed"
|
||||||
},
|
},
|
||||||
"kavita": {
|
"kavita": {
|
||||||
"seriesCount": "Số bộ truyện",
|
"seriesCount": "Series",
|
||||||
"totalFiles": "Files"
|
"totalFiles": "Files"
|
||||||
},
|
},
|
||||||
"azuredevops": {
|
"azuredevops": {
|
||||||
@@ -1250,7 +1248,7 @@
|
|||||||
"storage": "Storage"
|
"storage": "Storage"
|
||||||
},
|
},
|
||||||
"sportarr": {
|
"sportarr": {
|
||||||
"wanted": "Cần tải",
|
"wanted": "Wanted",
|
||||||
"queued": "Queued",
|
"queued": "Queued",
|
||||||
"leagues": "Leagues"
|
"leagues": "Leagues"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "請稍後"
|
"wait": "請稍後"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "搜索緊…",
|
"placeholder": "搜索緊…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "请稍候"
|
"wait": "请稍候"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "搜索…",
|
"placeholder": "搜索…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
"wait": "請稍候"
|
"wait": "請稍候"
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "搜尋…",
|
"placeholder": "搜尋…"
|
||||||
"provider": "Search engine: {{name}}",
|
|
||||||
"select_provider": "Select search engine"
|
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ describe("pages/api/auth/[...nextauth]", () => {
|
|||||||
it("routes sanitized NextAuth logs through the Homepage logger", async () => {
|
it("routes sanitized NextAuth logs through the Homepage logger", async () => {
|
||||||
const mod = await import("pages/api/auth/[...nextauth]");
|
const mod = await import("pages/api/auth/[...nextauth]");
|
||||||
const sensitiveMetadata = {
|
const sensitiveMetadata = {
|
||||||
error: Object.assign(new Error("State cookie was missing."), { access_token: "sensitive-access-token" }),
|
|
||||||
clientSecret: "sensitive-client-secret",
|
clientSecret: "sensitive-client-secret",
|
||||||
access_token: "sensitive-access-token",
|
access_token: "sensitive-access-token",
|
||||||
id_token: "sensitive-id-token",
|
id_token: "sensitive-id-token",
|
||||||
@@ -83,7 +82,7 @@ describe("pages/api/auth/[...nextauth]", () => {
|
|||||||
mod.authOptions.logger.warn("NEXTAUTH_URL", sensitiveMetadata);
|
mod.authOptions.logger.warn("NEXTAUTH_URL", sensitiveMetadata);
|
||||||
mod.authOptions.logger.debug("OAUTH_CALLBACK_RESPONSE", sensitiveMetadata);
|
mod.authOptions.logger.debug("OAUTH_CALLBACK_RESPONSE", sensitiveMetadata);
|
||||||
|
|
||||||
expect(errorMock).toHaveBeenCalledWith("%s: %s", "OAUTH_CALLBACK_ERROR", "State cookie was missing.");
|
expect(errorMock).toHaveBeenCalledWith("%s", "OAUTH_CALLBACK_ERROR");
|
||||||
expect(warnMock).toHaveBeenCalledWith("%s", "NEXTAUTH_URL");
|
expect(warnMock).toHaveBeenCalledWith("%s", "NEXTAUTH_URL");
|
||||||
expect(debugMock).toHaveBeenCalledWith("%s", "OAUTH_CALLBACK_RESPONSE");
|
expect(debugMock).toHaveBeenCalledWith("%s", "OAUTH_CALLBACK_RESPONSE");
|
||||||
expect(JSON.stringify([...errorMock.mock.calls, ...warnMock.mock.calls, ...debugMock.mock.calls])).not.toContain(
|
expect(JSON.stringify([...errorMock.mock.calls, ...warnMock.mock.calls, ...debugMock.mock.calls])).not.toContain(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// @vitest-environment jsdom
|
// @vitest-environment jsdom
|
||||||
|
|
||||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import { ColorContext } from "utils/contexts/color";
|
import { ColorContext } from "utils/contexts/color";
|
||||||
@@ -25,7 +25,6 @@ const {
|
|||||||
throwIn: null,
|
throwIn: null,
|
||||||
validateData: [],
|
validateData: [],
|
||||||
hashData: null,
|
hashData: null,
|
||||||
hashConfig: null,
|
|
||||||
mutateHash: vi.fn(),
|
mutateHash: vi.fn(),
|
||||||
servicesData: [],
|
servicesData: [],
|
||||||
bookmarksData: [],
|
bookmarksData: [],
|
||||||
@@ -60,12 +59,9 @@ const {
|
|||||||
const serverSideTranslations = vi.fn(async (language) => ({ _translations: language }));
|
const serverSideTranslations = vi.fn(async (language) => ({ _translations: language }));
|
||||||
const logger = { error: vi.fn() };
|
const logger = { error: vi.fn() };
|
||||||
|
|
||||||
const useSWR = vi.fn((key, config) => {
|
const useSWR = vi.fn((key) => {
|
||||||
if (key === "/api/validate") return { data: state.validateData };
|
if (key === "/api/validate") return { data: state.validateData };
|
||||||
if (key === "/api/hash") {
|
if (key === "/api/hash") return { data: state.hashData, mutate: state.mutateHash };
|
||||||
state.hashConfig = config;
|
|
||||||
return { data: state.hashData, mutate: state.mutateHash };
|
|
||||||
}
|
|
||||||
if (key === "/api/services") return { data: state.servicesData };
|
if (key === "/api/services") return { data: state.servicesData };
|
||||||
if (key === "/api/bookmarks") return { data: state.bookmarksData };
|
if (key === "/api/bookmarks") return { data: state.bookmarksData };
|
||||||
if (key === "/api/widgets") return { data: state.widgetsData };
|
if (key === "/api/widgets") return { data: state.widgetsData };
|
||||||
@@ -176,7 +172,6 @@ describe("pages/index getStaticProps", () => {
|
|||||||
state.throwIn = null;
|
state.throwIn = null;
|
||||||
state.validateData = [];
|
state.validateData = [];
|
||||||
state.hashData = null;
|
state.hashData = null;
|
||||||
state.hashConfig = null;
|
|
||||||
state.servicesData = [];
|
state.servicesData = [];
|
||||||
state.bookmarksData = [];
|
state.bookmarksData = [];
|
||||||
state.widgetsData = [];
|
state.widgetsData = [];
|
||||||
@@ -356,7 +351,6 @@ describe("pages/index Index routing + SWR branches", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await renderIndex({ initialSettings: { title: "Homepage", layout: {} }, settings: { layout: {} } });
|
await renderIndex({ initialSettings: { title: "Homepage", layout: {} }, settings: { layout: {} } });
|
||||||
act(() => state.hashConfig.onSuccess(state.hashData));
|
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(fetchSpy).toHaveBeenCalledWith("/api/revalidate");
|
expect(fetchSpy).toHaveBeenCalledWith("/api/revalidate");
|
||||||
@@ -385,24 +379,11 @@ describe("pages/index Index routing + SWR branches", () => {
|
|||||||
localStorage.removeItem("hash");
|
localStorage.removeItem("hash");
|
||||||
|
|
||||||
await renderIndex({ initialSettings: { title: "Homepage", layout: {} }, settings: { layout: {} } });
|
await renderIndex({ initialSettings: { title: "Homepage", layout: {} }, settings: { layout: {} } });
|
||||||
act(() => state.hashConfig.onSuccess(state.hashData));
|
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(localStorage.getItem("hash")).toBe("first-hash");
|
expect(localStorage.getItem("hash")).toBe("first-hash");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ignores a hash response without a hash", async () => {
|
|
||||||
state.validateData = [];
|
|
||||||
localStorage.setItem("hash", "old-hash");
|
|
||||||
|
|
||||||
await renderIndex({ initialSettings: { title: "Homepage", layout: {} }, settings: { layout: {} } });
|
|
||||||
|
|
||||||
expect(() => act(() => state.hashConfig.onSuccess(null))).not.toThrow();
|
|
||||||
expect(() => act(() => state.hashConfig.onSuccess({}))).not.toThrow();
|
|
||||||
expect(localStorage.getItem("hash")).toBe("old-hash");
|
|
||||||
expect(document.querySelector(".animate-spin")).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("pages/index Home behavior", () => {
|
describe("pages/index Home behavior", () => {
|
||||||
@@ -438,27 +419,11 @@ describe("pages/index Home behavior", () => {
|
|||||||
|
|
||||||
fireEvent.keyDown(document.body, { key: "a" });
|
fireEvent.keyDown(document.body, { key: "a" });
|
||||||
expect(screen.getByTestId("quicklaunch")).toHaveTextContent("open:3");
|
expect(screen.getByTestId("quicklaunch")).toHaveTextContent("open:3");
|
||||||
expect(state.quickLaunchProps.searchString).toBe("a");
|
|
||||||
|
|
||||||
fireEvent.keyDown(document.body, { key: "Escape" });
|
fireEvent.keyDown(document.body, { key: "Escape" });
|
||||||
expect(screen.getByTestId("quicklaunch")).toHaveTextContent("closed:3");
|
expect(screen.getByTestId("quicklaunch")).toHaveTextContent("closed:3");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens search on space without seeding the query with whitespace", async () => {
|
|
||||||
await renderIndex({
|
|
||||||
initialSettings: { title: "Homepage", layout: {} },
|
|
||||||
settings: { title: "Homepage", layout: {}, language: "en" },
|
|
||||||
});
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(state.quickLaunchProps).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
fireEvent.keyDown(document.body, { key: " " });
|
|
||||||
expect(screen.getByTestId("quicklaunch")).toHaveTextContent("open:3");
|
|
||||||
expect(state.quickLaunchProps.searchString).toBe("");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders services and bookmark groups when present", async () => {
|
it("renders services and bookmark groups when present", async () => {
|
||||||
await renderIndex({
|
await renderIndex({
|
||||||
initialSettings: { title: "Homepage", layout: {} },
|
initialSettings: { title: "Homepage", layout: {} },
|
||||||
@@ -524,7 +489,7 @@ describe("pages/index Home behavior", () => {
|
|||||||
state.widgetsData = [];
|
state.widgetsData = [];
|
||||||
|
|
||||||
const { setTheme, setColor, setSettings } = await renderIndex({
|
const { setTheme, setColor, setSettings } = await renderIndex({
|
||||||
initialSettings: { title: "Homepage", layout: {}, favicon: "/x.ico" },
|
initialSettings: { title: "Homepage", layout: {} },
|
||||||
settings: {
|
settings: {
|
||||||
title: "Homepage",
|
title: "Homepage",
|
||||||
layout: {},
|
layout: {},
|
||||||
@@ -533,6 +498,7 @@ describe("pages/index Home behavior", () => {
|
|||||||
color: "emerald",
|
color: "emerald",
|
||||||
disableIndexing: true,
|
disableIndexing: true,
|
||||||
base: "/base/",
|
base: "/base/",
|
||||||
|
favicon: "/x.ico",
|
||||||
},
|
},
|
||||||
theme: "dark",
|
theme: "dark",
|
||||||
color: "slate",
|
color: "slate",
|
||||||
@@ -550,20 +516,6 @@ describe("pages/index Home behavior", () => {
|
|||||||
expect(document.querySelector('link[rel="icon"]')?.getAttribute("href")).toBe("/x.ico");
|
expect(document.querySelector('link[rel="icon"]')?.getAttribute("href")).toBe("/x.ico");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Safari reads the head without running JS, so the favicon has to be there before the
|
|
||||||
// settings context is populated, and mask-icon must not be
|
|
||||||
it("renders a custom favicon before the settings context is populated", async () => {
|
|
||||||
await renderIndex({
|
|
||||||
initialSettings: { title: "Homepage", layout: {}, favicon: "/x.ico" },
|
|
||||||
settings: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(document.querySelector('link[rel="icon"]')?.getAttribute("href")).toBe("/x.ico");
|
|
||||||
expect(document.querySelector('link[rel="apple-touch-icon"]')?.getAttribute("href")).toBe("/x.ico");
|
|
||||||
expect(document.querySelector('link[rel="mask-icon"]')).toBeNull();
|
|
||||||
expect(document.querySelector('link[rel="shortcut icon"]')).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("marks information widgets as right-aligned for known widget types", async () => {
|
it("marks information widgets as right-aligned for known widget types", async () => {
|
||||||
await renderIndex({
|
await renderIndex({
|
||||||
initialSettings: { title: "Homepage", layout: {} },
|
initialSettings: { title: "Homepage", layout: {} },
|
||||||
|
|||||||
+105
-124
@@ -15,69 +15,6 @@ const MOBILE_BUTTON_POSITIONS = {
|
|||||||
"bottom-right": "bottom-4 right-4",
|
"bottom-right": "bottom-4 right-4",
|
||||||
};
|
};
|
||||||
|
|
||||||
function parseUrl(searchString) {
|
|
||||||
if (!/.+[.:].+/.test(searchString)) return null; // basic test for probably a url
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new URL(searchString.toLowerCase().startsWith("http") ? searchString : `https://${searchString}`);
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSearchResults({
|
|
||||||
hideVisitURL,
|
|
||||||
searchDescriptions,
|
|
||||||
searchProvider,
|
|
||||||
searchString,
|
|
||||||
searchSuggestions,
|
|
||||||
servicesAndBookmarks,
|
|
||||||
t,
|
|
||||||
url,
|
|
||||||
}) {
|
|
||||||
if (searchString.trim().length === 0) return [];
|
|
||||||
|
|
||||||
const results = servicesAndBookmarks.flatMap((result) => {
|
|
||||||
const nameMatch = result.name.toLowerCase().includes(searchString);
|
|
||||||
const descriptionMatch = searchDescriptions && result.description?.toLowerCase().includes(searchString);
|
|
||||||
|
|
||||||
if (!nameMatch && !descriptionMatch) return [];
|
|
||||||
return [{ ...result, ...(searchDescriptions && { priority: nameMatch ? 2 : +descriptionMatch }) }];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (searchDescriptions) {
|
|
||||||
results.sort((a, b) => b.priority - a.priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (searchProvider) {
|
|
||||||
results.push({
|
|
||||||
href: searchProvider.url + encodeURIComponent(searchString),
|
|
||||||
name: `${searchProvider.name ?? t("quicklaunch.custom")} ${t("quicklaunch.search")}`,
|
|
||||||
type: "search",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (searchProvider.showSearchSuggestions && searchProvider.suggestionUrl && searchSuggestions[1]) {
|
|
||||||
results.push(
|
|
||||||
...searchSuggestions[1].map((suggestion) => ({
|
|
||||||
href: searchProvider.url + encodeURIComponent(suggestion),
|
|
||||||
name: suggestion,
|
|
||||||
type: "searchSuggestion",
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hideVisitURL && url) {
|
|
||||||
results.unshift({
|
|
||||||
href: url.toString(),
|
|
||||||
name: `${t("quicklaunch.visit")} URL`,
|
|
||||||
type: "url",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function QuickLaunch({ servicesAndBookmarks, searchString, setSearchString, isOpen, setSearching }) {
|
export default function QuickLaunch({ servicesAndBookmarks, searchString, setSearchString, isOpen, setSearching }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -86,8 +23,9 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
|
|
||||||
const searchField = useRef();
|
const searchField = useRef();
|
||||||
|
|
||||||
|
const [results, setResults] = useState([]);
|
||||||
const [currentItemIndex, setCurrentItemIndex] = useState(null);
|
const [currentItemIndex, setCurrentItemIndex] = useState(null);
|
||||||
const url = parseUrl(searchString);
|
const [url, setUrl] = useState(null);
|
||||||
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
||||||
|
|
||||||
const { data: widgets } = useSWR("/api/widgets");
|
const { data: widgets } = useSWR("/api/widgets");
|
||||||
@@ -124,7 +62,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
function openCurrentItem(newWindow) {
|
function openCurrentItem(newWindow) {
|
||||||
const result = results[activeItemIndex];
|
const result = results[currentItemIndex];
|
||||||
window.open(
|
window.open(
|
||||||
result.href,
|
result.href,
|
||||||
newWindow ? "_blank" : (result.target ?? searchProvider?.target ?? settings.target ?? "_blank"),
|
newWindow ? "_blank" : (result.target ?? searchProvider?.target ?? settings.target ?? "_blank"),
|
||||||
@@ -143,9 +81,17 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
|
|
||||||
function handleSearchChange(event) {
|
function handleSearchChange(event) {
|
||||||
const rawSearchString = event.target.value;
|
const rawSearchString = event.target.value;
|
||||||
setCurrentItemIndex(null);
|
try {
|
||||||
// urls keep their casing, everything else is lowercased for matching
|
if (!/.+[.:].+/g.test(rawSearchString)) throw new Error(); // basic test for probably a url
|
||||||
setSearchString(parseUrl(rawSearchString) ? rawSearchString : rawSearchString.toLowerCase());
|
let urlString = rawSearchString;
|
||||||
|
if (urlString.toLowerCase().indexOf("http") !== 0) urlString = `https://${rawSearchString}`;
|
||||||
|
setUrl(new URL(urlString)); // basic validation
|
||||||
|
setSearchString(rawSearchString);
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
setUrl(null);
|
||||||
|
}
|
||||||
|
setSearchString(rawSearchString.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSearchKeyDown(event) {
|
function handleSearchKeyDown(event) {
|
||||||
@@ -157,19 +103,18 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
} else if (event.key === "Enter" && results.length) {
|
} else if (event.key === "Enter" && results.length) {
|
||||||
closeAndReset();
|
closeAndReset();
|
||||||
openCurrentItem(event.metaKey);
|
openCurrentItem(event.metaKey);
|
||||||
} else if (event.key === "ArrowDown" && results[activeItemIndex + 1]) {
|
} else if (event.key === "ArrowDown" && results[currentItemIndex + 1]) {
|
||||||
setCurrentItemIndex(activeItemIndex + 1);
|
setCurrentItemIndex(currentItemIndex + 1);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (event.key === "ArrowUp" && activeItemIndex > 0) {
|
} else if (event.key === "ArrowUp" && currentItemIndex > 0) {
|
||||||
setCurrentItemIndex(activeItemIndex - 1);
|
setCurrentItemIndex(currentItemIndex - 1);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (
|
} else if (
|
||||||
event.key === "ArrowRight" &&
|
event.key === "ArrowRight" &&
|
||||||
results[activeItemIndex] &&
|
results[currentItemIndex] &&
|
||||||
results[activeItemIndex].type === "searchSuggestion"
|
results[currentItemIndex].type === "searchSuggestion"
|
||||||
) {
|
) {
|
||||||
setCurrentItemIndex(null);
|
setSearchString(results[currentItemIndex].name);
|
||||||
setSearchString(results[activeItemIndex].name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,51 +138,88 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
|
||||||
searchString.trim().length === 0 ||
|
|
||||||
!searchProvider?.showSearchSuggestions ||
|
|
||||||
!searchProvider.suggestionUrl ||
|
|
||||||
searchString.trim() === searchSuggestions[0]?.trim()
|
|
||||||
) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
|
|
||||||
fetch(
|
if (searchString.trim().length === 0) setResults([]);
|
||||||
`/api/search/searchSuggestion?query=${encodeURIComponent(searchString)}&providerName=${
|
else {
|
||||||
searchProvider.name ?? "Custom"
|
let newResults = servicesAndBookmarks.filter((r) => {
|
||||||
}`,
|
const nameMatch = r.name.toLowerCase().includes(searchString);
|
||||||
{ signal: abortController.signal },
|
let descriptionMatch;
|
||||||
)
|
if (searchDescriptions) {
|
||||||
.then(async (searchSuggestionResult) => {
|
descriptionMatch = r.description?.toLowerCase().includes(searchString);
|
||||||
const newSearchSuggestions = await searchSuggestionResult.json();
|
r.priority = nameMatch ? 2 * +nameMatch : +descriptionMatch;
|
||||||
|
|
||||||
if (newSearchSuggestions) {
|
|
||||||
setCurrentItemIndex(null);
|
|
||||||
setSearchSuggestions([newSearchSuggestions[0], newSearchSuggestions[1].slice(0, 4)]);
|
|
||||||
}
|
}
|
||||||
})
|
return nameMatch || descriptionMatch;
|
||||||
.catch(() => {
|
|
||||||
// If there is an error, just ignore it. There just will be no search suggestions.
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => abortController.abort();
|
if (searchDescriptions) {
|
||||||
}, [searchProvider, searchString, searchSuggestions]);
|
newResults = newResults.sort((a, b) => b.priority - a.priority);
|
||||||
|
}
|
||||||
|
|
||||||
const results = getSearchResults({
|
if (searchProvider) {
|
||||||
hideVisitURL,
|
newResults.push({
|
||||||
searchDescriptions,
|
href: searchProvider.url + encodeURIComponent(searchString),
|
||||||
searchProvider,
|
name: `${searchProvider.name ?? t("quicklaunch.custom")} ${t("quicklaunch.search")}`,
|
||||||
searchString,
|
type: "search",
|
||||||
searchSuggestions,
|
});
|
||||||
servicesAndBookmarks,
|
|
||||||
t,
|
|
||||||
url,
|
|
||||||
});
|
|
||||||
|
|
||||||
const activeItemIndex = currentItemIndex ?? (results.length ? 0 : null);
|
if (searchProvider.showSearchSuggestions && searchProvider.suggestionUrl) {
|
||||||
|
if (searchString.trim() !== searchSuggestions[0]?.trim()) {
|
||||||
|
fetch(
|
||||||
|
`/api/search/searchSuggestion?query=${encodeURIComponent(searchString)}&providerName=${
|
||||||
|
searchProvider.name ?? "Custom"
|
||||||
|
}`,
|
||||||
|
{ signal: abortController.signal },
|
||||||
|
)
|
||||||
|
.then(async (searchSuggestionResult) => {
|
||||||
|
const newSearchSuggestions = await searchSuggestionResult.json();
|
||||||
|
|
||||||
|
if (newSearchSuggestions) {
|
||||||
|
if (newSearchSuggestions[1].length > 4) {
|
||||||
|
newSearchSuggestions[1] = newSearchSuggestions[1].splice(0, 4);
|
||||||
|
}
|
||||||
|
setSearchSuggestions(newSearchSuggestions);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// If there is an error, just ignore it. There just will be no search suggestions.
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchSuggestions[1]) {
|
||||||
|
newResults = newResults.concat(
|
||||||
|
searchSuggestions[1].map((suggestion) => ({
|
||||||
|
href: searchProvider.url + encodeURIComponent(suggestion),
|
||||||
|
name: suggestion,
|
||||||
|
type: "searchSuggestion",
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hideVisitURL && url) {
|
||||||
|
newResults.unshift({
|
||||||
|
href: url.toString(),
|
||||||
|
name: `${t("quicklaunch.visit")} URL`,
|
||||||
|
type: "url",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setResults(newResults);
|
||||||
|
|
||||||
|
if (newResults.length) {
|
||||||
|
setCurrentItemIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
abortController.abort();
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [searchString, servicesAndBookmarks, searchDescriptions, hideVisitURL, searchSuggestions, searchProvider, url]);
|
||||||
|
|
||||||
|
const [hidden, setHidden] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleBackdropClick(event) {
|
function handleBackdropClick(event) {
|
||||||
if (event.target?.tagName === "DIV") closeAndReset();
|
if (event.target?.tagName === "DIV") closeAndReset();
|
||||||
@@ -246,11 +228,14 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
searchField.current.focus();
|
searchField.current.focus();
|
||||||
document.body.addEventListener("click", handleBackdropClick);
|
document.body.addEventListener("click", handleBackdropClick);
|
||||||
|
setHidden(false);
|
||||||
} else {
|
} else {
|
||||||
|
document.body.removeEventListener("click", handleBackdropClick);
|
||||||
searchField.current.blur();
|
searchField.current.blur();
|
||||||
|
setTimeout(() => {
|
||||||
|
setHidden(true);
|
||||||
|
}, 300); // disable on close
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => document.body.removeEventListener("click", handleBackdropClick);
|
|
||||||
}, [isOpen, closeAndReset]);
|
}, [isOpen, closeAndReset]);
|
||||||
|
|
||||||
function highlightText(text) {
|
function highlightText(text) {
|
||||||
@@ -274,17 +259,13 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"relative z-40 ease-in-out",
|
"relative z-40 ease-in-out duration-300 transition-opacity",
|
||||||
isOpen ? "visible opacity-100" : "invisible opacity-0 pointer-events-none",
|
hidden && !isOpen && "hidden",
|
||||||
|
!hidden && isOpen && "opacity-100",
|
||||||
|
!isOpen && "opacity-0",
|
||||||
)}
|
)}
|
||||||
style={{
|
|
||||||
transitionProperty: "opacity, visibility",
|
|
||||||
transitionDuration: "300ms, 0s",
|
|
||||||
transitionDelay: isOpen ? "0s, 0s" : "0s, 300ms",
|
|
||||||
}}
|
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-hidden={!isOpen}
|
|
||||||
>
|
>
|
||||||
<div className="fixed inset-0 bg-gray-500 opacity-50" />
|
<div className="fixed inset-0 bg-gray-500 opacity-50" />
|
||||||
<div className="fixed inset-0 z-20 overflow-y-auto">
|
<div className="fixed inset-0 z-20 overflow-y-auto">
|
||||||
@@ -316,7 +297,7 @@ export default function QuickLaunch({ servicesAndBookmarks, searchString, setSea
|
|||||||
onKeyDown={handleItemKeyDown}
|
onKeyDown={handleItemKeyDown}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"flex flex-row w-full items-center justify-between rounded-md text-sm md:text-xl py-2 px-4 cursor-pointer text-theme-700 dark:text-theme-200",
|
"flex flex-row w-full items-center justify-between rounded-md text-sm md:text-xl py-2 px-4 cursor-pointer text-theme-700 dark:text-theme-200",
|
||||||
i === activeItemIndex && "bg-theme-300/50 dark:bg-theme-700/50",
|
i === currentItemIndex && "bg-theme-300/50 dark:bg-theme-700/50",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex flex-row items-center mr-4 pointer-events-none">
|
<div className="flex flex-row items-center mr-4 pointer-events-none">
|
||||||
|
|||||||
@@ -46,25 +46,13 @@ function Wrapper({ servicesAndBookmarks = [], initialOpen = true } = {}) {
|
|||||||
const [isOpen, setSearching] = useState(initialOpen);
|
const [isOpen, setSearching] = useState(initialOpen);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<QuickLaunch
|
||||||
<button
|
servicesAndBookmarks={servicesAndBookmarks}
|
||||||
type="button"
|
searchString={searchString}
|
||||||
data-testid="seed-key"
|
setSearchString={setSearchString}
|
||||||
onClick={() => {
|
isOpen={isOpen}
|
||||||
setSearchString((current) => `${current}g`);
|
setSearching={setSearching}
|
||||||
setSearching(true);
|
/>
|
||||||
}}
|
|
||||||
>
|
|
||||||
seed
|
|
||||||
</button>
|
|
||||||
<QuickLaunch
|
|
||||||
servicesAndBookmarks={servicesAndBookmarks}
|
|
||||||
searchString={searchString}
|
|
||||||
setSearchString={setSearchString}
|
|
||||||
isOpen={isOpen}
|
|
||||||
setSearching={setSearching}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,35 +151,6 @@ describe("components/quicklaunch", () => {
|
|||||||
openSpy.mockRestore();
|
openSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not carry a previous url result into a search seeded by a keypress", async () => {
|
|
||||||
renderWithProviders(<Wrapper />, {
|
|
||||||
settings: {
|
|
||||||
target: "_self",
|
|
||||||
quicklaunch: {
|
|
||||||
provider: "duckduckgo",
|
|
||||||
showSearchSuggestions: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const input = screen.getByPlaceholderText("Search");
|
|
||||||
await waitFor(() => expect(input).toHaveFocus());
|
|
||||||
|
|
||||||
fireEvent.change(input, { target: { value: "example.com" } });
|
|
||||||
expect(await screen.findByText("quicklaunch.visit URL")).toBeInTheDocument();
|
|
||||||
|
|
||||||
fireEvent.keyDown(input, { key: "Escape" });
|
|
||||||
await act(async () => {
|
|
||||||
await new Promise((r) => setTimeout(r, 350));
|
|
||||||
});
|
|
||||||
|
|
||||||
// reopen by "typing" a character, the way pages/index does
|
|
||||||
fireEvent.click(screen.getByTestId("seed-key"));
|
|
||||||
|
|
||||||
expect(input).toHaveValue("g");
|
|
||||||
expect(screen.queryByText("quicklaunch.visit URL")).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("closes on Escape and clears the search string after the timeout", async () => {
|
it("closes on Escape and clears the search string after the timeout", async () => {
|
||||||
renderWithProviders(<Wrapper />, {
|
renderWithProviders(<Wrapper />, {
|
||||||
settings: {
|
settings: {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
import { useMemo } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import Container from "../widget/container";
|
import Container from "../widget/container";
|
||||||
import Raw from "../widget/raw";
|
import Raw from "../widget/raw";
|
||||||
|
|
||||||
import useCurrentTime from "utils/hooks/use-current-time";
|
|
||||||
|
|
||||||
const textSizes = {
|
const textSizes = {
|
||||||
"4xl": "text-4xl",
|
"4xl": "text-4xl",
|
||||||
"3xl": "text-3xl",
|
"3xl": "text-3xl",
|
||||||
@@ -20,10 +18,17 @@ const textSizes = {
|
|||||||
export default function DateTime({ options }) {
|
export default function DateTime({ options }) {
|
||||||
const { text_size: textSize, locale, format } = options;
|
const { text_size: textSize, locale, format } = options;
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
|
const [date, setDate] = useState("");
|
||||||
const dateLocale = locale ?? i18n.language;
|
const dateLocale = locale ?? i18n.language;
|
||||||
const currentTime = useCurrentTime(1000);
|
|
||||||
const dateFormatter = useMemo(() => new Intl.DateTimeFormat(dateLocale, { ...format }), [dateLocale, format]);
|
useEffect(() => {
|
||||||
const date = currentTime === null ? "" : dateFormatter.format(new Date(currentTime));
|
const dateFormat = new Intl.DateTimeFormat(dateLocale, { ...format });
|
||||||
|
setDate(dateFormat.format(new Date()));
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setDate(dateFormat.format(new Date()));
|
||||||
|
}, 1000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [date, setDate, dateLocale, format]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container options={options} additionalClassNames="information-widget-datetime">
|
<Container options={options} additionalClassNames="information-widget-datetime">
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import Resource from "../widget/resource";
|
|||||||
|
|
||||||
export default function Network({ options, refresh = 1500 }) {
|
export default function Network({ options, refresh = 1500 }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const network = options.network === true ? "default" : options.network;
|
if (options.network === true) options.network = "default";
|
||||||
|
|
||||||
const { data, error } = useSWR(`/api/widgets/resources?type=network&interfaceName=${network}`, {
|
const { data, error } = useSWR(`/api/widgets/resources?type=network&interfaceName=${options.network}`, {
|
||||||
refreshInterval: refresh,
|
refreshInterval: refresh,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,10 @@ describe("components/widgets/resources/network", () => {
|
|||||||
|
|
||||||
it("normalizes options.network=true to default interfaceName in the request", () => {
|
it("normalizes options.network=true to default interfaceName in the request", () => {
|
||||||
useSWR.mockReturnValue({ data: undefined, error: undefined });
|
useSWR.mockReturnValue({ data: undefined, error: undefined });
|
||||||
const options = Object.freeze({ network: true });
|
|
||||||
|
|
||||||
render(<Network options={options} />);
|
render(<Network options={{ network: true }} />);
|
||||||
|
|
||||||
expect(useSWR).toHaveBeenCalledWith(expect.stringContaining("interfaceName=default"), expect.any(Object));
|
expect(useSWR).toHaveBeenCalledWith(expect.stringContaining("interfaceName=default"), expect.any(Object));
|
||||||
expect(options.network).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders rates and usage percentage when data is present", () => {
|
it("renders rates and usage percentage when data is present", () => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from "@headlessui/react";
|
} from "@headlessui/react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
import { Fragment, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
import { Fragment, useEffect, useMemo, useState } from "react";
|
||||||
import { BiLogoBing } from "react-icons/bi";
|
import { BiLogoBing } from "react-icons/bi";
|
||||||
import { FiSearch } from "react-icons/fi";
|
import { FiSearch } from "react-icons/fi";
|
||||||
import { SiBaidu, SiBrave, SiDuckduckgo, SiGoogle } from "react-icons/si";
|
import { SiBaidu, SiBrave, SiDuckduckgo, SiGoogle } from "react-icons/si";
|
||||||
@@ -79,32 +79,24 @@ export function getStoredProvider() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribeToStoredProvider(onStoreChange) {
|
|
||||||
const handleStorage = (event) => {
|
|
||||||
if (event.key === localStorageKey) onStoreChange();
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("storage", handleStorage);
|
|
||||||
return () => window.removeEventListener("storage", handleStorage);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Search({ options }) {
|
export default function Search({ options }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
// options is a fresh object each render, so memo on provider itself
|
// options is a fresh object each render, so memo on provider itself
|
||||||
const availableProviderIds = useMemo(() => getAvailableProviderIds(options.provider) ?? [], [options.provider]);
|
const availableProviderIds = useMemo(() => getAvailableProviderIds(options.provider) ?? [], [options.provider]);
|
||||||
const storedProvider = useSyncExternalStore(subscribeToStoredProvider, getStoredProvider, () => null);
|
|
||||||
const storedProviderId = Object.keys(searchProviders).find(
|
|
||||||
(providerId) => searchProviders[providerId] === storedProvider,
|
|
||||||
);
|
|
||||||
const initialProvider = availableProviderIds.includes(storedProviderId)
|
|
||||||
? storedProvider
|
|
||||||
: searchProviders[availableProviderIds[0] ?? "google"];
|
|
||||||
|
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [providerOverride, setProviderOverride] = useState(null);
|
const [selectedProvider, setSelectedProvider] = useState(searchProviders[availableProviderIds[0] ?? "google"]);
|
||||||
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
const [searchSuggestions, setSearchSuggestions] = useState([]);
|
||||||
const selectedProvider = providerOverride ?? initialProvider;
|
|
||||||
|
useEffect(() => {
|
||||||
|
const storedProvider = getStoredProvider();
|
||||||
|
let storedProviderKey = null;
|
||||||
|
storedProviderKey = Object.keys(searchProviders).find((pkey) => searchProviders[pkey] === storedProvider);
|
||||||
|
if (storedProvider && availableProviderIds.includes(storedProviderKey)) {
|
||||||
|
setSelectedProvider(storedProvider);
|
||||||
|
}
|
||||||
|
}, [availableProviderIds]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
@@ -138,6 +130,8 @@ export default function Search({ options }) {
|
|||||||
};
|
};
|
||||||
}, [selectedProvider, options, query, searchSuggestions]);
|
}, [selectedProvider, options, query, searchSuggestions]);
|
||||||
|
|
||||||
|
let currentSuggestion;
|
||||||
|
|
||||||
function doSearch(value) {
|
function doSearch(value) {
|
||||||
const q = encodeURIComponent(value);
|
const q = encodeURIComponent(value);
|
||||||
const { url } = selectedProvider;
|
const { url } = selectedProvider;
|
||||||
@@ -148,11 +142,13 @@ export default function Search({ options }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setQuery("");
|
setQuery("");
|
||||||
|
currentSuggestion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSearchKeyDown = (event) => {
|
const handleSearchKeyDown = (event) => {
|
||||||
if (event.key === "Enter" && !searchSuggestions[1]?.length) {
|
const useSuggestion = searchSuggestions.length && currentSuggestion;
|
||||||
doSearch(event.target.value);
|
if (event.key === "Enter") {
|
||||||
|
doSearch(useSuggestion ? currentSuggestion : event.target.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -161,7 +157,7 @@ export default function Search({ options }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onChangeProvider = (provider) => {
|
const onChangeProvider = (provider) => {
|
||||||
setProviderOverride(provider);
|
setSelectedProvider(provider);
|
||||||
localStorage.setItem(localStorageKey, provider.name);
|
localStorage.setItem(localStorageKey, provider.name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -170,7 +166,7 @@ export default function Search({ options }) {
|
|||||||
<Raw>
|
<Raw>
|
||||||
<div className="flex-col relative h-8 my-4 min-w-fit z-20">
|
<div className="flex-col relative h-8 my-4 min-w-fit z-20">
|
||||||
<div className="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none w-full text-theme-800 dark:text-white" />
|
<div className="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none w-full text-theme-800 dark:text-white" />
|
||||||
<Combobox value={query} onChange={doSearch}>
|
<Combobox value={query}>
|
||||||
<ComboboxInput
|
<ComboboxInput
|
||||||
type="text"
|
type="text"
|
||||||
className="
|
className="
|
||||||
@@ -182,7 +178,6 @@ export default function Search({ options }) {
|
|||||||
focus:border-theme-500 dark:focus:border-white/50
|
focus:border-theme-500 dark:focus:border-white/50
|
||||||
border border-theme-300 dark:border-theme-200/50"
|
border border-theme-300 dark:border-theme-200/50"
|
||||||
placeholder={t("search.placeholder")}
|
placeholder={t("search.placeholder")}
|
||||||
aria-label={t("search.placeholder")}
|
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setQuery(event.target.value);
|
setQuery(event.target.value);
|
||||||
}}
|
}}
|
||||||
@@ -209,8 +204,8 @@ export default function Search({ options }) {
|
|||||||
bg-theme-600/40 dark:bg-white/10
|
bg-theme-600/40 dark:bg-white/10
|
||||||
focus:ring-theme-500 dark:focus:ring-white/50"
|
focus:ring-theme-500 dark:focus:ring-white/50"
|
||||||
>
|
>
|
||||||
<selectedProvider.icon className="text-white w-3 h-3" aria-hidden="true" />
|
<selectedProvider.icon className="text-white w-3 h-3" />
|
||||||
<span className="sr-only">{t("search.provider", { name: selectedProvider.name })}</span>
|
<span className="sr-only">{t("search.search")}</span>
|
||||||
</ListboxButton>
|
</ListboxButton>
|
||||||
</div>
|
</div>
|
||||||
<Transition
|
<Transition
|
||||||
@@ -223,7 +218,6 @@ export default function Search({ options }) {
|
|||||||
leaveTo="transform opacity-0 scale-95"
|
leaveTo="transform opacity-0 scale-95"
|
||||||
>
|
>
|
||||||
<ListboxOptions
|
<ListboxOptions
|
||||||
aria-label={t("search.select_provider")}
|
|
||||||
className="absolute right-0 z-10 mt-1 origin-top-right rounded-md
|
className="absolute right-0 z-10 mt-1 origin-top-right rounded-md
|
||||||
bg-theme-100 dark:bg-theme-600 shadow-lg
|
bg-theme-100 dark:bg-theme-600 shadow-lg
|
||||||
ring-1 ring-black ring-opacity-5 focus:outline-hidden"
|
ring-1 ring-black ring-opacity-5 focus:outline-hidden"
|
||||||
@@ -240,8 +234,7 @@ export default function Search({ options }) {
|
|||||||
active ? "bg-theme-600/10 dark:bg-white/10 dark:text-gray-900" : "dark:text-gray-100",
|
active ? "bg-theme-600/10 dark:bg-white/10 dark:text-gray-900" : "dark:text-gray-100",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<p.icon className="h-4 w-4 mx-4 my-2" aria-hidden="true" />
|
<p.icon className="h-4 w-4 mx-4 my-2" />
|
||||||
<span className="sr-only">{p.name}</span>
|
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
</ListboxOption>
|
</ListboxOption>
|
||||||
@@ -255,24 +248,32 @@ export default function Search({ options }) {
|
|||||||
{searchSuggestions[1]?.length > 0 && (
|
{searchSuggestions[1]?.length > 0 && (
|
||||||
<ComboboxOptions className="mt-1 rounded-md bg-theme-50 dark:bg-theme-800 border border-theme-300 dark:border-theme-200/30 cursor-pointer shadow-lg">
|
<ComboboxOptions className="mt-1 rounded-md bg-theme-50 dark:bg-theme-800 border border-theme-300 dark:border-theme-200/30 cursor-pointer shadow-lg">
|
||||||
<div className="p-1 bg-white/50 dark:bg-white/10 text-theme-900/90 dark:text-white/90 text-xs">
|
<div className="p-1 bg-white/50 dark:bg-white/10 text-theme-900/90 dark:text-white/90 text-xs">
|
||||||
<ComboboxOption key={query} value={query}>
|
<ComboboxOption key={query} value={query} />
|
||||||
<span className="sr-only">{query}</span>
|
|
||||||
</ComboboxOption>
|
|
||||||
{searchSuggestions[1].map((suggestion) => (
|
{searchSuggestions[1].map((suggestion) => (
|
||||||
<ComboboxOption key={suggestion} value={suggestion} className="flex w-full">
|
<ComboboxOption
|
||||||
{({ active }) => (
|
key={suggestion}
|
||||||
<div
|
value={suggestion}
|
||||||
className={classNames(
|
onMouseDown={() => {
|
||||||
"px-2 py-1 rounded-md w-full flex-nowrap",
|
doSearch(suggestion);
|
||||||
active ? "bg-theme-300/20 dark:bg-white/10" : "",
|
}}
|
||||||
)}
|
className="flex w-full"
|
||||||
>
|
>
|
||||||
<span className="whitespace-pre">{suggestion.indexOf(query) === 0 ? query : ""}</span>
|
{({ active }) => {
|
||||||
<span className="mr-4 whitespace-pre opacity-50">
|
if (active) currentSuggestion = suggestion;
|
||||||
{suggestion.indexOf(query) === 0 ? suggestion.substring(query.length) : suggestion}
|
return (
|
||||||
</span>
|
<div
|
||||||
</div>
|
className={classNames(
|
||||||
)}
|
"px-2 py-1 rounded-md w-full flex-nowrap",
|
||||||
|
active ? "bg-theme-300/20 dark:bg-white/10" : "",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="whitespace-pre">{suggestion.indexOf(query) === 0 ? query : ""}</span>
|
||||||
|
<span className="mr-4 whitespace-pre opacity-50">
|
||||||
|
{suggestion.indexOf(query) === 0 ? suggestion.substring(query.length) : suggestion}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
</ComboboxOption>
|
</ComboboxOption>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { renderWithProviders } from "test-utils/render-with-providers";
|
|||||||
vi.mock("@headlessui/react", async () => {
|
vi.mock("@headlessui/react", async () => {
|
||||||
const React = await import("react");
|
const React = await import("react");
|
||||||
const { Fragment, createContext, useContext } = React;
|
const { Fragment, createContext, useContext } = React;
|
||||||
const ComboboxContext = createContext(null);
|
|
||||||
const ListboxContext = createContext(null);
|
const ListboxContext = createContext(null);
|
||||||
|
|
||||||
function passthrough({ as: As = "div", children, ...props }) {
|
function passthrough({ as: As = "div", children, ...props }) {
|
||||||
@@ -19,21 +18,9 @@ vi.mock("@headlessui/react", async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Combobox: ({ onChange, children }) => (
|
Combobox: passthrough,
|
||||||
<ComboboxContext.Provider value={{ onChange }}>
|
|
||||||
<div>{children}</div>
|
|
||||||
</ComboboxContext.Provider>
|
|
||||||
),
|
|
||||||
ComboboxInput: (props) => <input {...props} />,
|
ComboboxInput: (props) => <input {...props} />,
|
||||||
ComboboxOption: ({ as: As = "div", value, children, ...props }) => {
|
ComboboxOption: passthrough,
|
||||||
const ctx = useContext(ComboboxContext);
|
|
||||||
const content = typeof children === "function" ? children({ active: false }) : children;
|
|
||||||
return (
|
|
||||||
<As value={value} onMouseDown={() => ctx?.onChange?.(value)} {...props}>
|
|
||||||
{content}
|
|
||||||
</As>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
ComboboxOptions: passthrough,
|
ComboboxOptions: passthrough,
|
||||||
Listbox: ({ value, onChange, children, ...props }) => (
|
Listbox: ({ value, onChange, children, ...props }) => (
|
||||||
<ListboxContext.Provider value={{ value, onChange }}>
|
<ListboxContext.Provider value={{ value, onChange }}>
|
||||||
@@ -178,28 +165,6 @@ describe("components/widgets/search", () => {
|
|||||||
openSpy.mockRestore();
|
openSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("gives every provider option an accessible name", () => {
|
|
||||||
renderWithProviders(
|
|
||||||
<Search options={{ provider: ["google", "duckduckgo", "brave"], showSearchSuggestions: false }} />,
|
|
||||||
{ settings: {} },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(screen.getAllByRole("option").map((option) => option.textContent)).toEqual([
|
|
||||||
"Google",
|
|
||||||
"DuckDuckGo",
|
|
||||||
"Brave",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("labels the search input and the provider button", () => {
|
|
||||||
renderWithProviders(<Search options={{ provider: ["google", "duckduckgo"], showSearchSuggestions: false }} />, {
|
|
||||||
settings: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(screen.getByRole("textbox")).toHaveAccessibleName("search.placeholder");
|
|
||||||
expect(screen.getByRole("button")).toHaveAccessibleName(/search\.provider/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("fetches search suggestions and triggers a search when a suggestion is selected", async () => {
|
it("fetches search suggestions and triggers a search when a suggestion is selected", async () => {
|
||||||
const openSpy = vi.spyOn(window, "open").mockImplementation(() => null);
|
const openSpy = vi.spyOn(window, "open").mockImplementation(() => null);
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
|||||||
export default function Widget({ options }) {
|
export default function Widget({ options }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const widgetOptions = { ...options, service_group: "unifi_console", service_name: "unifi_console" };
|
options.service_group = options.service_name = "unifi_console";
|
||||||
const { data: statsData, error: statsError } = useWidgetAPI(widgetOptions, "stat/sites", { index: options.index });
|
const { data: statsData, error: statsError } = useWidgetAPI(options, "stat/sites", { index: options.index });
|
||||||
|
|
||||||
if (statsError) {
|
if (statsError) {
|
||||||
return <Error options={widgetOptions} />;
|
return <Error options={options} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultSite = options.site
|
const defaultSite = options.site
|
||||||
@@ -27,27 +27,27 @@ export default function Widget({ options }) {
|
|||||||
|
|
||||||
if (!defaultSite) {
|
if (!defaultSite) {
|
||||||
return (
|
return (
|
||||||
<Container options={widgetOptions} additionalClassNames="information-widget-unifi-console">
|
<Container options={options} additionalClassNames="information-widget-unifi-console">
|
||||||
<PrimaryText>{t("unifi.wait")}</PrimaryText>
|
<PrimaryText>{t("unifi.wait")}</PrimaryText>
|
||||||
<WidgetIcon icon={SiUbiquiti} />
|
<WidgetIcon icon={SiUbiquiti} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getHealth = (subsystem) => {
|
const wan = defaultSite.health.find((h) => h.subsystem === "wan");
|
||||||
const health = defaultSite.health.find((item) => item.subsystem === subsystem) ?? { status: "unknown" };
|
const lan = defaultSite.health.find((h) => h.subsystem === "lan");
|
||||||
return { ...health, up: health.status === "ok", show: health.status !== "unknown" };
|
const wlan = defaultSite.health.find((h) => h.subsystem === "wlan");
|
||||||
};
|
[wan, lan, wlan].forEach((s) => {
|
||||||
const wan = getHealth("wan");
|
s.up = s.status === "ok";
|
||||||
const lan = getHealth("lan");
|
s.show = s.status !== "unknown";
|
||||||
const wlan = getHealth("wlan");
|
});
|
||||||
const name = wan.gw_name ?? defaultSite.desc;
|
const name = wan.gw_name ?? defaultSite.desc;
|
||||||
const uptime = wan["gw_system-stats"] ? wan["gw_system-stats"].uptime : null;
|
const uptime = wan["gw_system-stats"] ? wan["gw_system-stats"].uptime : null;
|
||||||
|
|
||||||
const dataEmpty = !(wan.show || lan.show || wlan.show || uptime);
|
const dataEmpty = !(wan.show || lan.show || wlan.show || uptime);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container options={widgetOptions} additionalClassNames="information-widget-unifi-console">
|
<Container options={options} additionalClassNames="information-widget-unifi-console">
|
||||||
<Raw>
|
<Raw>
|
||||||
<div className="flex-none flex flex-row items-center mr-3 py-1.5">
|
<div className="flex-none flex flex-row items-center mr-3 py-1.5">
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
|
|||||||
@@ -40,41 +40,32 @@ describe("components/widgets/unifi_console", () => {
|
|||||||
|
|
||||||
it("renders a wait state when no site is available yet", () => {
|
it("renders a wait state when no site is available yet", () => {
|
||||||
useWidgetAPI.mockReturnValue({ data: undefined, error: undefined });
|
useWidgetAPI.mockReturnValue({ data: undefined, error: undefined });
|
||||||
const options = Object.freeze({ index: 0 });
|
|
||||||
|
|
||||||
renderWithProviders(<UnifiConsole options={options} />, { settings: { target: "_self" } });
|
renderWithProviders(<UnifiConsole options={{ index: 0 }} />, { settings: { target: "_self" } });
|
||||||
|
|
||||||
expect(screen.getByText("unifi.wait")).toBeInTheDocument();
|
expect(screen.getByText("unifi.wait")).toBeInTheDocument();
|
||||||
expect(useWidgetAPI).toHaveBeenCalledWith(
|
|
||||||
{ index: 0, service_group: "unifi_console", service_name: "unifi_console" },
|
|
||||||
"stat/sites",
|
|
||||||
{ index: 0 },
|
|
||||||
);
|
|
||||||
expect(options).toEqual({ index: 0 });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders site name and uptime when data is available", () => {
|
it("renders site name and uptime when data is available", () => {
|
||||||
const data = {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
name: "default",
|
|
||||||
desc: "Home",
|
|
||||||
health: [
|
|
||||||
{
|
|
||||||
subsystem: "wan",
|
|
||||||
status: "ok",
|
|
||||||
gw_name: "Router",
|
|
||||||
"gw_system-stats": { uptime: 172800 },
|
|
||||||
},
|
|
||||||
{ subsystem: "lan", status: "unknown" },
|
|
||||||
{ subsystem: "wlan", status: "unknown" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const originalData = structuredClone(data);
|
|
||||||
useWidgetAPI.mockReturnValue({
|
useWidgetAPI.mockReturnValue({
|
||||||
data,
|
data: {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
name: "default",
|
||||||
|
desc: "Home",
|
||||||
|
health: [
|
||||||
|
{
|
||||||
|
subsystem: "wan",
|
||||||
|
status: "ok",
|
||||||
|
gw_name: "Router",
|
||||||
|
"gw_system-stats": { uptime: 172800 },
|
||||||
|
},
|
||||||
|
{ subsystem: "lan", status: "unknown" },
|
||||||
|
{ subsystem: "wlan", status: "unknown" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
error: undefined,
|
error: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,7 +75,6 @@ describe("components/widgets/unifi_console", () => {
|
|||||||
// common.number is mocked to return the numeric value as a string.
|
// common.number is mocked to return the numeric value as a string.
|
||||||
expect(screen.getByText("2")).toBeInTheDocument();
|
expect(screen.getByText("2")).toBeInTheDocument();
|
||||||
expect(screen.getByText("unifi.days")).toBeInTheDocument();
|
expect(screen.getByText("unifi.days")).toBeInTheDocument();
|
||||||
expect(data).toEqual(originalData);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("selects a site by description when options.site is set", () => {
|
it("selects a site by description when options.site is set", () => {
|
||||||
|
|||||||
@@ -71,16 +71,6 @@ function logFailedPasswordSignIn() {
|
|||||||
createLogger("nextauth").warn("Failed password sign-in attempt");
|
createLogger("nextauth").warn("Failed password sign-in attempt");
|
||||||
}
|
}
|
||||||
|
|
||||||
function logNextAuthError(code, metadata) {
|
|
||||||
const error = metadata instanceof Error ? metadata : metadata?.error;
|
|
||||||
|
|
||||||
if (error?.message) {
|
|
||||||
createLogger("nextauth").error("%s: %s", code, error.message);
|
|
||||||
} else {
|
|
||||||
createLogger("nextauth").error("%s", code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let providers = [];
|
let providers = [];
|
||||||
if (authEnabled) {
|
if (authEnabled) {
|
||||||
if (hasOidcConfig) {
|
if (hasOidcConfig) {
|
||||||
@@ -150,7 +140,7 @@ export const authOptions = {
|
|||||||
signIn: "/auth/signin",
|
signIn: "/auth/signin",
|
||||||
},
|
},
|
||||||
logger: {
|
logger: {
|
||||||
error: logNextAuthError,
|
error: (code) => createLogger("nextauth").error("%s", code),
|
||||||
warn: (code) => createLogger("nextauth").warn("%s", code),
|
warn: (code) => createLogger("nextauth").warn("%s", code),
|
||||||
debug: (code) => createLogger("nextauth").debug("%s", code),
|
debug: (code) => createLogger("nextauth").debug("%s", code),
|
||||||
},
|
},
|
||||||
|
|||||||
+28
-35
@@ -12,7 +12,7 @@ import dynamic from "next/dynamic";
|
|||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import Script from "next/script";
|
import Script from "next/script";
|
||||||
import { useCallback, useContext, useEffect, useMemo, useState } from "react";
|
import { useContext, useEffect, useMemo, useState } from "react";
|
||||||
import { BiError } from "react-icons/bi";
|
import { BiError } from "react-icons/bi";
|
||||||
import useSWR, { SWRConfig } from "swr";
|
import useSWR, { SWRConfig } from "swr";
|
||||||
import { ColorContext } from "utils/contexts/color";
|
import { ColorContext } from "utils/contexts/color";
|
||||||
@@ -102,29 +102,7 @@ function Index({ initialSettings, fallback }) {
|
|||||||
const [stale, setStale] = useState(false);
|
const [stale, setStale] = useState(false);
|
||||||
const { data: errorsData } = useSWR("/api/validate");
|
const { data: errorsData } = useSWR("/api/validate");
|
||||||
const { error: validateError } = errorsData || {};
|
const { error: validateError } = errorsData || {};
|
||||||
|
const { data: hashData, mutate: mutateHash } = useSWR("/api/hash");
|
||||||
const handleHashData = useCallback((hashData) => {
|
|
||||||
if (typeof window === "undefined" || !hashData?.hash) return;
|
|
||||||
|
|
||||||
const previousHash = localStorage.getItem("hash");
|
|
||||||
|
|
||||||
if (!previousHash) {
|
|
||||||
localStorage.setItem("hash", hashData.hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previousHash && previousHash !== hashData.hash) {
|
|
||||||
setStale(true);
|
|
||||||
localStorage.setItem("hash", hashData.hash);
|
|
||||||
|
|
||||||
fetch("/api/revalidate").then((res) => {
|
|
||||||
if (res.ok) {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const { mutate: mutateHash } = useSWR("/api/hash", { onSuccess: handleHashData });
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (windowFocused) {
|
if (windowFocused) {
|
||||||
@@ -132,6 +110,29 @@ function Index({ initialSettings, fallback }) {
|
|||||||
}
|
}
|
||||||
}, [windowFocused, mutateHash]);
|
}, [windowFocused, mutateHash]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (hashData) {
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
const previousHash = localStorage.getItem("hash");
|
||||||
|
|
||||||
|
if (!previousHash) {
|
||||||
|
localStorage.setItem("hash", hashData.hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousHash && previousHash !== hashData.hash) {
|
||||||
|
setStale(true);
|
||||||
|
localStorage.setItem("hash", hashData.hash);
|
||||||
|
|
||||||
|
fetch("/api/revalidate").then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [hashData]);
|
||||||
|
|
||||||
if (validateError) {
|
if (validateError) {
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-screen container m-auto justify-center p-10 pointer-events-none">
|
<div className="w-full h-screen container m-auto justify-center p-10 pointer-events-none">
|
||||||
@@ -263,13 +264,6 @@ function Home({ initialSettings }) {
|
|||||||
e.key.match(/([à-ü]|[À-Ü]|!)/g) ||
|
e.key.match(/([à-ü]|[À-Ü]|!)/g) ||
|
||||||
(e.key === "v" && (e.ctrlKey || e.metaKey))
|
(e.key === "v" && (e.ctrlKey || e.metaKey))
|
||||||
) {
|
) {
|
||||||
if (e.key.length === 1 && !(e.key === "v" && (e.ctrlKey || e.metaKey))) {
|
|
||||||
e.preventDefault();
|
|
||||||
// whitespace opens the search but shouldn't be in it
|
|
||||||
if (e.key.trim()) {
|
|
||||||
setSearchString((currentSearchString) => currentSearchString + e.key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setSearching(true);
|
setSearching(true);
|
||||||
} else if (e.key === "Escape") {
|
} else if (e.key === "Escape") {
|
||||||
setSearchString("");
|
setSearchString("");
|
||||||
@@ -426,11 +420,10 @@ function Home({ initialSettings }) {
|
|||||||
/>
|
/>
|
||||||
{settings.disableIndexing && <meta name="robots" content="noindex, nofollow" />}
|
{settings.disableIndexing && <meta name="robots" content="noindex, nofollow" />}
|
||||||
{settings.base && <base href={settings.base} />}
|
{settings.base && <base href={settings.base} />}
|
||||||
{/* from props, not context so its set before running JS */}
|
{settings.favicon ? (
|
||||||
{initialSettings.favicon ? (
|
|
||||||
<>
|
<>
|
||||||
<link rel="icon" href={initialSettings.favicon} />
|
<link rel="icon" href={settings.favicon} />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href={initialSettings.favicon} />
|
<link rel="apple-touch-icon" sizes="180x180" href={settings.favicon} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ export function ColorProvider({ initialTheme, children }) {
|
|||||||
lastColor = rawColor;
|
lastColor = rawColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialTheme !== undefined) setColor(initialTheme ?? getInitialColor());
|
||||||
|
}, [initialTheme]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
rawSetColor(color);
|
rawSetColor(color);
|
||||||
}, [color]);
|
}, [color]);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { createContext, useMemo, useState } from "react";
|
import { createContext, useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
export const SettingsContext = createContext();
|
export const SettingsContext = createContext();
|
||||||
|
|
||||||
export function SettingsProvider({ initialSettings, children }) {
|
export function SettingsProvider({ initialSettings, children }) {
|
||||||
const [settings, setSettings] = useState(() => initialSettings ?? {});
|
const [settings, setSettings] = useState(() => initialSettings ?? {});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialSettings !== undefined) setSettings(initialSettings ?? {});
|
||||||
|
}, [initialSettings]);
|
||||||
|
|
||||||
const value = useMemo(() => ({ settings, setSettings }), [settings]);
|
const value = useMemo(() => ({ settings, setSettings }), [settings]);
|
||||||
|
|
||||||
return <SettingsContext.Provider value={value}>{children}</SettingsContext.Provider>;
|
return <SettingsContext.Provider value={value}>{children}</SettingsContext.Provider>;
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { createContext, useMemo, useState } from "react";
|
import { createContext, useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
export const TabContext = createContext();
|
export const TabContext = createContext();
|
||||||
|
|
||||||
export function TabProvider({ initialTab, children }) {
|
export function TabProvider({ initialTab, children }) {
|
||||||
const [activeTab, setActiveTab] = useState(() => initialTab ?? false);
|
const [activeTab, setActiveTab] = useState(() => initialTab ?? false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialTab !== undefined) setActiveTab(initialTab ?? false);
|
||||||
|
}, [initialTab]);
|
||||||
|
|
||||||
const value = useMemo(() => ({ activeTab, setActiveTab }), [activeTab]);
|
const value = useMemo(() => ({ activeTab, setActiveTab }), [activeTab]);
|
||||||
|
|
||||||
return <TabContext.Provider value={value}>{children}</TabContext.Provider>;
|
return <TabContext.Provider value={value}>{children}</TabContext.Provider>;
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ export function ThemeProvider({ initialTheme, children }) {
|
|||||||
localStorage.setItem("theme-mode", rawTheme);
|
localStorage.setItem("theme-mode", rawTheme);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialTheme !== undefined) setTheme(initialTheme ?? getInitialTheme());
|
||||||
|
}, [initialTheme]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
rawSetTheme(theme);
|
rawSetTheme(theme);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
import { useSyncExternalStore } from "react";
|
|
||||||
|
|
||||||
const MINUTE = 60_000;
|
|
||||||
const stores = new Map();
|
|
||||||
|
|
||||||
function getStore(refreshInterval) {
|
|
||||||
const existing = stores.get(refreshInterval);
|
|
||||||
if (existing) return existing;
|
|
||||||
|
|
||||||
const listeners = new Set();
|
|
||||||
let now = null; // null until mounted, so SSR and hydration render the same thing
|
|
||||||
let timer = null;
|
|
||||||
|
|
||||||
const store = {
|
|
||||||
getSnapshot: () => now,
|
|
||||||
subscribe: (onStoreChange) => {
|
|
||||||
listeners.add(onStoreChange);
|
|
||||||
|
|
||||||
if (!timer) {
|
|
||||||
now = Date.now();
|
|
||||||
timer = setInterval(() => {
|
|
||||||
now = Date.now();
|
|
||||||
listeners.forEach((listener) => listener());
|
|
||||||
}, refreshInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
listeners.delete(onStoreChange);
|
|
||||||
if (!listeners.size) {
|
|
||||||
clearInterval(timer);
|
|
||||||
timer = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
stores.set(refreshInterval, store);
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns null on the server and during hydration, then the current time.
|
|
||||||
export default function useCurrentTime(refreshInterval = MINUTE) {
|
|
||||||
const { subscribe, getSnapshot } = getStore(refreshInterval);
|
|
||||||
return useSyncExternalStore(subscribe, getSnapshot, () => null);
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
// @vitest-environment jsdom
|
|
||||||
|
|
||||||
import { act, render, screen } from "@testing-library/react";
|
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
||||||
|
|
||||||
import useCurrentTime from "./use-current-time";
|
|
||||||
|
|
||||||
function CurrentTime({ refreshInterval }) {
|
|
||||||
return <span>{useCurrentTime(refreshInterval)}</span>;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("utils/hooks/use-current-time", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
vi.useFakeTimers();
|
|
||||||
vi.setSystemTime(1_000);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.useRealTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("updates at the requested interval", () => {
|
|
||||||
render(<CurrentTime refreshInterval={5_000} />);
|
|
||||||
expect(screen.getByText("1000")).toBeInTheDocument();
|
|
||||||
|
|
||||||
act(() => {
|
|
||||||
vi.advanceTimersByTime(5_000);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(screen.getByText("6000")).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,17 +1,26 @@
|
|||||||
import { useSyncExternalStore } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
const hasFocus = () => typeof document !== "undefined" && document.hasFocus();
|
const hasFocus = () => typeof document !== "undefined" && document.hasFocus();
|
||||||
|
|
||||||
const subscribe = (onFocusChange) => {
|
const useWindowFocus = () => {
|
||||||
window.addEventListener("focus", onFocusChange);
|
const [focused, setFocused] = useState(hasFocus);
|
||||||
window.addEventListener("blur", onFocusChange);
|
|
||||||
|
|
||||||
return () => {
|
useEffect(() => {
|
||||||
window.removeEventListener("focus", onFocusChange);
|
setFocused(hasFocus());
|
||||||
window.removeEventListener("blur", onFocusChange);
|
|
||||||
};
|
const onFocus = () => setFocused(true);
|
||||||
|
const onBlur = () => setFocused(false);
|
||||||
|
|
||||||
|
window.addEventListener("focus", onFocus);
|
||||||
|
window.addEventListener("blur", onBlur);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("focus", onFocus);
|
||||||
|
window.removeEventListener("blur", onBlur);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return focused;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useWindowFocus = () => useSyncExternalStore(subscribe, hasFocus, () => false);
|
|
||||||
|
|
||||||
export default useWindowFocus;
|
export default useWindowFocus;
|
||||||
|
|||||||
@@ -12,17 +12,15 @@ function Fixture() {
|
|||||||
|
|
||||||
describe("utils/hooks/window-focus", () => {
|
describe("utils/hooks/window-focus", () => {
|
||||||
it("tracks focus/blur events", async () => {
|
it("tracks focus/blur events", async () => {
|
||||||
const hasFocus = vi.spyOn(document, "hasFocus").mockReturnValue(true);
|
vi.spyOn(document, "hasFocus").mockReturnValue(true);
|
||||||
|
|
||||||
render(<Fixture />);
|
render(<Fixture />);
|
||||||
|
|
||||||
expect(screen.getByTestId("focused")).toHaveTextContent("true");
|
expect(screen.getByTestId("focused")).toHaveTextContent("true");
|
||||||
|
|
||||||
hasFocus.mockReturnValue(false);
|
|
||||||
window.dispatchEvent(new Event("blur"));
|
window.dispatchEvent(new Event("blur"));
|
||||||
await waitFor(() => expect(screen.getByTestId("focused")).toHaveTextContent("false"));
|
await waitFor(() => expect(screen.getByTestId("focused")).toHaveTextContent("false"));
|
||||||
|
|
||||||
hasFocus.mockReturnValue(true);
|
|
||||||
window.dispatchEvent(new Event("focus"));
|
window.dispatchEvent(new Event("focus"));
|
||||||
await waitFor(() => expect(screen.getByTestId("focused")).toHaveTextContent("true"));
|
await waitFor(() => expect(screen.getByTestId("focused")).toHaveTextContent("true"));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import useSWR from "swr";
|
|||||||
|
|
||||||
import { formatProxyUrl } from "./api-helpers";
|
import { formatProxyUrl } from "./api-helpers";
|
||||||
|
|
||||||
export default function useWidgetAPI(widget, endpoint, queryParams, swrConfig = {}) {
|
export default function useWidgetAPI(widget, ...options) {
|
||||||
const config = { ...swrConfig };
|
const config = {};
|
||||||
if (queryParams?.refreshInterval) {
|
if (options && options[1]?.refreshInterval) {
|
||||||
config.refreshInterval = queryParams.refreshInterval;
|
config.refreshInterval = options[1].refreshInterval;
|
||||||
}
|
}
|
||||||
let url = formatProxyUrl(widget, endpoint, queryParams);
|
let url = formatProxyUrl(widget, ...options);
|
||||||
if (endpoint === "") {
|
if (options[0] === "") {
|
||||||
url = null;
|
url = null;
|
||||||
}
|
}
|
||||||
const { data, error, mutate } = useSWR(url, config);
|
const { data, error, mutate } = useSWR(url, config);
|
||||||
|
|||||||
@@ -28,18 +28,6 @@ describe("utils/proxy/use-widget-api", () => {
|
|||||||
expect(result.mutate).toBe("m");
|
expect(result.mutate).toBe("m");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes additional SWR configuration separately from the proxy query", () => {
|
|
||||||
useSWR.mockReturnValue({ data: undefined, error: undefined, mutate: vi.fn() });
|
|
||||||
|
|
||||||
const widget = { service_group: "g", service_name: "s", index: 0 };
|
|
||||||
const onSuccess = vi.fn();
|
|
||||||
useWidgetAPI(widget, "status", { refreshInterval: 123 }, { onSuccess });
|
|
||||||
|
|
||||||
const [url, config] = useSWR.mock.calls[0];
|
|
||||||
expect(url).not.toContain("onSuccess");
|
|
||||||
expect(config).toEqual({ refreshInterval: 123, onSuccess });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns data.error as the top-level error", () => {
|
it("returns data.error as the top-level error", () => {
|
||||||
const dataError = { message: "nope" };
|
const dataError = { message: "nope" };
|
||||||
useSWR.mockReturnValue({ data: { error: dataError }, error: undefined, mutate: vi.fn() });
|
useSWR.mockReturnValue({ data: { error: dataError }, error: undefined, mutate: vi.fn() });
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
export default function withWidgetFields(service, defaultFields, maxFields = 4) {
|
|
||||||
const configuredFields = service.widget.fields;
|
|
||||||
const fields = (configuredFields?.length ? configuredFields : defaultFields).slice(0, maxFields);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...service,
|
|
||||||
widget: {
|
|
||||||
...service.widget,
|
|
||||||
fields,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
|
|
||||||
import withWidgetFields from "./widget-fields";
|
|
||||||
|
|
||||||
describe("utils/widget-fields", () => {
|
|
||||||
it("applies defaults without modifying the service", () => {
|
|
||||||
const service = { name: "Example", widget: { type: "example" } };
|
|
||||||
|
|
||||||
const normalizedService = withWidgetFields(service, ["one", "two"]);
|
|
||||||
|
|
||||||
expect(normalizedService).toEqual({
|
|
||||||
name: "Example",
|
|
||||||
widget: { type: "example", fields: ["one", "two"] },
|
|
||||||
});
|
|
||||||
expect(service).toEqual({ name: "Example", widget: { type: "example" } });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("treats an explicitly empty fields list as unset", () => {
|
|
||||||
const service = { widget: { type: "example", fields: [] } };
|
|
||||||
|
|
||||||
const normalizedService = withWidgetFields(service, ["one", "two"]);
|
|
||||||
|
|
||||||
expect(normalizedService.widget.fields).toEqual(["one", "two"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("copies and limits configured fields", () => {
|
|
||||||
const service = { widget: { type: "example", fields: ["one", "two", "three"] } };
|
|
||||||
|
|
||||||
const normalizedService = withWidgetFields(service, ["default"], 2);
|
|
||||||
|
|
||||||
expect(normalizedService.widget.fields).toEqual(["one", "two"]);
|
|
||||||
expect(normalizedService.widget.fields).not.toBe(service.widget.fields);
|
|
||||||
expect(service.widget.fields).toEqual(["one", "two", "three"]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -3,15 +3,19 @@ import Container from "components/services/widget/container";
|
|||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
import withWidgetFields from "utils/widget-fields";
|
|
||||||
|
|
||||||
const DEFAULT_FIELDS = ["running", "stopped", "total", "image_updates"];
|
const MAX_FIELDS = 4;
|
||||||
|
|
||||||
export default function Component({ service: configuredService }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const service = withWidgetFields(configuredService, DEFAULT_FIELDS);
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
|
if (!widget.fields) {
|
||||||
|
widget.fields = ["running", "stopped", "total", "image_updates"];
|
||||||
|
} else if (widget.fields.length > MAX_FIELDS) {
|
||||||
|
widget.fields = widget.fields.slice(0, MAX_FIELDS);
|
||||||
|
}
|
||||||
|
|
||||||
const envNotSet = widget.env == null || widget.env === "";
|
const envNotSet = widget.env == null || widget.env === "";
|
||||||
|
|
||||||
const { data: containers, error: containersError } = useWidgetAPI(widget, envNotSet ? "" : "containers");
|
const { data: containers, error: containersError } = useWidgetAPI(widget, envNotSet ? "" : "containers");
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ describe("widgets/arcane/component", () => {
|
|||||||
expect(screen.getByText("arcane.image_updates")).toBeInTheDocument();
|
expect(screen.getByText("arcane.image_updates")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders only the first four custom fields without mutating the input", () => {
|
it("truncates custom fields to the max allowed", () => {
|
||||||
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
|
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
|
||||||
|
|
||||||
const service = {
|
const service = {
|
||||||
@@ -65,8 +65,7 @@ describe("widgets/arcane/component", () => {
|
|||||||
};
|
};
|
||||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
// The helper caps the copied fields used for rendering and leaves the configured service unchanged.
|
// sliced to first four entries
|
||||||
expect(service.widget.fields).toEqual(["running", "stopped", "total", "images", "images_unused"]);
|
|
||||||
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
||||||
expect(screen.getByText("docker.running")).toBeInTheDocument();
|
expect(screen.getByText("docker.running")).toBeInTheDocument();
|
||||||
expect(screen.getByText("dockhand.stopped")).toBeInTheDocument();
|
expect(screen.getByText("dockhand.stopped")).toBeInTheDocument();
|
||||||
|
|||||||
@@ -2,14 +2,19 @@ import Block from "components/services/widget/block";
|
|||||||
import Container from "components/services/widget/container";
|
import Container from "components/services/widget/container";
|
||||||
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
import withWidgetFields from "utils/widget-fields";
|
|
||||||
|
|
||||||
const DEFAULT_FIELDS = ["apps", "synced", "outOfSync", "healthy"];
|
export default function Component({ service }) {
|
||||||
|
|
||||||
export default function Component({ service: configuredService }) {
|
|
||||||
const service = withWidgetFields(configuredService, DEFAULT_FIELDS);
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
|
if (!widget.fields) {
|
||||||
|
widget.fields = ["apps", "synced", "outOfSync", "healthy"];
|
||||||
|
}
|
||||||
|
|
||||||
|
const MAX_ALLOWED_FIELDS = 4;
|
||||||
|
if (widget.fields.length > MAX_ALLOWED_FIELDS) {
|
||||||
|
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
|
||||||
|
}
|
||||||
|
|
||||||
const { data: appsData, error: appsError } = useWidgetAPI(widget, "applications");
|
const { data: appsData, error: appsError } = useWidgetAPI(widget, "applications");
|
||||||
|
|
||||||
const appCounts = widget.fields.map((status) => {
|
const appCounts = widget.fields.map((status) => {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe("widgets/argocd/component", () => {
|
|||||||
const service = { widget: { type: "argocd", fields: ["apps", "synced", "outOfSync", "healthy", "extra"] } };
|
const service = { widget: { type: "argocd", fields: ["apps", "synced", "outOfSync", "healthy", "extra"] } };
|
||||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
expect(service.widget.fields).toEqual(["apps", "synced", "outOfSync", "healthy", "extra"]);
|
expect(service.widget.fields).toEqual(["apps", "synced", "outOfSync", "healthy"]);
|
||||||
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
||||||
expect(screen.getByText("argocd.apps")).toBeInTheDocument();
|
expect(screen.getByText("argocd.apps")).toBeInTheDocument();
|
||||||
expect(screen.getByText("argocd.synced")).toBeInTheDocument();
|
expect(screen.getByText("argocd.synced")).toBeInTheDocument();
|
||||||
|
|||||||
@@ -2,14 +2,10 @@ import Block from "components/services/widget/block";
|
|||||||
import Container from "components/services/widget/container";
|
import Container from "components/services/widget/container";
|
||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
|
|
||||||
import useCurrentTime from "utils/hooks/use-current-time";
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
const DAY = 24 * 60 * 60 * 1000;
|
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const currentTime = useCurrentTime();
|
|
||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
const isV2 = widget.version === 2;
|
const isV2 = widget.version === 2;
|
||||||
@@ -49,7 +45,7 @@ export default function Component({ service }) {
|
|||||||
switch (widget.version) {
|
switch (widget.version) {
|
||||||
// v1 is default
|
// v1 is default
|
||||||
default:
|
default:
|
||||||
const yesterday = currentTime - DAY;
|
const yesterday = new Date(Date.now()).setHours(-24);
|
||||||
loginsLast24H = loginsData.reduce(
|
loginsLast24H = loginsData.reduce(
|
||||||
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
(total, current) => (current.x_cord >= yesterday ? total + current.y_cord : total),
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ describe("widgets/authentik/component", () => {
|
|||||||
|
|
||||||
it("computes v1 login/failed counts for entries within the last 24h window", () => {
|
it("computes v1 login/failed counts for entries within the last 24h window", () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
// Use midday so a mistaken previous-midnight cutoff would include the 25-hour-old entries.
|
vi.setSystemTime(new Date("2026-01-02T00:00:00Z"));
|
||||||
vi.setSystemTime(new Date("2026-01-02T12:00:00Z"));
|
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const oneHourAgo = now - 60 * 60 * 1000;
|
const oneHourAgo = now - 60 * 60 * 1000;
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ import Container from "components/services/widget/container";
|
|||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
import withWidgetFields from "utils/widget-fields";
|
|
||||||
|
|
||||||
const BACKREST_DEFAULT_FIELDS = ["num_success_latest", "num_failure_latest", "num_failure_30", "bytes_added_30"];
|
const BACKREST_DEFAULT_FIELDS = ["num_success_latest", "num_failure_latest", "num_failure_30", "bytes_added_30"];
|
||||||
|
const MAX_ALLOWED_FIELDS = 4;
|
||||||
|
|
||||||
export default function Component({ service: configuredService }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const service = withWidgetFields(configuredService, BACKREST_DEFAULT_FIELDS);
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data, error } = useWidgetAPI(widget, "summary");
|
const { data, error } = useWidgetAPI(widget, "summary");
|
||||||
@@ -19,6 +18,12 @@ export default function Component({ service: configuredService }) {
|
|||||||
return <Container service={service} error={error} />;
|
return <Container service={service} error={error} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!widget.fields?.length) {
|
||||||
|
widget.fields = BACKREST_DEFAULT_FIELDS;
|
||||||
|
} else if (widget.fields.length > MAX_ALLOWED_FIELDS) {
|
||||||
|
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
|
||||||
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ describe("widgets/backrest/component", () => {
|
|||||||
const service = { widget: { type: "backrest" } };
|
const service = { widget: { type: "backrest" } };
|
||||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
expect(service.widget.fields).toBeUndefined();
|
expect(service.widget.fields).toEqual([
|
||||||
|
"num_success_latest",
|
||||||
|
"num_failure_latest",
|
||||||
|
"num_failure_30",
|
||||||
|
"bytes_added_30",
|
||||||
|
]);
|
||||||
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
||||||
|
|
||||||
expect(screen.getByText("backrest.num_success_latest")).toBeInTheDocument();
|
expect(screen.getByText("backrest.num_success_latest")).toBeInTheDocument();
|
||||||
@@ -43,7 +48,7 @@ describe("widgets/backrest/component", () => {
|
|||||||
|
|
||||||
renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
expect(service.widget.fields).toEqual(["a", "b", "c", "d", "e"]);
|
expect(service.widget.fields).toEqual(["a", "b", "c", "d"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders values and respects field filtering", () => {
|
it("renders values and respects field filtering", () => {
|
||||||
|
|||||||
@@ -3,21 +3,23 @@ import Container from "components/services/widget/container";
|
|||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
import withWidgetFields from "utils/widget-fields";
|
|
||||||
|
|
||||||
const SUMMARY_FIELDS = ["systems", "up"];
|
export default function Component({ service }) {
|
||||||
const SYSTEM_FIELDS = ["name", "status", "cpu", "memory"];
|
|
||||||
|
|
||||||
export default function Component({ service: configuredService }) {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const defaultFields = configuredService.widget.systemId ? SYSTEM_FIELDS : SUMMARY_FIELDS;
|
|
||||||
const service = withWidgetFields(configuredService, defaultFields);
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
const { systemId } = widget;
|
const { systemId } = widget;
|
||||||
|
|
||||||
const { data: systems, error: systemsError } = useWidgetAPI(widget, "systems");
|
const { data: systems, error: systemsError } = useWidgetAPI(widget, "systems");
|
||||||
|
|
||||||
|
const MAX_ALLOWED_FIELDS = 4;
|
||||||
|
if (!widget.fields?.length > 0) {
|
||||||
|
widget.fields = systemId ? ["name", "status", "cpu", "memory"] : ["systems", "up"];
|
||||||
|
}
|
||||||
|
if (widget.fields?.length > MAX_ALLOWED_FIELDS) {
|
||||||
|
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
|
||||||
|
}
|
||||||
|
|
||||||
let system = null;
|
let system = null;
|
||||||
let finalError = systemsError;
|
let finalError = systemsError;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe("widgets/beszel/component", () => {
|
|||||||
const service = { widget: { type: "beszel" } };
|
const service = { widget: { type: "beszel" } };
|
||||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
expect(service.widget.fields).toBeUndefined();
|
expect(service.widget.fields).toEqual(["systems", "up"]);
|
||||||
expect(container.querySelectorAll(".service-block")).toHaveLength(2);
|
expect(container.querySelectorAll(".service-block")).toHaveLength(2);
|
||||||
expect(screen.getByText("beszel.systems")).toBeInTheDocument();
|
expect(screen.getByText("beszel.systems")).toBeInTheDocument();
|
||||||
expect(screen.getByText("beszel.up")).toBeInTheDocument();
|
expect(screen.getByText("beszel.up")).toBeInTheDocument();
|
||||||
@@ -66,7 +66,7 @@ describe("widgets/beszel/component", () => {
|
|||||||
const service = { widget: { type: "beszel", systemId: "sys1" } };
|
const service = { widget: { type: "beszel", systemId: "sys1" } };
|
||||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
expect(service.widget.fields).toBeUndefined();
|
expect(service.widget.fields).toEqual(["name", "status", "cpu", "memory"]);
|
||||||
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
|
||||||
|
|
||||||
expectBlockValue(container, "beszel.name", "MySystem");
|
expectBlockValue(container, "beszel.name", "MySystem");
|
||||||
|
|||||||
@@ -38,16 +38,16 @@ const colorVariants = {
|
|||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
|
const [showDate, setShowDate] = useState(null);
|
||||||
const [events, setEvents] = useState({});
|
const [events, setEvents] = useState({});
|
||||||
const nowDate = DateTime.now().setLocale(i18n.language);
|
const nowDate = DateTime.now().setLocale(i18n.language);
|
||||||
const currentDate = widget?.timezone ? nowDate.setZone(widget?.timezone).startOf("day") : nowDate;
|
const currentDate = widget?.timezone ? nowDate.setZone(widget?.timezone).startOf("day") : nowDate;
|
||||||
const [showDate, setShowDate] = useState(null);
|
|
||||||
const { settings } = useContext(SettingsContext);
|
const { settings } = useContext(SettingsContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// seeded after mount, not during render: "today" is client-only and would break hydration
|
if (!showDate) {
|
||||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
setShowDate(currentDate);
|
||||||
if (!showDate) setShowDate(currentDate);
|
}
|
||||||
}, [showDate, currentDate]);
|
}, [showDate, currentDate]);
|
||||||
|
|
||||||
// params for API fetch
|
// params for API fetch
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import ICAL from "ical.js";
|
import ICAL from "ical.js";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
import { useTranslation } from "next-i18next/pages";
|
import { useTranslation } from "next-i18next/pages";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
import Error from "../../../components/services/widget/error";
|
import Error from "../../../components/services/widget/error";
|
||||||
import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
||||||
@@ -17,67 +17,65 @@ function simpleHash(str) {
|
|||||||
return Math.abs(hash).toString(36);
|
return Math.abs(hash).toString(36);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEvent(event, type) {
|
|
||||||
return {
|
|
||||||
id: event.getFirstPropertyValue("uid"),
|
|
||||||
type,
|
|
||||||
title: event.getFirstPropertyValue("summary"),
|
|
||||||
rrule: event.getFirstPropertyValue("rrule"),
|
|
||||||
dtstart:
|
|
||||||
event.getFirstPropertyValue("dtstart") ||
|
|
||||||
event.getFirstPropertyValue("due") ||
|
|
||||||
event.getFirstPropertyValue("completed") ||
|
|
||||||
ICAL.Time.now(), // handles events without a date
|
|
||||||
dtend:
|
|
||||||
event.getFirstPropertyValue("dtend") ||
|
|
||||||
event.getFirstPropertyValue("due") ||
|
|
||||||
event.getFirstPropertyValue("completed") ||
|
|
||||||
ICAL.Time.now(), // handles events without a date
|
|
||||||
location: event.getFirstPropertyValue("location"),
|
|
||||||
status: event.getFirstPropertyValue("status"),
|
|
||||||
url: event.getFirstPropertyValue("url"),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Integration({ config, params, setEvents, hideErrors, timezone }) {
|
export default function Integration({ config, params, setEvents, hideErrors, timezone }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { data: icalData, error: icalError } = useWidgetAPI(config, config.name, {
|
const { data: icalData, error: icalError } = useWidgetAPI(config, config.name, {
|
||||||
refreshInterval: 300000, // 5 minutes
|
refreshInterval: 300000, // 5 minutes
|
||||||
});
|
});
|
||||||
|
|
||||||
const { events, dataError } = useMemo(() => {
|
|
||||||
if (icalError || !icalData || icalData.error) {
|
|
||||||
return { events: [], dataError: undefined };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!icalData.data) {
|
|
||||||
return {
|
|
||||||
events: [],
|
|
||||||
dataError: { message: `'${config.name}': ${t("calendar.errorWhenLoadingData")}` },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const jCal = ICAL.parse(icalData.data);
|
|
||||||
const vCalendar = new ICAL.Component(jCal);
|
|
||||||
const parsedEvents = [
|
|
||||||
...vCalendar.getAllSubcomponents("vevent").map((event) => buildEvent(event, "vevent")),
|
|
||||||
...vCalendar.getAllSubcomponents("vtodo").map((todo) => buildEvent(todo, "vtodo")),
|
|
||||||
];
|
|
||||||
|
|
||||||
return {
|
|
||||||
events: parsedEvents,
|
|
||||||
dataError:
|
|
||||||
parsedEvents.length === 0 ? { message: `'${config.name}': ${t("calendar.noEventsFound")}` } : undefined,
|
|
||||||
};
|
|
||||||
}, [icalData, icalError, config.name, t]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { showName = false } = config?.params || {};
|
const { showName = false } = config?.params || {};
|
||||||
|
let events = [];
|
||||||
|
|
||||||
|
if (!icalError && icalData && !icalData.error) {
|
||||||
|
if (!icalData.data) {
|
||||||
|
icalData.error = { message: `'${config.name}': ${t("calendar.errorWhenLoadingData")}` };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const jCal = ICAL.parse(icalData.data);
|
||||||
|
const vCalendar = new ICAL.Component(jCal);
|
||||||
|
|
||||||
|
const buildEvent = (event, type) => {
|
||||||
|
return {
|
||||||
|
id: event.getFirstPropertyValue("uid"),
|
||||||
|
type,
|
||||||
|
title: event.getFirstPropertyValue("summary"),
|
||||||
|
rrule: event.getFirstPropertyValue("rrule"),
|
||||||
|
dtstart:
|
||||||
|
event.getFirstPropertyValue("dtstart") ||
|
||||||
|
event.getFirstPropertyValue("due") ||
|
||||||
|
event.getFirstPropertyValue("completed") ||
|
||||||
|
ICAL.Time.now(), // handles events without a date
|
||||||
|
dtend:
|
||||||
|
event.getFirstPropertyValue("dtend") ||
|
||||||
|
event.getFirstPropertyValue("due") ||
|
||||||
|
event.getFirstPropertyValue("completed") ||
|
||||||
|
ICAL.Time.now(), // handles events without a date
|
||||||
|
location: event.getFirstPropertyValue("location"),
|
||||||
|
status: event.getFirstPropertyValue("status"),
|
||||||
|
url: event.getFirstPropertyValue("url"),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEvents = () => {
|
||||||
|
const vEvents = vCalendar.getAllSubcomponents("vevent").map((event) => buildEvent(event, "vevent"));
|
||||||
|
|
||||||
|
const vTodos = vCalendar.getAllSubcomponents("vtodo").map((todo) => buildEvent(todo, "vtodo"));
|
||||||
|
|
||||||
|
return [...vEvents, ...vTodos];
|
||||||
|
};
|
||||||
|
|
||||||
|
events = getEvents();
|
||||||
|
if (events.length === 0) {
|
||||||
|
icalData.error = { message: `'${config.name}': ${t("calendar.noEventsFound")}` };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const startDate = DateTime.fromISO(params.start);
|
const startDate = DateTime.fromISO(params.start);
|
||||||
const endDate = DateTime.fromISO(params.end);
|
const endDate = DateTime.fromISO(params.end);
|
||||||
|
|
||||||
if (events.length === 0 || !startDate.isValid || !endDate.isValid) {
|
if (icalError || events.length === 0 || !startDate.isValid || !endDate.isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +113,7 @@ export default function Integration({ config, params, setEvents, hideErrors, tim
|
|||||||
return occurrences;
|
return occurrences;
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventsToAdd = {};
|
const eventsToAdd = [];
|
||||||
events.forEach((event) => {
|
events.forEach((event) => {
|
||||||
const occurrences = getOcurrencesFromRange(event);
|
const occurrences = getOcurrencesFromRange(event);
|
||||||
|
|
||||||
@@ -156,8 +154,8 @@ export default function Integration({ config, params, setEvents, hideErrors, tim
|
|||||||
});
|
});
|
||||||
|
|
||||||
setEvents((prevEvents) => ({ ...prevEvents, ...eventsToAdd }));
|
setEvents((prevEvents) => ({ ...prevEvents, ...eventsToAdd }));
|
||||||
}, [events, config, params, setEvents, timezone]);
|
}, [icalData, icalError, config, params, setEvents, timezone, t]);
|
||||||
|
|
||||||
const error = icalError ?? icalData?.error ?? dataError;
|
const error = icalError ?? icalData?.error;
|
||||||
return error && !hideErrors && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
|
return error && !hideErrors && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// @vitest-environment jsdom
|
// @vitest-environment jsdom
|
||||||
|
|
||||||
import { render, screen, waitFor } from "@testing-library/react";
|
import { render, waitFor } from "@testing-library/react";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
const { useWidgetAPI } = vi.hoisted(() => ({
|
const { useWidgetAPI } = vi.hoisted(() => ({
|
||||||
@@ -12,45 +12,6 @@ vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI }));
|
|||||||
import Integration from "./ical";
|
import Integration from "./ical";
|
||||||
|
|
||||||
describe("widgets/calendar/integrations/ical", () => {
|
describe("widgets/calendar/integrations/ical", () => {
|
||||||
it("reports a missing calendar payload without mutating the response", () => {
|
|
||||||
const data = {};
|
|
||||||
useWidgetAPI.mockReturnValue({ data, error: undefined });
|
|
||||||
|
|
||||||
render(
|
|
||||||
<Integration
|
|
||||||
config={{ name: "Work", type: "ical" }}
|
|
||||||
params={{ start: "2099-01-01", end: "2099-01-02" }}
|
|
||||||
setEvents={vi.fn()}
|
|
||||||
hideErrors={false}
|
|
||||||
timezone="utc"
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(screen.getByText(/'Work': calendar\.errorWhenLoadingData/)).toBeInTheDocument();
|
|
||||||
expect(data).toEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("reports a calendar with no events without mutating the response", () => {
|
|
||||||
const data = {
|
|
||||||
data: ["BEGIN:VCALENDAR", "VERSION:2.0", "PRODID:-//Test//EN", "END:VCALENDAR", ""].join("\n"),
|
|
||||||
};
|
|
||||||
const originalData = structuredClone(data);
|
|
||||||
useWidgetAPI.mockReturnValue({ data, error: undefined });
|
|
||||||
|
|
||||||
render(
|
|
||||||
<Integration
|
|
||||||
config={{ name: "Empty", type: "ical" }}
|
|
||||||
params={{ start: "2099-01-01", end: "2099-01-02" }}
|
|
||||||
setEvents={vi.fn()}
|
|
||||||
hideErrors={false}
|
|
||||||
timezone="utc"
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(screen.getByText(/'Empty': calendar\.noEventsFound/)).toBeInTheDocument();
|
|
||||||
expect(data).toEqual(originalData);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("adds parsed events within the date range", async () => {
|
it("adds parsed events within the date range", async () => {
|
||||||
useWidgetAPI.mockReturnValue({
|
useWidgetAPI.mockReturnValue({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -4,19 +4,14 @@ import { useTranslation } from "next-i18next/pages";
|
|||||||
|
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
const ALERTS_LIMIT = 500;
|
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data: alerts, error: alertsError } = useWidgetAPI(widget, "alerts");
|
const { data: alerts, error: alertsError } = useWidgetAPI(widget, !!widget.limit24h ? "alerts24h" : "alerts");
|
||||||
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
|
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
|
||||||
|
|
||||||
const alertsCount = alerts?.length ?? 0;
|
|
||||||
const alertsValue = t("common.number", { value: alertsCount });
|
|
||||||
|
|
||||||
if (alertsError || bansError) {
|
if (alertsError || bansError) {
|
||||||
return <Container service={service} error={alertsError ?? bansError} />;
|
return <Container service={service} error={alertsError ?? bansError} />;
|
||||||
}
|
}
|
||||||
@@ -32,7 +27,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="crowdsec.alerts" value={alertsCount >= ALERTS_LIMIT ? `${alertsValue}+` : alertsValue} />
|
<Block label="crowdsec.alerts" value={t("common.number", { value: alerts?.length ?? 0 })} />
|
||||||
<Block label="crowdsec.bans" value={t("common.number", { value: bans?.length ?? 0 })} />
|
<Block label="crowdsec.bans" value={t("common.number", { value: bans?.length ?? 0 })} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,25 +17,15 @@ describe("widgets/crowdsec/component", () => {
|
|||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("requests the alerts and bans endpoints", () => {
|
it("selects alerts24h endpoint when limit24h is enabled", () => {
|
||||||
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
|
|
||||||
|
|
||||||
renderWithProviders(<Component service={{ widget: { type: "crowdsec" } }} />, {
|
|
||||||
settings: { hideErrors: false },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(useWidgetAPI).toHaveBeenNthCalledWith(1, expect.any(Object), "alerts");
|
|
||||||
expect(useWidgetAPI).toHaveBeenNthCalledWith(2, expect.any(Object), "bans");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("ignores the deprecated limit24h option", () => {
|
|
||||||
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
|
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
|
||||||
|
|
||||||
renderWithProviders(<Component service={{ widget: { type: "crowdsec", limit24h: true } }} />, {
|
renderWithProviders(<Component service={{ widget: { type: "crowdsec", limit24h: true } }} />, {
|
||||||
settings: { hideErrors: false },
|
settings: { hideErrors: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(useWidgetAPI).toHaveBeenNthCalledWith(1, expect.any(Object), "alerts");
|
expect(useWidgetAPI).toHaveBeenNthCalledWith(1, expect.any(Object), "alerts24h");
|
||||||
|
expect(useWidgetAPI).toHaveBeenNthCalledWith(2, expect.any(Object), "bans");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders placeholders when both alerts and bans are missing", () => {
|
it("renders placeholders when both alerts and bans are missing", () => {
|
||||||
@@ -62,28 +52,4 @@ describe("widgets/crowdsec/component", () => {
|
|||||||
expectBlockValue(container, "crowdsec.alerts", 0);
|
expectBlockValue(container, "crowdsec.alerts", 0);
|
||||||
expectBlockValue(container, "crowdsec.bans", 0);
|
expectBlockValue(container, "crowdsec.bans", 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("marks the alert count as truncated at the API limit", () => {
|
|
||||||
useWidgetAPI
|
|
||||||
.mockReturnValueOnce({ data: new Array(500).fill({}), error: undefined })
|
|
||||||
.mockReturnValueOnce({ data: [], error: undefined });
|
|
||||||
|
|
||||||
renderWithProviders(<Component service={{ widget: { type: "crowdsec" } }} />, {
|
|
||||||
settings: { hideErrors: false },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(screen.getByText("500+")).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not mark the alert count below the API limit", () => {
|
|
||||||
useWidgetAPI
|
|
||||||
.mockReturnValueOnce({ data: new Array(499).fill({}), error: undefined })
|
|
||||||
.mockReturnValueOnce({ data: [], error: undefined });
|
|
||||||
|
|
||||||
const { container } = renderWithProviders(<Component service={{ widget: { type: "crowdsec" } }} />, {
|
|
||||||
settings: { hideErrors: false },
|
|
||||||
});
|
|
||||||
|
|
||||||
expectBlockValue(container, "crowdsec.alerts", 499);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,10 +7,13 @@ const widget = {
|
|||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
alerts: {
|
alerts: {
|
||||||
endpoint: "alerts?limit=500&since=24h&with_decisions=false&include_capi=false",
|
endpoint: "alerts",
|
||||||
|
},
|
||||||
|
alerts24h: {
|
||||||
|
endpoint: "alerts?limit=0&since=24h",
|
||||||
},
|
},
|
||||||
bans: {
|
bans: {
|
||||||
endpoint: "alerts?decision_type=ban&include_capi=false&has_active_decision=1&with_decisions=false",
|
endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user