Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b23b0c1c53 | ||
|
|
c05950c0e3 | ||
|
|
6df410c37b | ||
|
|
a25a421028 | ||
|
|
8bc583bd19 | ||
|
|
65f6ac91ac | ||
|
|
548bb66d0e | ||
|
|
775f8ef789 | ||
|
|
e593274b19 | ||
|
|
9a98f633ab | ||
|
|
441d76ef96 | ||
|
|
9ff162460d | ||
|
|
4934d18f2a | ||
|
|
1c9ccadf4e | ||
|
|
0caa196908 | ||
|
|
d14de1d44d | ||
|
|
6993ad3557 |
No files matched your search
@@ -167,6 +167,44 @@ class DependencyUpdates(unittest.TestCase):
|
||||
self.assertEqual(composer["require-dev"]["c/c"], "^3.0||^4.0")
|
||||
|
||||
|
||||
class NpmUpdates(unittest.TestCase):
|
||||
NOW = __import__("datetime").datetime(2026, 12, 8, 12, 0, tzinfo=__import__("datetime").timezone.utc)
|
||||
|
||||
def published(self, ages):
|
||||
import datetime
|
||||
|
||||
return lambda name, version: None if (name, version) not in ages else self.NOW - datetime.timedelta(hours=ages[(name, version)])
|
||||
|
||||
def test_a_release_must_be_public_for_two_days(self):
|
||||
outdated = {"vue": {"current": "3.5.0", "wanted": "3.5.9", "latest": "4.0.0"}}
|
||||
# The newest is a day old: the newest one inside the range is taken instead.
|
||||
targets = update_dependencies.npm_targets(outdated, self.published({("vue", "4.0.0"): 24, ("vue", "3.5.9"): 200}), self.NOW)
|
||||
self.assertEqual(targets, {"vue": ("3.5.0", "3.5.9")})
|
||||
# Both too new: nothing this week.
|
||||
self.assertEqual(update_dependencies.npm_targets(outdated, self.published({("vue", "4.0.0"): 24, ("vue", "3.5.9"): 47}), self.NOW), {})
|
||||
|
||||
def test_the_newest_is_taken_when_it_is_old_enough(self):
|
||||
outdated = {"vite": {"current": "7.0.0", "wanted": "7.1.0", "latest": "8.0.0"}}
|
||||
targets = update_dependencies.npm_targets(outdated, self.published({("vite", "8.0.0"): 49}), self.NOW)
|
||||
self.assertEqual(targets["vite"], ("7.0.0", "8.0.0"))
|
||||
|
||||
def test_a_held_back_package_stays_on_its_major(self):
|
||||
outdated = {"typescript": {"current": "5.9.3", "wanted": "5.9.3", "latest": "7.0.2"}}
|
||||
self.assertEqual(update_dependencies.npm_targets(outdated, self.published({("typescript", "7.0.2"): 999}), self.NOW), {})
|
||||
outdated["typescript"]["wanted"] = "5.9.9"
|
||||
targets = update_dependencies.npm_targets(outdated, self.published({("typescript", "7.0.2"): 999, ("typescript", "5.9.9"): 999}), self.NOW)
|
||||
self.assertEqual(targets, {"typescript": ("5.9.3", "5.9.9")})
|
||||
|
||||
def test_unknown_dates_prereleases_and_missing_installs_are_left_alone(self):
|
||||
outdated = {
|
||||
"a": {"current": "1.0.0", "wanted": "1.0.0", "latest": "2.0.0"},
|
||||
"b": {"current": "1.0.0", "wanted": "1.0.0", "latest": "2.0.0-beta.1"},
|
||||
"c": {"wanted": "1.0.0", "latest": "2.0.0"},
|
||||
}
|
||||
ages = {("b", "2.0.0-beta.1"): 999, ("c", "2.0.0"): 999}
|
||||
self.assertEqual(update_dependencies.npm_targets(outdated, self.published(ages), self.NOW), {})
|
||||
|
||||
|
||||
class PackagistNotice(unittest.TestCase):
|
||||
def run_notice(self, answers):
|
||||
"""Runs notify() with fake answers per endpoint (a status number, or an HTTP error code as a string)."""
|
||||
|
||||
@@ -11,8 +11,13 @@ it is not, so a red pull request is the signal that the package does not work wi
|
||||
Nothing happens when no release is open (start one first), when a pull request of this script is
|
||||
still open, or when nothing is outside its constraint.
|
||||
|
||||
The screens have their own dependencies (`ui/package.json`, with a lock file). `update_dependencies.py ui` moves
|
||||
every npm package that has a newer release (a new major too) to it, but only to a release that has been public for
|
||||
48 hours (a supply-chain guard: a hijacked release is usually pulled within days), rebuilds `resources/dist`, and opens
|
||||
a pull request the same way. PR CI type-checks and builds it, so a red pull request is the signal.
|
||||
|
||||
Environment: GT_URL, GT_OWNER, GT_REPO, GT_TOKEN (the deploy bot: pushes a branch, opens a pull
|
||||
request). Needs git and composer. Standard library only.
|
||||
request). Needs git and composer (npm and node for `ui`). Standard library only.
|
||||
"""
|
||||
|
||||
import datetime
|
||||
@@ -35,6 +40,10 @@ REPO = os.environ.get("GT_REPO", "")
|
||||
TOKEN = os.environ.get("GT_TOKEN", "")
|
||||
USER = "deploy-bot"
|
||||
BRANCH_PREFIX = "renovate/deps-"
|
||||
UI_BRANCH_PREFIX = "renovate/ui-deps-"
|
||||
MIN_AGE = datetime.timedelta(hours=48)
|
||||
# npm packages held at a major until what depends on them works with the next one (remove the line then).
|
||||
HELD = {"typescript": 5} # vue-tsc (the type check of the screens) does not run on TypeScript 7 yet
|
||||
SECTIONS = ("require", "require-dev")
|
||||
|
||||
|
||||
@@ -102,6 +111,140 @@ def widened(composer, outdated):
|
||||
return changes
|
||||
|
||||
|
||||
def npm_targets(outdated, published, now):
|
||||
"""What each outdated npm package moves to: its newest release (or the newest inside its range) that is old enough.
|
||||
|
||||
`outdated` is `npm outdated --json` (name -> current, wanted, latest); `published(name, version)` is the time that
|
||||
release came out (a datetime, or None when unknown, which counts as too new).
|
||||
"""
|
||||
targets = {}
|
||||
|
||||
for name, info in sorted(outdated.items()):
|
||||
if not isinstance(info, dict) or not info.get("current"):
|
||||
continue
|
||||
|
||||
for candidate in (info.get("latest"), info.get("wanted")):
|
||||
if not candidate or candidate == info["current"] or "-" in candidate:
|
||||
continue
|
||||
|
||||
if name in HELD and int(candidate.split(".")[0]) > HELD[name]:
|
||||
continue
|
||||
|
||||
when = published(name, candidate)
|
||||
|
||||
if when is not None and now - when >= MIN_AGE:
|
||||
targets[name] = (info["current"], candidate)
|
||||
break
|
||||
|
||||
return targets
|
||||
|
||||
|
||||
def main_ui():
|
||||
"""The same cycle for ui/: bump what is outdated and old enough, rebuild the bundle, open a pull request."""
|
||||
work, release, remote = prepare(UI_BRANCH_PREFIX)
|
||||
ui = os.path.join(work, "ui")
|
||||
|
||||
install = run(["npm", "ci", "--no-audit", "--no-fund", "--ignore-scripts"], ui, retries=3)
|
||||
|
||||
if install.returncode != 0:
|
||||
sys.exit(f"npm ci failed:\n{install.stderr[-2000:]}")
|
||||
|
||||
listed = run(["npm", "outdated", "--json"], ui) # exit code 1 means "something is outdated"
|
||||
outdated = json.loads(listed.stdout or "{}")
|
||||
times = {}
|
||||
|
||||
def published(name, version):
|
||||
if name not in times:
|
||||
view = run(["npm", "view", name, "time", "--json"], ui, retries=2)
|
||||
try:
|
||||
times[name] = json.loads(view.stdout or "{}")
|
||||
except ValueError:
|
||||
times[name] = {}
|
||||
|
||||
stamp = times[name].get(version) if isinstance(times[name], dict) else None
|
||||
|
||||
try:
|
||||
return datetime.datetime.fromisoformat(stamp.replace("Z", "+00:00")) if stamp else None
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
targets = npm_targets(outdated, published, datetime.datetime.now(datetime.timezone.utc))
|
||||
|
||||
if not targets:
|
||||
print("Every npm package is up to date, or too new to adopt yet: nothing to do.")
|
||||
return
|
||||
|
||||
applied = {}
|
||||
|
||||
for name, (old, new) in targets.items():
|
||||
result = run(["npm", "install", f"{name}@{new}", "--save-prefix=^", "--no-audit", "--no-fund", "--ignore-scripts"], ui)
|
||||
|
||||
if result.returncode == 0:
|
||||
applied[name] = (old, new)
|
||||
else:
|
||||
run(["git", "checkout", "--", "ui/package.json", "ui/package-lock.json"], work)
|
||||
print(f"{name} {new} does not install: left as it was.")
|
||||
|
||||
if not applied:
|
||||
print("Nothing could be installed.")
|
||||
return
|
||||
|
||||
# A new bundle with the new dependencies; when it does not build the pull request still opens, red, with the old bundle.
|
||||
if run(["npm", "run", "build"], ui).returncode != 0:
|
||||
print("The build failed with the new packages: the pull request will be red.")
|
||||
|
||||
publish(work, release, remote, UI_BRANCH_PREFIX, applied, "Update the dependencies of the screens", ["ui/package.json", "ui/package-lock.json", "resources/dist"])
|
||||
|
||||
|
||||
def prepare(prefix):
|
||||
"""Finds the open release, makes sure no pull request of this kind is open, and clones the release branch."""
|
||||
if not (URL and OWNER and REPO and TOKEN):
|
||||
sys.exit("GT_URL, GT_OWNER, GT_REPO and GT_TOKEN are required.")
|
||||
|
||||
branches = [item["name"] for item in api("GET", "branches?limit=50") or []]
|
||||
tags = [item["name"] for item in api("GET", "tags?limit=50") or []]
|
||||
release = open_release(branches, tags)
|
||||
|
||||
if release is None:
|
||||
print("No release is open: nothing to update. Start a release first.")
|
||||
sys.exit(0)
|
||||
|
||||
for pull in api("GET", "pulls?state=open&limit=50") or []:
|
||||
if pull["head"]["ref"].startswith(prefix):
|
||||
print(f"Pull request #{pull['number']} of this workflow is still open: not making another.")
|
||||
sys.exit(0)
|
||||
|
||||
remote = f"https://{USER}:{TOKEN}@{URL.split('://', 1)[1]}/{OWNER}/{REPO}.git"
|
||||
work = os.path.join(tempfile.mkdtemp(), "repo")
|
||||
clone = subprocess.run(["git", "clone", "--quiet", "--branch", release, remote, work], capture_output=True, text=True)
|
||||
|
||||
if clone.returncode != 0:
|
||||
sys.exit("git clone failed.")
|
||||
|
||||
return work, release, remote
|
||||
|
||||
|
||||
def publish(work, release, remote, prefix, changes, title, paths):
|
||||
"""Commits `paths`, pushes a branch and opens the pull request to the release."""
|
||||
branch = prefix + datetime.date.today().strftime("%Y%m%d")
|
||||
|
||||
for command in (
|
||||
["git", "config", "user.name", USER],
|
||||
["git", "config", "user.email", f"{USER}@iriks-it.nl"],
|
||||
["git", "checkout", "-b", branch],
|
||||
["git", "add", "--", *paths],
|
||||
["git", "commit", "-m", f"{title}: " + ", ".join(sorted(changes))],
|
||||
["git", "push", "--quiet", "origin", branch],
|
||||
):
|
||||
result = subprocess.run(command, cwd=work, capture_output=True, text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
sys.exit(f"{' '.join(command[:2])} failed: {result.stderr.strip()}")
|
||||
|
||||
pull = api("POST", "pulls", {"title": f"{title}: " + ", ".join(sorted(changes)), "head": branch, "base": release, "body": body(changes, release)})
|
||||
print(f"Pull request #{pull['number']} to {release}: {', '.join(sorted(changes))}.")
|
||||
|
||||
|
||||
def run(command, cwd, retries=1):
|
||||
for attempt in range(1, retries + 1):
|
||||
result = subprocess.run(command, cwd=cwd, capture_output=True, text=True)
|
||||
@@ -114,36 +257,15 @@ def run(command, cwd, retries=1):
|
||||
|
||||
def body(changes, release):
|
||||
lines = "\n".join(f"- `{name}`: `{old}` → `{new}`" for name, (old, new) in sorted(changes.items()))
|
||||
return f"""Automatic update of the version constraints, by the weekly workflow `Dependency updates`.
|
||||
return f"""Automatic update of the dependencies, by the weekly workflow `Dependency updates`.
|
||||
|
||||
{lines}
|
||||
|
||||
PR CI tests the package with the newer versions. It merges into `{release}` by itself when everything is green; when it is red, the package does not work with them yet."""
|
||||
PR CI tests the package with the newer versions (and rebuilds the screens when it is about npm). It merges into `{release}` by itself when everything is green; when it is red, the package does not work with them yet."""
|
||||
|
||||
|
||||
def main():
|
||||
if not (URL and OWNER and REPO and TOKEN):
|
||||
sys.exit("GT_URL, GT_OWNER, GT_REPO and GT_TOKEN are required.")
|
||||
|
||||
branches = [item["name"] for item in api("GET", "branches?limit=50") or []]
|
||||
tags = [item["name"] for item in api("GET", "tags?limit=50") or []]
|
||||
release = open_release(branches, tags)
|
||||
|
||||
if release is None:
|
||||
print("No release is open: nothing to update. Start a release first.")
|
||||
return
|
||||
|
||||
for pull in api("GET", "pulls?state=open&limit=50") or []:
|
||||
if pull["head"]["ref"].startswith(BRANCH_PREFIX):
|
||||
print(f"Pull request #{pull['number']} of this workflow is still open: not making another.")
|
||||
return
|
||||
|
||||
remote = f"https://{USER}:{TOKEN}@{URL.split('://', 1)[1]}/{OWNER}/{REPO}.git"
|
||||
work = os.path.join(tempfile.mkdtemp(), "repo")
|
||||
clone = subprocess.run(["git", "clone", "--quiet", "--branch", release, remote, work], capture_output=True, text=True)
|
||||
|
||||
if clone.returncode != 0:
|
||||
sys.exit("git clone failed.")
|
||||
work, release, remote = prepare(BRANCH_PREFIX)
|
||||
|
||||
update = run(["composer", "update", "--prefer-stable", "--prefer-dist", "--no-scripts", "--no-interaction"], work, retries=3)
|
||||
|
||||
@@ -165,23 +287,8 @@ def main():
|
||||
json.dump(composer, file, indent=4, ensure_ascii=False)
|
||||
file.write("\n")
|
||||
|
||||
branch = BRANCH_PREFIX + datetime.date.today().strftime("%Y%m%d")
|
||||
|
||||
for command in (
|
||||
["git", "config", "user.name", USER],
|
||||
["git", "config", "user.email", f"{USER}@iriks-it.nl"],
|
||||
["git", "checkout", "-b", branch],
|
||||
["git", "commit", "-am", "Widen dependency constraints: " + ", ".join(sorted(changes))],
|
||||
["git", "push", "--quiet", "origin", branch],
|
||||
):
|
||||
result = subprocess.run(command, cwd=work, capture_output=True, text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
sys.exit(f"{' '.join(command[:2])} failed: {result.stderr.strip()}")
|
||||
|
||||
pull = api("POST", "pulls", {"title": "Dependency updates: " + ", ".join(sorted(changes)), "head": branch, "base": release, "body": body(changes, release)})
|
||||
print(f"Pull request #{pull['number']} to {release}: {', '.join(sorted(changes))}.")
|
||||
publish(work, release, remote, BRANCH_PREFIX, changes, "Dependency updates", ["composer.json"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main_ui() if sys.argv[1:] == ["ui"] else main()
|
||||
@@ -3,7 +3,9 @@ name: Dependency updates
|
||||
# A package has no composer.lock, so what goes stale is the range of versions it accepts. Every
|
||||
# Monday this looks for a direct dependency with a release outside its constraint (a new major) and
|
||||
# opens a pull request to the open release branch that accepts it as well; PR CI then tests it and the
|
||||
# pull request merges by itself when it is green. Nothing happens while no release is open.
|
||||
# pull request merges by itself when it is green. The second job does the same for the npm packages of the
|
||||
# screens (ui/), to a release that has been public for 48 hours, and rebuilds resources/dist. Nothing happens
|
||||
# while no release is open.
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 5 * * 1'
|
||||
@@ -34,3 +36,21 @@ jobs:
|
||||
GT_OWNER: iriks-it
|
||||
GT_REPO: laravel-manager
|
||||
GT_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
|
||||
# The screens: npm packages that have a newer release (a new major too), once it has been public for 48 hours.
|
||||
# The node image has git and python3; PR CI type-checks and builds the result.
|
||||
ui:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: update the packages of the screens
|
||||
run: python3 .gitea/scripts/update_dependencies.py ui
|
||||
env:
|
||||
GT_URL: https://git.iriks.casa
|
||||
GT_OWNER: iriks-it
|
||||
GT_REPO: laravel-manager
|
||||
GT_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
@@ -19,6 +19,6 @@ between lil-koneko.com, CarsHub, iriks-it.nl and bouwbedrijf.iriks-it.nl, as one
|
||||
|
||||
## Open decisions
|
||||
|
||||
1. Frontend: decided to ship the Inertia/Vue screens inside the package (prebuilt bundle, host needs no Node) with per-user and site themes; being built after v0.4.0's AI tooling slice.
|
||||
2. Moving the rest from bouwbedrijf.iriks-it.nl, module by module: pages, reviews, then revisions, audit log, login and profile. Users, media and posts (with labels) are done. Leave out what is site-specific (the IriksIT API disk, the owner's simple screens, client names): this repo is public.
|
||||
1. Frontend: decided and built: the screens are in the package (`ui/`, built into `resources/dist`, committed; PR CI checks it is up to date). Still open: a theme editor in the manager, and a `host` mode that publishes the sources for a site to build itself.
|
||||
2. Moving the rest from bouwbedrijf.iriks-it.nl: real pages and reviews (now skeletons) and revisions. Users, media, posts, audit log and statistics are done, with their screens. Leave out what is site-specific (the IriksIT API disk, the owner's simple screens, client names): this repo is public.
|
||||
3. How the host's own `User` and a package `Group` relate when the host has its own roles.
|
||||
@@ -4,6 +4,19 @@ Every release has a section here, named after its version (for example `v0.1.0 -
|
||||
heading). The release pull request to `production` is stopped by PR CI when its section is missing, and the text of
|
||||
the section is the text of the release in Gitea.
|
||||
|
||||
## v0.4.0 - 2026-12-04
|
||||
|
||||
- Screens in the package: a small Vue app on the JSON routes, built and served by the package (a site needs no Node). Login, logout and
|
||||
profile for an app that has none, a dashboard and menu, and screens for accounts, groups, media (with a picker for covers), posts,
|
||||
categories and tags, the audit log with bans, and statistics. Pages and reviews show a read-only list. `MANAGER_UI=none` keeps only the
|
||||
JSON routes. The default middleware is now `['web', 'manager.auth']` (a published config that still says `auth` keeps working).
|
||||
- Themes: `dark` and `light`, your own as a JSON file (`php artisan manager:make-theme`) or in the config, chosen per account in the
|
||||
profile (new table `manager_user_settings`; `MANAGER_THEME`, `MANAGER_USER_THEMES`). Every value is checked before it reaches a page.
|
||||
- For AI agents: `php artisan manager:install` (no questions), `php artisan manager:doctor --json` (checks the setup, says how to fix
|
||||
it, non-zero exit on failure), a step-by-step guide (`resources/ai/INTEGRATION.md`) and a Laravel Boost guideline. Modules report
|
||||
their tables with `tables()`.
|
||||
- PR CI: a job that type-checks and builds the screens and fails when the committed `resources/dist` is out of date.
|
||||
|
||||
## v0.3.0 - 2026-12-04
|
||||
|
||||
- The Packagist step submits the package itself when Packagist does not know it yet (the update call answered 404), instead
|
||||
|
||||
@@ -32,7 +32,7 @@ on the JSON routes. A browser that opens a manager address gets the page; anythi
|
||||
- **The house style of the site.** `php artisan manager:make-theme acme --brand=#e4002b --name="Acme" --logo=/img/logo.svg --font="Inter, sans-serif"`
|
||||
writes `resources/manager-themes/acme.json`; set `MANAGER_THEME=acme`. A theme is colours, a radius, fonts, a name and a logo, and every
|
||||
value is checked, so a theme file can never put CSS or markup in the page. Themes can also be listed in `manager.themes`.
|
||||
- **Not built yet:** screens for the other modules (they show a notice for now) and a theme editor in the manager.
|
||||
- **Not built yet:** a theme editor in the manager (themes are files for now), and screens for modules your own site adds (they show a notice).
|
||||
- **Working on the screens:** the sources are in `ui/`; `npm ci && npm run build` there writes `resources/dist`, which is committed
|
||||
(PR CI fails when it is out of date).
|
||||
|
||||
@@ -152,13 +152,12 @@ scheduled daily), so a code cannot be traced back afterwards. A browser that sen
|
||||
|
||||
## State of this version
|
||||
|
||||
Done: module registry and switches, permissions per module, users (accounts, groups, command), media
|
||||
(library and public file route) posts (with categories and tags) and the audit log with bans and the statistics, 99 tests (`composer test`).
|
||||
Done: module registry and switches, permissions per module, users (accounts, groups, command), media (library and public file
|
||||
route), posts (with categories and tags), the audit log with bans, the statistics, the built-in screens for all of these (with a
|
||||
login and profile), themes, and the install and doctor commands for AI agents. `composer test` runs the tests.
|
||||
|
||||
The answers of every action are JSON, in the shape the screens of bouwbedrijf.iriks-it.nl got as
|
||||
Inertia props. The screens themselves are not in the package yet: the frontend is an open decision
|
||||
(`AGENTS.md`). Pages and reviews are still skeletons (a list), and login, profile and revisions are not
|
||||
ported yet.
|
||||
Pages and reviews are still skeletons (a read-only list), and revisions are not ported yet. The answers of every action are JSON
|
||||
in the shape the screens use, so an app can build its own screens with `MANAGER_UI=none`.
|
||||
|
||||
## Development cycle
|
||||
|
||||
@@ -184,7 +183,7 @@ Nobody opens a pull request to `develop`, and `production` and the release branc
|
||||
| Pull request to a release branch or to production | *flow* (right branches, version above the latest tag, changelog section, tests of these scripts), *ledger* (`TOKENS.md`), *test* (Pint, Pest with the newest and the oldest dependencies, `composer validate`), *security* (`composer audit`, Trivy on the dependencies, secrets and settings). The check `PR CI / pr-ci` is green when all are. |
|
||||
| Push to production | verify (Pest, audit), tag and release, Packagist, sync develop |
|
||||
| Every Monday | `composer audit` and Trivy on production |
|
||||
| Every Monday | *Dependency updates*: a direct dependency with a release outside its constraint (a new major) gets its constraint widened in a pull request `renovate/deps-DATE` to the open release branch; PR CI tests it and it merges when green. Nothing happens while no release is open. The central Trivy (every night 03:00 UTC) and Renovate (04:00 UTC) of the homelab also pass over this repo, but read a `composer.lock` and a package has none, so they find little here. |
|
||||
| Every Monday | *Dependency updates*: a direct dependency with a release outside its constraint (a new major) gets its constraint widened in a pull request `renovate/deps-DATE` to the open release branch; the npm packages of the screens (`ui/`) move to their newest release that has been public for 48 hours, with a rebuilt `resources/dist`, in `renovate/ui-deps-DATE`. PR CI tests them and they merge when green. Nothing happens while no release is open. The central Trivy (every night 03:00 UTC) and Renovate (04:00 UTC) of the homelab also pass over this repo, but read a `composer.lock` and a package has none, so they find little here. |
|
||||
| Every night | *Prune branches*: removes `feature/*` and `fix/*` branches whose last commit is over 30 days old and that have no open pull request (a branch of a pull request can be restored from it in Gitea) |
|
||||
|
||||
Secrets of the repository for this: `DEPLOY_TOKEN` (the organisation has it), and `PACKAGIST_USERNAME` and
|
||||
|
||||
@@ -25,3 +25,10 @@ Per stuk werk een rij; zie `dev/token-usage.py`.
|
||||
| 2026-12-04 | Installatie en gezondheidscheck voor AI (manager:install en manager:doctor) met een stappengids voor agents | - | claude-sonnet-5-5 | 12 | 12.112 | 28 | 64.789 | 2.344.181 | 0,04 |
|
||||
| 2026-12-04 | Installatie en gezondheidscheck voor AI (manager:install en manager:doctor) met een stappengids voor agents | - | claude-fable-5-2 | 1 | 17.440 | 362.597 | 0 | 0 | 0,00 |
|
||||
| 2026-12-04 | Schermen in het pakket: eigen login, profiel, menu en berichten, thema's per gebruiker en voor de huisstijl van de site | - | claude-sonnet-5-5 | 51 | 60.198 | 102 | 94.747 | 7.947.787 | 0,19 |
|
||||
| 2026-12-04 | Schermen voor gebruikers, groepen, categorieën en tags, pagina's en reviews | - | claude-sonnet-5-5 | 11 | 13.236 | 24 | 21.715 | 2.310.933 | 0,06 |
|
||||
| 2026-12-04 | Schermen voor media (met kiezer voor de omslag), de auditlog met blokkades en de statistieken | - | claude-sonnet-5-5 | 23 | 23.335 | 46 | 42.961 | 5.678.787 | 0,06 |
|
||||
| 2026-12-04 | De stappengids en de installatie verbeterd na de proef met een verse agent | - | claude-sonnet-5-5 | 25 | 21.844 | 50 | 35.997 | 6.551.164 | 0,10 |
|
||||
| 2026-12-04 | De stappengids en de installatie verbeterd na de proef met een verse agent | - | claude-haiku-5-5 | 11 | 8.233 | 22 | 51.184 | 444.805 | 0,00 |
|
||||
| 2026-12-04 | Changelog van v0.4.0, wiki en notitie in longterm-memory | - | claude-sonnet-5-5 | 7 | 3.891 | 14 | 5.215 | 1.999.583 | 0,01 |
|
||||
| 2026-12-04 | De wekelijkse workflow werkt ook de npm-pakketten van de schermen bij, met 48 uur wachttijd en een nieuwe bundel | - | claude-sonnet-5-5 | 9 | 9.971 | 22 | 15.191 | 3.032.384 | 0,05 |
|
||||
| 2026-12-04 | TypeScript 7 niet voorstellen zolang vue-tsc het niet draait, en de PR van de eerste run rechtgezet | - | claude-sonnet-5-5 | 10 | 4.340 | 26 | 4.489 | 3.503.406 | 0,05 |
|
||||
@@ -1,22 +1,31 @@
|
||||
# Integrating iriks-it/laravel-manager (guide for AI agents)
|
||||
|
||||
Goal: the manager runs in this Laravel app and `php artisan manager:doctor` is green. Do the steps in order and
|
||||
never edit files inside `vendor/`.
|
||||
Goal: the manager runs in this Laravel app and `php artisan manager:doctor --json` says `"ok": true`. Do the steps in
|
||||
order and never edit files inside `vendor/`.
|
||||
|
||||
1. `composer require iriks-it/laravel-manager`
|
||||
2. Pick the modules. `users` and `media` are on; `pages`, `posts` default on; `reviews`, `audit`, `statistics` default off
|
||||
(A version that is not on Packagist yet: first `composer config repositories.manager --json '{"type":"path","url":"/path/to/laravel-manager","options":{"symlink":false}}'`, then require `@dev`.)
|
||||
2. Pick the modules. `users` and `media` are on; `pages` and `posts` are on by default; `reviews`, `audit` and `statistics` are off
|
||||
(audit and statistics store visitor data: only switch them on when the owner says so).
|
||||
3. `php artisan manager:install --modules=users,media,posts --user-model="App\Models\User"`
|
||||
(writes `MANAGER_*` to `.env`, publishes `config/manager.php`, runs the doctor). Add `--path=admin` to move the URL.
|
||||
It writes the `MANAGER_*` switches to `.env` and publishes `config/manager.php`. Add `--path=admin` to move the URL.
|
||||
It does not run the check itself (this process still has the old config): that is step 7.
|
||||
4. Add the trait to the user model: `use \IriksIT\Manager\Concerns\HasManagerAccess;`. Never put `is_super_admin` in `$fillable`.
|
||||
5. `php artisan migrate` (a new process, so it sees the switches you wrote in step 3).
|
||||
5. `php artisan config:clear && php artisan migrate && php artisan storage:link` (a new process, so it sees the switches of step 3).
|
||||
6. Create the first super admin: `php artisan manager:create-user --name="..." --email="..." --password="<12+ chars>"`.
|
||||
7. Run `php artisan manager:doctor --json`. Every check must be `ok` or an understood `warn`; each `fail`/`warn` has a `fix`.
|
||||
7. `php artisan manager:doctor --json`. Every check must be `ok` or an understood `warn`; each `fail` and `warn` has a `fix`.
|
||||
Repeat until `"ok": true`.
|
||||
|
||||
Facts that matter:
|
||||
- The manager lives at `/manager` (`MANAGER_PATH`) behind `web` + `auth` (`manager.middleware`); the app needs a route named `login`.
|
||||
- The screens are part of the package (`MANAGER_UI=package`, the default): open `/manager` in a browser. The app does not need a
|
||||
login of its own: when it has no route named `login`, the manager's own login at `/manager/login` is used. With
|
||||
`MANAGER_UI=none` there are only the JSON routes.
|
||||
- A browser address gets the screens, a request with `Accept: application/json` gets the data. To call the JSON routes from a
|
||||
script: `GET /manager/login` once for the `XSRF-TOKEN` cookie, then `POST /manager/login` with header `X-XSRF-TOKEN` (the cookie
|
||||
value, URL-decoded), `Accept: application/json` and body `{"email": "...", "password": "..."}`; the answer is `{"redirect": "/manager"}`.
|
||||
- The look: `MANAGER_THEME=dark|light` or your own (`php artisan manager:make-theme acme --brand=#e4002b --name="Acme" --logo=/img/logo.svg`,
|
||||
then `MANAGER_THEME=acme`). Each account can pick its own in its profile (`MANAGER_USER_THEMES=false` stops that).
|
||||
- Anything that is off has no routes, tables or permissions. A module that needs another one fails at boot when that one is off.
|
||||
- Answers are JSON. Do not add site-specific code to the package: a site's own part is its own module class (`Contracts\Module`,
|
||||
extend `Modules\BaseModule`, add it to `manager.available`).
|
||||
- Do not add site-specific code to the package: a site's own part is its own module class (`Contracts\Module`, extend
|
||||
`Modules\BaseModule`, add it to `manager.available`).
|
||||
- Behind a proxy set trusted proxies before switching `audit` on.
|
||||
@@ -3,6 +3,7 @@
|
||||
A modular backend (users, media, pages, posts, reviews, audit, statistics) installed as a package.
|
||||
|
||||
- To integrate it, follow `vendor/iriks-it/laravel-manager/resources/ai/INTEGRATION.md` step by step.
|
||||
- Set it up with `php artisan manager:install --modules=... --user-model=...`; verify with `php artisan manager:doctor --json` (non-zero exit on failure, every problem has a `fix`).
|
||||
- Set it up with `php artisan manager:install --modules=... --user-model=...`, then `config:clear`, `migrate`, `storage:link`; verify in a new process with `php artisan manager:doctor --json` (non-zero exit on failure, every problem has a `fix`).
|
||||
- The screens come with the package (`MANAGER_UI`), including a login when the app has none; themes: `php artisan manager:make-theme`, `MANAGER_THEME`.
|
||||
- The user model needs the `HasManagerAccess` trait; `is_super_admin` is never mass assignable. The first super admin comes from `php artisan manager:create-user`.
|
||||
- Switch parts with `MANAGER_<MODULE>=true|false`; never edit `vendor/`. Site-specific parts are your own `Module` class.
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:var(--m-font,ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-500:oklch(63.7% .237 25.331);--color-emerald-500:oklch(69.6% .17 162.48);--color-black:#000;--spacing:.25rem;--container-sm:24rem;--container-xl:36rem;--container-3xl:48rem;--container-5xl:64rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--m-font,ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-Line truncated
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:var(--m-font,ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-500:oklch(63.7% .237 25.331);--color-emerald-500:oklch(69.6% .17 162.48);--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-5xl:64rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--radius-sm:.25rem;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--m-font,ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padLine truncated
|
||||
Vendored
+2
-2
@@ -1,2 +1,2 @@
|
||||
function pn(e){const t=Object.create(null);for(const s of e.split(","))t[s]=1;return s=>s in t}const G={},xt=[],We=()=>{},Sr=()=>!1,$s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),Os=e=>e.startsWith("onUpdate:"),le=Object.assign,hn=(e,t)=>{const s=e.indexOf(t);s>-1&&e.splice(s,1)},Vi=Object.prototype.hasOwnProperty,U=(e,t)=>Vi.call(e,t),R=Array.isArray,at=e=>It(e)==="[object Map]",Ot=e=>It(e)==="[object Set]",Ln=e=>It(e)==="[object Date]",j=e=>typeof e=="function",te=e=>typeof e=="string",Ne=e=>typeof e=="symbol",q=e=>e!==null&&typeof e=="object",Cr=e=>(q(e)||j(e))&&j(e.then)&&j(e.catch),Tr=Object.prototype.toString,It=e=>Tr.call(e),Ui=e=>It(e).slice(8,-1),Er=e=>It(e)==="[object Object]",gn=e=>te(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Vt=pn(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Hi=1e4,As=e=>{let t=Object.create(null),s=0;return(n=>{const r=t[n];return r!==void 0?r:(++s>Hi&&(t=Object.create(null),s=1),t[n]=e(n))})},Ki=/-\w/g,ye=As(e=>e.replace(Ki,t=>t.slice(1).toUpperCase())),Bi=/\B([A-Z])/g,St=As(e=>e.replace(Bi,"-$1").toLowerCase()),Ps=As(e=>e.charAt(0).toUpperCase()+e.slice(1)),Us=As(e=>e?`on${Ps(e)}`:""),Ke=(e,t)=>!Object.is(e,t),hs=(e,...t)=>{for(let s=0;s<e.length;s++)e[s](...t)},$r=(e,t,s,n=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:n,value:s})},mn=e=>{const t=parseFloat(e);return isNaN(t)?e:t};let Vn;const Ms=()=>Vn||(Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function es(e){if(R(e)){const t={};for(let s=0;s<e.length;s++){const n=e[s],r=te(n)?Gi(n):es(n);if(r)for(const i in r)t[i]=r[i]}return t}else if(te(e)||q(e))return e}const Wi=/;(?![^(]*\))/g,qi=/:([^]+)/,zi=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function Gi(e){const t={};return e.replace(zi,s=>s.startsWith("/*")?"":s).split(Wi).forEach(s=>{if(s){const n=s.split(qi);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function ft(e){let t="";if(te(e))t=e;else if(R(e))for(let s=0;s<e.length;s++){const n=ft(e[s]);n&&(t+=n+" ")}else if(q(e))for(const s in e)e[s]&&(t+=s+" ");return t.trim()}function Ji(e){if(!e)return null;let{class:t,style:s}=e;return t&&!te(t)&&(e.class=ft(t)),s&&(e.style=es(s)),e}const Yi="itemscope,allowfullscreen,disablepictureinpicture,disableremoteplayback,formnovalidate,ismap,nomodule,novalidate,playsinline,readonly",Xi=pn(Yi);function Or(e){return!!e||e===""}function Zi(e,t,s){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=dt(e[r],t[r],s);return n}function Un(e,t,s){if(e.size!==t.size)return!1;const n=Array.from(t),r=new Uint8Array(n.length);for(const i of e){let o=-1;for(let l=0;l<n.length;l++)if(!r[l]&&dt(i,n[l],s)){o=l;break}if(o<0)return!1;r[o]=1}return!0}function Qi(e,t,s){let n=at(e),r=at(t);if(n||r||(n=Ot(e),r=Ot(t),n||r))return n&&r?Un(e,t,s):!1;const i=Object.keys(e).length,o=Object.keys(t).length;if(i!==o)return!1;for(const l in e){const c=U(e,l),d=U(t,l);if(c&&!d||!c&&d||!dt(e[l],t[l],s))return!1}return Kn(e)===Kn(t)}function Hn(e,t,s,n){s||(s=[new Map,new Map]);const[r,i]=s;if(r.has(e)||i.has(t))return r.get(e)===t&&i.get(t)===e;r.set(e,t),i.set(t,e);const o=n(e,t,s);return r.delete(e),i.delete(t),o}function dt(e,t,s){if(e===t)return!0;let n=Ln(e),r=Ln(t);return n||r?n&&r?e.getTime()===t.getTime():!1:(n=Ne(e),r=Ne(t),n||r?e===t:(n=R(e),r=R(t),n||r?n&&r?Hn(e,t,s,Zi):!1:(n=q(e),r=q(t),n||r?!n||!r?!1:Hn(e,t,s,Qi):String(e)===String(t))))}function Ar(e,t){return e.findIndex(s=>dt(s,t))}function Kn(e){return Object.getPrototypeOf(e)===null&&e[Symbol.toPrimitive]==null&&typeof e.toString!="function"&&typeof e.valueOf!="function"?It(e):String(e)}const Pr=e=>!!(e&&e.__v_isRef===!0),E=e=>te(e)?e:e==null?"":R(e)||q(e)&&(e.toString===Tr||!j(e.toString))?Pr(e)?E(e.value):JSON.stringify(e,Mr,2):String(e),Mr=(e,t)=>Pr(t)?Mr(e,t.value):at(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((s,[n,r],i)=>(s[Hs(n,i)+" =>"]=r,s),{})}:Ot(t)?{[`Set(${t.size})`]:[...t.values()].map(s=>Hs(s))}:Ne(t)?Hs(t):q(t)&&!R(t)&&!Er(t)?String(t):t,Hs=(e,t="")=>{var s;return Ne(e)?`Symbol(${(s=e.description)!=null?s:t})`:e};let oe;class Ir{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!t&&oe&&(oe.active?(this.parent=oe,this.index=(oe.scopes||(oe.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,s;if(this.scopes){const n=this.scopes.slice();for(t=0,s=n.length;t<s;t++)n[t].pause()}for(t=0,s=this.effects.length;t<s;t++)this.effects[t].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let t,s;if(this.scopes){const r=this.scopes.slice();for(t=0,s=r.length;t<s;t++)r[t].resume()}const n=this.effects.slice();for(t=0,s=n.length;t<s;t++)n[t].resume()}}run(t){iLine truncated
|
||||
`))),e[Be]=Mt(r);const i=n||r.props&&r.props.type==="number";ct(e,t?"change":"input",o=>{o.target.composing||e[Be](Qs(e.value,s,i))}),(s||i)&&ct(e,"change",()=>{e.value=Qs(e.value,s,i)}),t||(ct(e,"compositionstart",ac),ct(e,"compositionend",_r),ct(e,"change",_r))},mounted(e,{value:t,modifiers:{trim:s,number:n}}){const r=t??"",i=e[ds];delete e[ds],i!==void 0&&(e.type==="text"||e.type==="textarea")&&e.value!==i?e[Be](Qs(e.value,s,n)):e.value=r},beforeUpdate(e,{value:t,oldValue:s,modifiers:{lazy:n,trim:r,number:i}},o){if(e[Be]=Mt(o),e.composing)return;const l=(i||e.type==="number")&&!/^0\d/.test(e.value)?mn(e.value):e.value,c=t??"";if(l===c)return;const d=e.getRootNode();(d instanceof Document||d instanceof ShadowRoot)&&d.activeElement===e&&e.type!=="range"&&(n&&t===s||r&&e.value.trim()===c)||(e.value=c)}},dn={deep:!0,created(e,t,s){e[Be]=Mt(s),ct(e,"change",()=>{const n=e._modelValue,r=ji(e),i=e.checked,o=e[Be];if(R(n)){const l=Ar(n,r),c=l!==-1;if(i&&!c)o(n.concat(r));else if(!i&&c){const d=[...n];d.splice(l,1),o(d)}}else if(Ot(n)){const l=new Set(n);i?l.add(r):l.delete(r),o(l)}else o(Di(e,i))})},mounted:br,beforeUpdate(e,t,s){e[Be]=Mt(s),br(e,t,s)}};function br(e,{value:t,oldValue:s},n){e._modelValue=t;let r;if(R(t))r=Ar(t,n.props.value)>-1;else if(Ot(t))r=t.has(n.props.value);else{if(t===s)return;r=dt(t,Di(e,!0))}e.checked!==r&&(e.checked=r)}const uc={created(e,{value:t},s){e.checked=dt(t,s.props.value),e[Be]=Mt(s),ct(e,"change",()=>{e[Be](ji(e))})},beforeUpdate(e,{value:t,oldValue:s},n){e[Be]=Mt(n),t!==s&&(e.checked=dt(t,n.props.value))}};function ji(e){return"_value"in e?e._value:e.value}function Di(e,t){const s=t?"_trueValue":"_falseValue";return s in e?e[s]:t}const fc=["ctrl","shift","alt","meta"],dc={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>fc.some(s=>e[`${s}Key`]&&!t.includes(s))},An=(e,t)=>{if(!e)return e;const s=e._withMods||(e._withMods={}),n=t.join(".");return s[n]||(s[n]=((r,...i)=>{for(let o=0;o<t.length;o++){const l=dc[t[o]];if(l&&l(r,t))return}return e(r,...i)}))},pc=le({patchProp:oc},Kl);let yr;function hc(){return yr||(yr=wl(pc))}const gc=((...e)=>{const t=hc().createApp(...e),{mount:s}=t;return t.mount=n=>{const r=_c(n);if(!r)return;const i=t._component;!j(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=s(r,!1,mc(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t});function mc(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function _c(e){return te(e)?document.querySelector(e):e}class Ts extends Error{constructor(t,s){super(s?.message??`HTTP ${t}`),this.status=t,this.body=s}status;body;get errors(){return Object.fromEntries(Object.entries(this.body?.errors??{}).map(([t,s])=>[t,s[0]]))}}const k=JSON.parse(document.getElementById("manager-boot").textContent);function bc(){const e=document.cookie.match(/(?:^|; )XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):""}async function ps(e,t,s){const n=await fetch(t,{method:e,credentials:"same-origin",headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest","X-XSRF-TOKEN":bc(),...s===void 0?{}:{"Content-Type":"application/json"}},body:s===void 0?void 0:JSON.stringify(s)}),r=n.status===204?null:await n.json().catch(()=>null);if(!n.ok)throw new Ts(n.status,r);return r}const Qt={get:e=>ps("GET",e),post:(e,t={})=>ps("POST",e,t),put:(e,t={})=>ps("PUT",e,t),delete:e=>ps("DELETE",e)};function Pn(e){const t=ts({values:{...e},errors:{},busy:!1,async send(s,n){t.busy=!0,t.errors={};try{return await Qt[s](n,t.values)}catch(r){if(r instanceof Ts&&r.status===422)return t.errors=r.errors,null;throw r}finally{t.busy=!1}}});return t}const yc={Dashboard:"Dashboard","Log in":"Inloggen","Log out":"Uitloggen",Email:"E-mailadres",Password:"Wachtwoord","Keep me logged in":"Ingelogd blijven","Logging in…":"Bezig met inloggen…","Log in to manage the site.":"Log in om de site te beheren.","My account":"Mijn account",Name:"Naam","Email address":"E-mailadres","What you may do":"Wat je mag","Super admin: everything":"Super admin: alles","Not in a group yet":"Nog in geen groep","New password":"Nieuw wachtwoord","Leave empty to keep the password you have.":"Laat leeg om je wachtwoord te houden.","Current password":"Huidig wachtwoord","At least 12 characters.":"Minstens 12 tekens.","New password, once more":"Nieuw wachtwoord, nogmaals",Save:"Opslaan","Saving…":"Bezig met opslaan…","Saved.":"Opgeslagen.",Look:"Uiterlijk",Theme:"Thema",Posts:"Berichten","New post":"Nieuw bericht",Title:"Titel",Status:"Status",Category:"Categorie",Edit:"Bewerken",Delete:"Verwijderen","Put online":"Online zetten","Take offline":"Offline halen",Draft:"Concept",Sc
Line truncated
|
||||
function xn(e){const t=Object.create(null);for(const s of e.split(","))t[s]=1;return s=>s in t}const te={},Ot=[],st=()=>{},Ai=()=>!1,Is=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),js=e=>e.startsWith("onUpdate:"),de=Object.assign,wn=(e,t)=>{const s=e.indexOf(t);s>-1&&e.splice(s,1)},qo=Object.prototype.hasOwnProperty,X=(e,t)=>qo.call(e,t),U=Array.isArray,xt=e=>Ht(e)==="[object Map]",bt=e=>Ht(e)==="[object Set]",Kn=e=>Ht(e)==="[object Date]",F=e=>typeof e=="function",re=e=>typeof e=="string",Ke=e=>typeof e=="symbol",Q=e=>e!==null&&typeof e=="object",Ei=e=>(Q(e)||F(e))&&F(e.then)&&F(e.catch),Pi=Object.prototype.toString,Ht=e=>Pi.call(e),Go=e=>Ht(e).slice(8,-1),Oi=e=>Ht(e)==="[object Object]",$n=e=>re(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Zt=xn(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),zo=1e4,Ds=e=>{let t=Object.create(null),s=0;return(n=>{const i=t[n];return i!==void 0?i:(++s>zo&&(t=Object.create(null),s=1),t[n]=e(n))})},Jo=/-\w/g,Se=Ds(e=>e.replace(Jo,t=>t.slice(1).toUpperCase())),Xo=/\B([A-Z])/g,Vt=Ds(e=>e.replace(Xo,"-$1").toLowerCase()),Us=Ds(e=>e.charAt(0).toUpperCase()+e.slice(1)),Xs=Ds(e=>e?`on${Us(e)}`:""),tt=(e,t)=>!Object.is(e,t),Ss=(e,...t)=>{for(let s=0;s<e.length;s++)e[s](...t)},Mi=(e,t,s,n=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:n,value:s})},ds=e=>{const t=parseFloat(e);return isNaN(t)?e:t};let Wn;const Ls=()=>Wn||(Wn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function wt(e){if(U(e)){const t={};for(let s=0;s<e.length;s++){const n=e[s],i=re(n)?el(n):wt(n);if(i)for(const o in i)t[o]=i[o]}return t}else if(re(e)||Q(e))return e}const Yo=/;(?![^(]*\))/g,Zo=/:([^]+)/,Qo=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function el(e){const t={};return e.replace(Qo,s=>s.startsWith("/*")?"":s).split(Yo).forEach(s=>{if(s){const n=s.split(Zo);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function Ce(e){let t="";if(re(e))t=e;else if(U(e))for(let s=0;s<e.length;s++){const n=Ce(e[s]);n&&(t+=n+" ")}else if(Q(e))for(const s in e)e[s]&&(t+=s+" ");return t.trim()}function tl(e){if(!e)return null;let{class:t,style:s}=e;return t&&!re(t)&&(e.class=Ce(t)),s&&(e.style=wt(s)),e}const sl="itemscope,allowfullscreen,disablepictureinpicture,disableremoteplayback,formnovalidate,ismap,nomodule,novalidate,playsinline,readonly",nl=xn(sl);function Ni(e){return!!e||e===""}function il(e,t,s){if(e.length!==t.length)return!1;let n=!0;for(let i=0;n&&i<e.length;i++)n=We(e[i],t[i],s);return n}function qn(e,t,s){if(e.size!==t.size)return!1;const n=Array.from(t),i=new Uint8Array(n.length);for(const o of e){let l=-1;for(let r=0;r<n.length;r++)if(!i[r]&&We(o,n[r],s)){l=r;break}if(l<0)return!1;i[l]=1}return!0}function ol(e,t,s){let n=xt(e),i=xt(t);if(n||i||(n=bt(e),i=bt(t),n||i))return n&&i?qn(e,t,s):!1;const o=Object.keys(e).length,l=Object.keys(t).length;if(o!==l)return!1;for(const r in e){const a=X(e,r),d=X(t,r);if(a&&!d||!a&&d||!We(e[r],t[r],s))return!1}return zn(e)===zn(t)}function Gn(e,t,s,n){s||(s=[new Map,new Map]);const[i,o]=s;if(i.has(e)||o.has(t))return i.get(e)===t&&o.get(t)===e;i.set(e,t),o.set(t,e);const l=n(e,t,s);return i.delete(e),o.delete(t),l}function We(e,t,s){if(e===t)return!0;let n=Kn(e),i=Kn(t);return n||i?n&&i?e.getTime()===t.getTime():!1:(n=Ke(e),i=Ke(t),n||i?e===t:(n=U(e),i=U(t),n||i?n&&i?Gn(e,t,s,il):!1:(n=Q(e),i=Q(t),n||i?!n||!i?!1:Gn(e,t,s,ol):String(e)===String(t))))}function Sn(e,t){return e.findIndex(s=>We(s,t))}function zn(e){return Object.getPrototypeOf(e)===null&&e[Symbol.toPrimitive]==null&&typeof e.toString!="function"&&typeof e.valueOf!="function"?Ht(e):String(e)}const Ri=e=>!!(e&&e.__v_isRef===!0),p=e=>re(e)?e:e==null?"":U(e)||Q(e)&&(e.toString===Pi||!F(e.toString))?Ri(e)?p(e.value):JSON.stringify(e,Vi,2):String(e),Vi=(e,t)=>Ri(t)?Vi(e,t.value):xt(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((s,[n,i],o)=>(s[Ys(n,o)+" =>"]=i,s),{})}:bt(t)?{[`Set(${t.size})`]:[...t.values()].map(s=>Ys(s))}:Ke(t)?Ys(t):Q(t)&&!U(t)&&!Oi(t)?String(t):t,Ys=(e,t="")=>{var s;return Ke(e)?`Symbol(${(s=e.description)!=null?s:t})`:e};let ue;class Ii{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!t&&ue&&(ue.active?(this.parent=ue,this.index=(ue.scopes||(ue.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,s;if(this.scopes){const n=this.scopes.slice();for(t=0,s=n.length;t<s;t++)n[t].pause()}for(t=0,s=this.effects.length;t<s;t++)this.effects[t].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let t,s;if(this.scopes){const i=this.scopes.slice();for(t=0,s=i.length;t<s;t++)i[t].resume()}const n=this.effects.slice();for(t=0,s=n.length;t<s;t++)n[t].resume()}}run(t){Line truncated
|
||||
`))),e[Oe]=St(i);const o=n||i.props&&i.props.type==="number";pt(e,t?"change":"input",l=>{l.target.composing||e[Oe](cn(e.value,s,o))}),(s||o)&&pt(e,"change",()=>{e.value=cn(e.value,s,o)}),t||(pt(e,"compositionstart",da),pt(e,"compositionend",wi),pt(e,"change",wi))},mounted(e,{value:t,modifiers:{trim:s,number:n}}){const i=t??"",o=e[ws];delete e[ws],o!==void 0&&(e.type==="text"||e.type==="textarea")&&e.value!==o?e[Oe](cn(e.value,s,n)):e.value=i},beforeUpdate(e,{value:t,oldValue:s,modifiers:{lazy:n,trim:i,number:o}},l){if(e[Oe]=St(l),e.composing)return;const r=(o||e.type==="number")&&!/^0\d/.test(e.value)?ds(e.value):e.value,a=t??"";if(r===a)return;const d=e.getRootNode();(d instanceof Document||d instanceof ShadowRoot)&&d.activeElement===e&&e.type!=="range"&&(n&&t===s||i&&e.value.trim()===a)||(e.value=a)}},Nt={deep:!0,created(e,t,s){e[Oe]=St(s),pt(e,"change",()=>{const n=e._modelValue,i=Bt(e),o=e.checked,l=e[Oe];if(U(n)){const r=Sn(n,i),a=r!==-1;if(o&&!a)l(n.concat(i));else if(!o&&a){const d=[...n];d.splice(r,1),l(d)}}else if(bt(n)){const r=new Set(n);o?r.add(i):r.delete(i),l(r)}else l(Bo(e,o))})},mounted:$i,beforeUpdate(e,t,s){e[Oe]=St(s),$i(e,t,s)}};function $i(e,{value:t,oldValue:s},n){e._modelValue=t;let i;if(U(t))i=Sn(t,n.props.value)>-1;else if(bt(t))i=t.has(n.props.value);else{if(t===s)return;i=We(t,Bo(e,!0))}e.checked!==i&&(e.checked=i)}const fa={created(e,{value:t},s){e.checked=We(t,s.props.value),e[Oe]=St(s),pt(e,"change",()=>{e[Oe](Bt(e))})},beforeUpdate(e,{value:t,oldValue:s},n){e[Oe]=St(n),t!==s&&(e.checked=We(t,n.props.value))}},pa={deep:!0,created(e,{value:t,modifiers:{number:s}},n){e._modelValue=t,pt(e,"change",()=>{const i=Array.prototype.filter.call(e.options,a=>a.selected).map(a=>s?ds(Bt(a)):Bt(a)),o=e.multiple,l=o?bt(e._modelValue)?new Set(i):i:i[0],r=e._pendingValue=[o,o?U(l)?i.slice():i:l];try{e[Oe](l)}finally{to(()=>{e._pendingValue===r&&(e._pendingValue=void 0)})}}),e[Oe]=St(n)},mounted(e,{value:t,modifiers:{number:s}}){Si(e,t,s)},beforeUpdate(e,{value:t},s){e._modelValue=t,e[Oe]=St(s)},updated(e,{value:t,modifiers:{number:s}}){const n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!ha(t,n[1],n[0]))&&Si(e,t,s)}};function ha(e,t,s){if(!s||U(e))return We(e,t);if(bt(e)){if(e.size!==t.length)return!1;for(const n of t)if(!e.has(n))return!1;return!0}return!1}function Si(e,t,s=!1){const n=e.multiple,i=U(t);if(!(n&&!i&&!bt(t))){for(let o=0,l=e.options.length;o<l;o++){const r=e.options[o],a=Bt(r);if(n)if(i){const d=typeof a;d==="string"||d==="number"?r.selected=t.some(h=>String(h)===String(a)):r.selected=Sn(t,a)>-1}else r.selected=t.has(a)||s&&typeof a=="string"&&t.has(ds(a));else if(We(Bt(r),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Bt(e){return"_value"in e?e._value:e.value}function Bo(e,t){const s=t?"_trueValue":"_falseValue";return s in e?e[s]:t}const ma=["ctrl","shift","alt","meta"],ga={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>ma.some(s=>e[`${s}Key`]&&!t.includes(s))},De=(e,t)=>{if(!e)return e;const s=e._withMods||(e._withMods={}),n=t.join(".");return s[n]||(s[n]=((i,...o)=>{for(let l=0;l<t.length;l++){const r=ga[t[l]];if(r&&r(i,t))return}return e(i,...o)}))},ba=de({patchProp:aa},Wr);let ki;function _a(){return ki||(ki=Sr(ba))}const ya=((...e)=>{const t=_a().createApp(...e),{mount:s}=t;return t.mount=n=>{const i=xa(n);if(!i)return;const o=t._component;!F(o)&&!o.render&&!o.template&&(o.template=i.innerHTML),i.nodeType===1&&(i.textContent="");const l=s(i,!1,va(i));return i instanceof Element&&(i.removeAttribute("v-cloak"),i.setAttribute("data-v-app","")),l},t});function va(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function xa(e){return re(e)?document.querySelector(e):e}class Rt extends Error{constructor(t,s){super(s?.message??`HTTP ${t}`),this.status=t,this.body=s}status;body;get errors(){return Object.fromEntries(Object.entries(this.body?.errors??{}).map(([t,s])=>[t,s[0]]))}}const I=JSON.parse(document.getElementById("manager-boot").textContent);function Ho(){const e=document.cookie.match(/(?:^|; )XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):""}async function $s(e,t,s){const n=await fetch(t,{method:e,credentials:"same-origin",headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest","X-XSRF-TOKEN":Ho(),...s===void 0?{}:{"Content-Type":"application/json"}},body:s===void 0?void 0:JSON.stringify(s)}),i=n.status===204?null:await n.json().catch(()=>null);if(!n.ok)throw new Rt(n.status,i);return i}async function wa(e,t){const s=await fetch(e,{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest","X-XSRF-TOKEN":Ho()
Line truncated
|
||||
@@ -71,6 +71,13 @@ class InstallCommand extends Command
|
||||
$this->line('Run `php artisan migrate` (a new process) so the migrations of the modules you switched on are loaded.');
|
||||
}
|
||||
|
||||
if ($env !== []) {
|
||||
// This process still has the old config: its check would report the old state. A new process is right.
|
||||
$this->line('Next: add the HasManagerAccess trait to the user model, run `php artisan config:clear && php artisan migrate && php artisan storage:link`, then `php artisan manager:doctor --json`.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
return Artisan::call('manager:doctor', $this->option('json') ? ['--json' => true] : [], $this->output) === 0 ? self::SUCCESS : self::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,14 @@ use IriksIT\Manager\Tests\TestCase;
|
||||
uses(TestCase::class);
|
||||
|
||||
// The installer publishes the config into the app, here the skeleton in vendor/: leave it as it was.
|
||||
beforeEach(fn () => $this->hadConfig = file_exists(config_path('manager.php')));
|
||||
afterEach(fn () => $this->hadConfig || @unlink(config_path('manager.php')));
|
||||
beforeEach(function () {
|
||||
$this->hadConfig = file_exists(config_path('manager.php'));
|
||||
$this->env = file_exists(base_path('.env')) ? file_get_contents(base_path('.env')) : null;
|
||||
});
|
||||
afterEach(function () {
|
||||
$this->hadConfig || @unlink(config_path('manager.php'));
|
||||
$this->env === null ? @unlink(base_path('.env')) : file_put_contents(base_path('.env'), $this->env);
|
||||
});
|
||||
|
||||
function doctorReport(): array
|
||||
{
|
||||
@@ -54,12 +60,16 @@ it('refuses an unknown module in the installer', function () {
|
||||
|
||||
it('writes the switches to .env', function () {
|
||||
$env = base_path('.env');
|
||||
$before = file_exists($env) ? file_get_contents($env) : null;
|
||||
|
||||
Artisan::call('manager:install', ['--modules' => 'users,media,posts', '--path' => 'admin']);
|
||||
|
||||
$written = file_get_contents($env);
|
||||
$before === null ? unlink($env) : file_put_contents($env, $before);
|
||||
|
||||
expect($written)->toContain('MANAGER_PATH=admin')->toContain('MANAGER_AUDIT=false')->toContain('MANAGER_POSTS=true');
|
||||
});
|
||||
|
||||
it('leaves the check to a new process after it changed the switches', function () {
|
||||
Artisan::call('manager:install', ['--path' => 'admin']);
|
||||
|
||||
expect(Artisan::output())->toContain('manager:doctor')->not->toContain('[OK]');
|
||||
});
|
||||
+18
-1
@@ -53,11 +53,28 @@ export async function request<T = any>(method: string, path: string, body?: unkn
|
||||
return data as T;
|
||||
}
|
||||
|
||||
/** A file upload: multipart, the browser sets the content type. */
|
||||
export async function upload<T = any>(path: string, form: FormData): Promise<T> {
|
||||
const response = await fetch(path, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: { Accept: 'application/json', 'X-Requested-With': 'XMLHttpRequest', 'X-XSRF-TOKEN': xsrf() },
|
||||
body: form,
|
||||
});
|
||||
const data = await response.json().catch(() => null);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new ApiError(response.status, data);
|
||||
}
|
||||
|
||||
return data as T;
|
||||
}
|
||||
|
||||
export const api = {
|
||||
get: <T = any>(path: string) => request<T>('GET', path),
|
||||
post: <T = any>(path: string, body: unknown = {}) => request<T>('POST', path, body),
|
||||
put: <T = any>(path: string, body: unknown = {}) => request<T>('PUT', path, body),
|
||||
delete: <T = any>(path: string) => request<T>('DELETE', path),
|
||||
delete: <T = any>(path: string, body?: unknown) => request<T>('DELETE', path, body),
|
||||
};
|
||||
|
||||
/** A form: values, errors by field, a busy flag. */
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { api, boot } from '../api';
|
||||
import { t } from '../i18n';
|
||||
|
||||
const emit = defineEmits<{ pick: [url: string]; close: [] }>();
|
||||
const items = ref<{ id: number; name: string; url: string; is_image: boolean }[]>([]);
|
||||
const loading = ref(true);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
items.value = (await api.get(`${boot.base}/media/items`)).items.filter((item: any) => item.is_image);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="fixed inset-0 z-50 grid place-items-center bg-black/60 p-4" @click.self="emit('close')">
|
||||
<div class="m-card max-h-[85vh] w-full max-w-3xl overflow-y-auto p-5" role="dialog" aria-modal="true">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="font-display text-lg font-bold">{{ t('Choose an image') }}</h2>
|
||||
<button type="button" class="m-btn m-btn-secondary" @click="emit('close')">{{ t('Cancel') }}</button>
|
||||
</div>
|
||||
<p v-if="loading" class="text-sm text-muted">{{ t('Loading…') }}</p>
|
||||
<p v-else-if="!items.length" class="text-sm text-muted">{{ t('No images yet.') }}</p>
|
||||
<div v-else class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4">
|
||||
<button v-for="item in items" :key="item.id" type="button" class="overflow-hidden rounded-lg border border-line text-left hover:border-brand" @click="emit('pick', item.url)">
|
||||
<img :src="item.url" :alt="item.name" loading="lazy" class="aspect-square w-full object-cover" />
|
||||
<span class="block truncate px-2 py-1 text-xs">{{ item.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -15,6 +15,23 @@ const nl: Record<string, string> = {
|
||||
'You may not open this page.': 'Je mag deze pagina niet openen.', 'Something went wrong. Try again.': 'Er ging iets mis. Probeer het opnieuw.',
|
||||
'This page has no screen in the manager yet.': 'Deze pagina heeft nog geen scherm in de manager.', 'Go to the dashboard': 'Naar het dashboard',
|
||||
'The page expired. Reload it and try again.': 'De pagina is verlopen. Laad hem opnieuw en probeer het nog eens.', 'Back': 'Terug',
|
||||
'Accounts': 'Accounts', 'New account': 'Nieuw account', 'you': 'jij', 'Super admin': 'Super admin', 'Groups': 'Groepen', 'Cancel': 'Annuleren',
|
||||
'New group': 'Nieuwe groep', 'Description': 'Omschrijving', 'accounts': 'accounts', 'Categories and tags': 'Categorieën en tags',
|
||||
'Categories': 'Categorieën', 'Tags': 'Tags', 'Add': 'Toevoegen', 'Rename': 'Hernoemen', 'New name': 'Nieuwe naam',
|
||||
'Pages': 'Pagina\'s', 'Reviews': 'Reviews', 'Nothing here yet.': 'Hier is nog niets.', 'Previous': 'Vorige', 'Next': 'Volgende', 'Media': 'Media',
|
||||
'Choose an image': 'Kies een afbeelding', 'No images yet.': 'Nog geen afbeeldingen.', 'Uploaded.': 'Geüpload.', 'Upload': 'Uploaden',
|
||||
'Uploading…': 'Bezig met uploaden…', 'This file is in use. Delete it anyway?': 'Dit bestand is in gebruik. Toch verwijderen?',
|
||||
'Largest file': 'Grootste bestand', 'Alternative text': 'Alternatieve tekst', 'Used': 'Gebruikt', 'No files yet.': 'Nog geen bestanden.', 'Choose': 'Kiezen',
|
||||
'Audit log': 'Auditlog', 'Addresses banned': 'Geblokkeerde adressen', 'Logins (24 h)': 'Logins (24 u)', 'Failed logins (24 h)': 'Mislukte logins (24 u)',
|
||||
'Refused (24 h)': 'Geweigerd (24 u)', 'all': 'alles', 'logins': 'logins', 'failed': 'mislukt', 'actions': 'acties', 'viewed': 'bekeken', 'refused': 'geweigerd', 'bans': 'blokkades',
|
||||
'Search': 'Zoeken', 'Account': 'Account', 'Everyone': 'Iedereen', 'Filter': 'Filteren', 'Someone': 'Iemand', 'banned': 'geblokkeerd', 'Ban': 'Blokkeren', 'Bans': 'Blokkades',
|
||||
'Minutes (0 = until lifted)': 'Minuten (0 = tot opgeheven)', 'Reason': 'Reden', 'Whole site': 'Hele site', 'No bans.': 'Geen blokkades.', 'automatic': 'automatisch',
|
||||
'whole site': 'hele site', 'hits': 'pogingen', 'Lift': 'Opheffen', 'Rules': 'Regels', 'until lifted': 'tot opgeheven',
|
||||
'Ban an address by itself after too many failed logins': 'Een adres zelf blokkeren na te veel mislukte logins', 'Failed logins': 'Mislukte logins', 'Within minutes': 'Binnen minuten',
|
||||
'Ban for minutes (0 = until lifted)': 'Blokkeren voor minuten (0 = tot opgeheven)', 'Keep the log (days)': 'Log bewaren (dagen)', 'Notes about addresses': 'Notities over adressen',
|
||||
'Group': 'Groep', 'Note': 'Notitie', 'Statistics': 'Statistieken', 'compared with': 'vergeleken met', 'Visitors': 'Bezoekers', 'Visits': 'Bezoeken', 'Page views': 'Paginaweergaven',
|
||||
'Average time': 'Gemiddelde tijd', 'Bounce rate': 'Bouncepercentage', 'Channels': 'Kanalen', 'Sources': 'Bronnen', 'Countries': 'Landen', 'Devices': 'Apparaten', 'Browsers': 'Browsers',
|
||||
'Systems': 'Systemen', 'Direct': 'Direct', 'When people visit': 'Wanneer mensen komen', 'Programs': 'Programma\'s', 'Download': 'Downloaden',
|
||||
'Open': 'Openen', 'Created.': 'Aangemaakt.', 'Deleted.': 'Verwijderd.',
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { api, boot, useForm } from '../api';
|
||||
import { t } from '../i18n';
|
||||
import { flash, reload } from '../state';
|
||||
|
||||
interface Group { id: number; name: string; description: string | null; can_give: boolean }
|
||||
interface Account {
|
||||
id: number; name: string; email: string; is_super_admin: boolean; is_you: boolean;
|
||||
groups: { id: number; name: string }[]; can_change: boolean; can_delete: boolean;
|
||||
}
|
||||
|
||||
defineProps<{ accounts: Account[]; groups: Group[] }>();
|
||||
|
||||
const editing = ref<Account | 'new' | null>(null);
|
||||
const form = useForm({ name: '', email: '', password: '', groups: [] as number[] });
|
||||
|
||||
function open(account: Account | 'new'): void {
|
||||
editing.value = account;
|
||||
form.errors = {};
|
||||
form.values.name = account === 'new' ? '' : account.name;
|
||||
form.values.email = account === 'new' ? '' : account.email;
|
||||
form.values.password = '';
|
||||
form.values.groups = account === 'new' ? [] : account.groups.map((g) => g.id);
|
||||
}
|
||||
|
||||
async function save(): Promise<void> {
|
||||
const account = editing.value;
|
||||
const saved = account === 'new'
|
||||
? await form.send('post', `${boot.base}/accounts`)
|
||||
: await form.send('put', `${boot.base}/accounts/${(account as Account).id}`);
|
||||
|
||||
if (saved) {
|
||||
flash(t('Saved.'));
|
||||
editing.value = null;
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(account: Account): Promise<void> {
|
||||
if (window.confirm(t('Are you sure?'))) {
|
||||
await api.delete(`${boot.base}/accounts/${account.id}`);
|
||||
flash(t('Deleted.'));
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 class="font-display text-2xl font-bold">{{ t('Accounts') }}</h1>
|
||||
<button type="button" class="m-btn m-btn-primary" @click="open('new')">{{ t('New account') }}</button>
|
||||
</div>
|
||||
|
||||
<form v-if="editing" class="m-card mb-6 max-w-2xl space-y-4 p-5" @submit.prevent="save">
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="m-label" for="a-name">{{ t('Name') }}</label>
|
||||
<input id="a-name" v-model="form.values.name" required maxlength="255" class="m-input" />
|
||||
<p v-if="form.errors.name" class="m-error">{{ form.errors.name }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="m-label" for="a-email">{{ t('Email address') }}</label>
|
||||
<input id="a-email" v-model="form.values.email" type="email" required maxlength="255" class="m-input" />
|
||||
<p v-if="form.errors.email" class="m-error">{{ form.errors.email }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="m-label" for="a-pass">{{ t('Password') }}</label>
|
||||
<input id="a-pass" v-model="form.values.password" type="password" minlength="12" maxlength="200" :required="editing === 'new'" class="m-input" autocomplete="new-password" />
|
||||
<p class="m-help">{{ editing === 'new' ? t('At least 12 characters.') : t('Leave empty to keep the password you have.') }}</p>
|
||||
<p v-if="form.errors.password" class="m-error">{{ form.errors.password }}</p>
|
||||
</div>
|
||||
<fieldset v-if="groups.length">
|
||||
<legend class="m-label">{{ t('Groups') }}</legend>
|
||||
<label v-for="group in groups" :key="group.id" class="flex items-center gap-2 py-0.5 text-sm" :class="group.can_give ? '' : 'opacity-50'">
|
||||
<input v-model="form.values.groups" type="checkbox" :value="group.id" :disabled="!group.can_give" />
|
||||
{{ group.name }}
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="flex gap-2">
|
||||
<button type="submit" class="m-btn m-btn-primary" :disabled="form.busy">{{ form.busy ? t('Saving…') : t('Save') }}</button>
|
||||
<button type="button" class="m-btn m-btn-secondary" @click="editing = null">{{ t('Cancel') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<ul class="m-card divide-y divide-line">
|
||||
<li v-for="account in accounts" :key="account.id" class="flex flex-wrap items-center justify-between gap-3 p-4">
|
||||
<div class="min-w-0">
|
||||
<p class="truncate font-semibold">{{ account.name }} <span v-if="account.is_you" class="text-xs font-normal text-muted">({{ t('you') }})</span></p>
|
||||
<p class="truncate text-xs text-muted">{{ account.email }}</p>
|
||||
<p class="mt-1 flex flex-wrap gap-1">
|
||||
<span v-if="account.is_super_admin" class="m-badge">{{ t('Super admin') }}</span>
|
||||
<span v-for="group in account.groups" :key="group.id" class="m-badge">{{ group.name }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button v-if="account.can_change" type="button" class="m-btn m-btn-secondary" @click="open(account)">{{ t('Edit') }}</button>
|
||||
<button v-if="account.can_delete" type="button" class="m-btn m-btn-danger" @click="remove(account)">{{ t('Delete') }}</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -0,0 +1,171 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { api, boot, useForm } from '../api';
|
||||
import Link from '../components/Link.vue';
|
||||
import { t } from '../i18n';
|
||||
import { flash, navigate, reload } from '../state';
|
||||
|
||||
interface Entry {
|
||||
id: number; at: string; event: string; summary: string; subject: { type: string; label: string; url: string | null } | null;
|
||||
details: Record<string, any>; who: string | null; email: string | null; ip: string | null; browser: string | null;
|
||||
banned: boolean; never_banned: boolean;
|
||||
}
|
||||
interface Ban { id: number; ip: string; reason: string | null; automatic: boolean; whole_site: boolean; by: string | null; hits: number; expires_at: string | null; active: boolean }
|
||||
|
||||
const props = defineProps<{
|
||||
entries: Entry[]; pagination: { page: number; pages: number; total: number };
|
||||
filters: { show: string; user: number | null; ip: string; q: string };
|
||||
accounts: { id: number; name: string }[];
|
||||
summary: { logins: number; failed: number; refused: number; banned: number };
|
||||
bans: Ban[]; notes: { ip: string; group: string | null; note: string; by: string | null }[];
|
||||
settings: { auto_ban: boolean; max_failures: number; window_minutes: number; ban_minutes: number; keep_days: number };
|
||||
max_keep_days: number; can_manage: boolean; my_ip: string; never_banned: string[]; whole_site_bans: boolean;
|
||||
}>();
|
||||
|
||||
const tabs = ['all', 'logins', 'failed', 'actions', 'viewed', 'refused', 'bans'];
|
||||
const search = reactive({ q: props.filters.q, ip: props.filters.ip, user: props.filters.user ?? '' });
|
||||
const when = (iso: string) => new Date(iso).toLocaleString();
|
||||
|
||||
function go(extra: Record<string, string | number>): void {
|
||||
const query = new URLSearchParams();
|
||||
const merged: Record<string, string | number> = { show: props.filters.show, q: search.q, ip: search.ip, user: search.user, ...extra };
|
||||
|
||||
for (const [key, value] of Object.entries(merged)) {
|
||||
value !== '' && value !== 'all' && value !== 1 && query.set(key, String(value));
|
||||
}
|
||||
void navigate(`${boot.base}/audit${query.size ? '?' + query : ''}`);
|
||||
}
|
||||
|
||||
const ban = useForm({ ip: '', minutes: 1440, reason: '', whole_site: false });
|
||||
|
||||
async function banIp(ip?: string): Promise<void> {
|
||||
if (ip) {
|
||||
ban.values.ip = ip;
|
||||
}
|
||||
const done = await ban.send<{ message: string }>('post', `${boot.base}/audit/bans`);
|
||||
|
||||
if (done) {
|
||||
flash(done.message);
|
||||
ban.values.ip = ban.values.reason = '';
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function lift(item: Ban): Promise<void> {
|
||||
flash((await api.delete(`${boot.base}/audit/bans/${item.id}`)).message);
|
||||
await reload();
|
||||
}
|
||||
|
||||
const rules = useForm({ ...props.settings });
|
||||
|
||||
async function saveRules(): Promise<void> {
|
||||
if (await rules.send('put', `${boot.base}/audit/settings`)) {
|
||||
flash(t('Saved.'));
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
const note = useForm({ ip: '', group: '', note: '' });
|
||||
|
||||
async function saveNote(): Promise<void> {
|
||||
if (await note.send('put', `${boot.base}/audit/notes`)) {
|
||||
flash(t('Saved.'));
|
||||
note.values.ip = note.values.group = note.values.note = '';
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
const expires = (item: Ban) => (item.expires_at ? when(item.expires_at) : t('until lifted'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1 class="font-display mb-6 text-2xl font-bold">{{ t('Audit log') }}</h1>
|
||||
|
||||
<div class="mb-6 grid grid-cols-2 gap-3 md:grid-cols-4">
|
||||
<div v-for="(value, key) in summary" :key="key" class="m-card p-4">
|
||||
<p class="text-2xl font-bold">{{ value }}</p>
|
||||
<p class="m-help">{{ t(key === 'banned' ? 'Addresses banned' : key === 'logins' ? 'Logins (24 h)' : key === 'failed' ? 'Failed logins (24 h)' : 'Refused (24 h)') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="mb-4 flex flex-wrap gap-2">
|
||||
<button v-for="tab in tabs" :key="tab" type="button" class="m-btn" :class="filters.show === tab ? 'm-btn-primary' : 'm-btn-secondary'" @click="go({ show: tab, page: 1 })">{{ t(tab) }}</button>
|
||||
</nav>
|
||||
<form class="mb-4 flex flex-wrap gap-2" @submit.prevent="go({ page: 1 })">
|
||||
<input v-model="search.q" class="m-input max-w-xs" :placeholder="t('Search')" :aria-label="t('Search')" />
|
||||
<input v-model="search.ip" class="m-input max-w-[12rem]" placeholder="IP" aria-label="IP" />
|
||||
<select v-model="search.user" class="m-input max-w-[12rem]" :aria-label="t('Account')">
|
||||
<option value="">{{ t('Everyone') }}</option>
|
||||
<option v-for="account in accounts" :key="account.id" :value="account.id">{{ account.name }}</option>
|
||||
</select>
|
||||
<button type="submit" class="m-btn m-btn-secondary">{{ t('Filter') }}</button>
|
||||
</form>
|
||||
|
||||
<p v-if="!entries.length" class="m-card p-5 text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul v-else class="m-card divide-y divide-line">
|
||||
<li v-for="entry in entries" :key="entry.id" class="flex flex-wrap items-start justify-between gap-3 p-4 text-sm">
|
||||
<div class="min-w-0">
|
||||
<p class="font-semibold">{{ entry.summary }}
|
||||
<template v-if="entry.subject">
|
||||
· <Link v-if="entry.subject.url" :href="entry.subject.url" class="underline">{{ entry.subject.label }}</Link><span v-else>{{ entry.subject.label }}</span>
|
||||
</template>
|
||||
</p>
|
||||
<p class="text-xs text-muted">{{ when(entry.at) }} · {{ entry.who ?? entry.email ?? t('Someone') }} · {{ entry.ip }} · {{ entry.browser }}</p>
|
||||
</div>
|
||||
<span class="flex gap-2">
|
||||
<span v-if="entry.banned" class="m-badge">{{ t('banned') }}</span>
|
||||
<button v-if="can_manage && entry.ip && !entry.banned && !entry.never_banned && entry.ip !== my_ip" type="button" class="m-btn m-btn-danger" @click="banIp(entry.ip)">{{ t('Ban') }}</button>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<nav v-if="pagination.pages > 1" class="mt-4 flex items-center gap-2">
|
||||
<button v-if="pagination.page > 1" type="button" class="m-btn m-btn-secondary" @click="go({ page: pagination.page - 1 })">{{ t('Previous') }}</button>
|
||||
<span class="text-sm text-muted">{{ pagination.page }} / {{ pagination.pages }}</span>
|
||||
<button v-if="pagination.page < pagination.pages" type="button" class="m-btn m-btn-secondary" @click="go({ page: pagination.page + 1 })">{{ t('Next') }}</button>
|
||||
</nav>
|
||||
|
||||
<h2 class="font-display mb-3 mt-10 text-xl font-bold">{{ t('Bans') }}</h2>
|
||||
<form v-if="can_manage" class="m-card mb-4 flex max-w-3xl flex-wrap items-end gap-3 p-4" @submit.prevent="banIp()">
|
||||
<div><label class="m-label" for="b-ip">IP</label><input id="b-ip" v-model="ban.values.ip" required class="m-input" /></div>
|
||||
<div><label class="m-label" for="b-min">{{ t('Minutes (0 = until lifted)') }}</label><input id="b-min" v-model.number="ban.values.minutes" type="number" min="0" class="m-input w-32" /></div>
|
||||
<div class="min-w-[10rem] flex-1"><label class="m-label" for="b-why">{{ t('Reason') }}</label><input id="b-why" v-model="ban.values.reason" maxlength="200" class="m-input" /></div>
|
||||
<label v-if="whole_site_bans" class="flex items-center gap-2 text-sm"><input v-model="ban.values.whole_site" type="checkbox" /> {{ t('Whole site') }}</label>
|
||||
<button type="submit" class="m-btn m-btn-danger">{{ t('Ban') }}</button>
|
||||
<p v-if="ban.errors.ip" class="m-error w-full">{{ ban.errors.ip }}</p>
|
||||
</form>
|
||||
<p v-if="!bans.length" class="text-sm text-muted">{{ t('No bans.') }}</p>
|
||||
<ul v-else class="m-card divide-y divide-line">
|
||||
<li v-for="item in bans" :key="item.id" class="flex flex-wrap items-center justify-between gap-3 p-4 text-sm" :class="item.active ? '' : 'opacity-50'">
|
||||
<div>
|
||||
<p class="font-semibold">{{ item.ip }} <span v-if="item.automatic" class="m-badge">{{ t('automatic') }}</span> <span v-if="item.whole_site" class="m-badge">{{ t('whole site') }}</span></p>
|
||||
<p class="text-xs text-muted">{{ item.reason }} · {{ expires(item) }} · {{ item.hits }} {{ t('hits') }}</p>
|
||||
</div>
|
||||
<button v-if="can_manage && item.active" type="button" class="m-btn m-btn-secondary" @click="lift(item)">{{ t('Lift') }}</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<template v-if="can_manage">
|
||||
<h2 class="font-display mb-3 mt-10 text-xl font-bold">{{ t('Rules') }}</h2>
|
||||
<form class="m-card grid max-w-3xl gap-4 p-5 sm:grid-cols-2" @submit.prevent="saveRules">
|
||||
<label class="flex items-center gap-2 text-sm sm:col-span-2"><input v-model="rules.values.auto_ban" type="checkbox" /> {{ t('Ban an address by itself after too many failed logins') }}</label>
|
||||
<div><label class="m-label" for="r-max">{{ t('Failed logins') }}</label><input id="r-max" v-model.number="rules.values.max_failures" type="number" min="3" max="100" class="m-input" /></div>
|
||||
<div><label class="m-label" for="r-win">{{ t('Within minutes') }}</label><input id="r-win" v-model.number="rules.values.window_minutes" type="number" min="1" max="1440" class="m-input" /></div>
|
||||
<div><label class="m-label" for="r-ban">{{ t('Ban for minutes (0 = until lifted)') }}</label><input id="r-ban" v-model.number="rules.values.ban_minutes" type="number" min="0" class="m-input" /></div>
|
||||
<div><label class="m-label" for="r-keep">{{ t('Keep the log (days)') }}</label><input id="r-keep" v-model.number="rules.values.keep_days" type="number" min="7" :max="max_keep_days" class="m-input" /><p class="m-help">≤ {{ max_keep_days }}</p></div>
|
||||
<div class="sm:col-span-2"><button type="submit" class="m-btn m-btn-primary" :disabled="rules.busy">{{ t('Save') }}</button></div>
|
||||
<template v-for="(message, field) in rules.errors" :key="field"><p class="m-error sm:col-span-2">{{ message }}</p></template>
|
||||
</form>
|
||||
|
||||
<h2 class="font-display mb-3 mt-10 text-xl font-bold">{{ t('Notes about addresses') }}</h2>
|
||||
<form class="m-card mb-4 flex max-w-3xl flex-wrap items-end gap-3 p-4" @submit.prevent="saveNote">
|
||||
<div><label class="m-label" for="n-ip">IP</label><input id="n-ip" v-model="note.values.ip" required class="m-input" /></div>
|
||||
<div><label class="m-label" for="n-group">{{ t('Group') }}</label><input id="n-group" v-model="note.values.group" maxlength="60" class="m-input" /></div>
|
||||
<div class="min-w-[10rem] flex-1"><label class="m-label" for="n-note">{{ t('Note') }}</label><input id="n-note" v-model="note.values.note" maxlength="2000" class="m-input" /></div>
|
||||
<button type="submit" class="m-btn m-btn-secondary">{{ t('Save') }}</button>
|
||||
<p v-if="note.errors.ip" class="m-error w-full">{{ note.errors.ip }}</p>
|
||||
</form>
|
||||
<ul v-if="notes.length" class="m-card divide-y divide-line text-sm">
|
||||
<li v-for="item in notes" :key="item.ip" class="p-3"><b>{{ item.ip }}</b> <span v-if="item.group" class="m-badge">{{ item.group }}</span> {{ item.note }}</li>
|
||||
</ul>
|
||||
</template>
|
||||
</template>
|
||||
@@ -0,0 +1,97 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { api, boot, useForm } from '../api';
|
||||
import { t } from '../i18n';
|
||||
import { flash, reload } from '../state';
|
||||
|
||||
interface Perm { value: string; label: string; needs: string[] }
|
||||
interface Group { id: number; name: string; description: string | null; permissions: string[]; accounts: number }
|
||||
|
||||
const props = defineProps<{ groups: Group[]; catalogue: { section: string; permissions: Perm[] }[] }>();
|
||||
|
||||
const editing = ref<Group | 'new' | null>(null);
|
||||
const form = useForm({ name: '', description: '', permissions: [] as string[] });
|
||||
const all = props.catalogue.flatMap((s) => s.permissions);
|
||||
|
||||
function open(group: Group | 'new'): void {
|
||||
editing.value = group;
|
||||
form.errors = {};
|
||||
form.values.name = group === 'new' ? '' : group.name;
|
||||
form.values.description = group === 'new' ? '' : (group.description ?? '');
|
||||
form.values.permissions = group === 'new' ? [] : [...group.permissions];
|
||||
}
|
||||
|
||||
/** A permission that needs others brings them along; the server does the same, this only shows it. */
|
||||
function toggled(perm: Perm): void {
|
||||
if (form.values.permissions.includes(perm.value)) {
|
||||
form.values.permissions = [...new Set([...form.values.permissions, ...perm.needs])];
|
||||
} else {
|
||||
form.values.permissions = form.values.permissions.filter((value) => !all.find((p) => p.value === value)?.needs.includes(perm.value));
|
||||
}
|
||||
}
|
||||
|
||||
async function save(): Promise<void> {
|
||||
const group = editing.value;
|
||||
const saved = group === 'new'
|
||||
? await form.send('post', `${boot.base}/groups`)
|
||||
: await form.send('put', `${boot.base}/groups/${(group as Group).id}`);
|
||||
|
||||
if (saved) {
|
||||
flash(t('Saved.'));
|
||||
editing.value = null;
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(group: Group): Promise<void> {
|
||||
if (window.confirm(t('Are you sure?'))) {
|
||||
await api.delete(`${boot.base}/groups/${group.id}`);
|
||||
flash(t('Deleted.'));
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 class="font-display text-2xl font-bold">{{ t('Groups') }}</h1>
|
||||
<button type="button" class="m-btn m-btn-primary" @click="open('new')">{{ t('New group') }}</button>
|
||||
</div>
|
||||
|
||||
<form v-if="editing" class="m-card mb-6 max-w-3xl space-y-4 p-5" @submit.prevent="save">
|
||||
<div>
|
||||
<label class="m-label" for="g-name">{{ t('Name') }}</label>
|
||||
<input id="g-name" v-model="form.values.name" required maxlength="60" class="m-input" />
|
||||
<p v-if="form.errors.name" class="m-error">{{ form.errors.name }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="m-label" for="g-desc">{{ t('Description') }}</label>
|
||||
<textarea id="g-desc" v-model="form.values.description" rows="2" maxlength="500" class="m-input" />
|
||||
</div>
|
||||
<fieldset v-for="section in catalogue" :key="section.section" class="rounded-lg border border-line p-3">
|
||||
<legend class="px-1 text-sm font-semibold">{{ section.section }}</legend>
|
||||
<label v-for="perm in section.permissions" :key="perm.value" class="flex items-center gap-2 py-0.5 text-sm">
|
||||
<input v-model="form.values.permissions" type="checkbox" :value="perm.value" @change="toggled(perm)" />
|
||||
{{ perm.label }}
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="flex gap-2">
|
||||
<button type="submit" class="m-btn m-btn-primary" :disabled="form.busy">{{ form.busy ? t('Saving…') : t('Save') }}</button>
|
||||
<button type="button" class="m-btn m-btn-secondary" @click="editing = null">{{ t('Cancel') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<p v-if="!groups.length" class="m-card p-5 text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul v-else class="m-card divide-y divide-line">
|
||||
<li v-for="group in groups" :key="group.id" class="flex flex-wrap items-center justify-between gap-3 p-4">
|
||||
<div class="min-w-0">
|
||||
<p class="font-semibold">{{ group.name }} <span class="text-xs font-normal text-muted">· {{ group.accounts }} {{ t('accounts') }}</span></p>
|
||||
<p v-if="group.description" class="text-xs text-muted">{{ group.description }}</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button type="button" class="m-btn m-btn-secondary" @click="open(group)">{{ t('Edit') }}</button>
|
||||
<button type="button" class="m-btn m-btn-danger" @click="remove(group)">{{ t('Delete') }}</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { api, boot, ApiError } from '../api';
|
||||
import { t } from '../i18n';
|
||||
import { flash, reload } from '../state';
|
||||
|
||||
type Label = { name: string; posts: number };
|
||||
defineProps<{ categories: Label[]; tags: Label[] }>();
|
||||
|
||||
const kinds = [
|
||||
{ type: 'category', title: 'Categories' },
|
||||
{ type: 'tag', title: 'Tags' },
|
||||
] as const;
|
||||
const adding = ref<Record<string, string>>({ category: '', tag: '' });
|
||||
const error = ref('');
|
||||
|
||||
async function run(action: () => Promise<unknown>): Promise<void> {
|
||||
error.value = '';
|
||||
try {
|
||||
await action();
|
||||
await reload();
|
||||
} catch (e) {
|
||||
if (e instanceof ApiError && e.status === 422) {
|
||||
error.value = Object.values(e.errors)[0] ?? e.message;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const add = (type: string) => run(async () => {
|
||||
await api.post(`${boot.base}/labels`, { type, name: adding.value[type] });
|
||||
adding.value[type] = '';
|
||||
flash(t('Created.'));
|
||||
});
|
||||
const rename = (type: string, name: string) => {
|
||||
const to = window.prompt(t('New name'), name);
|
||||
|
||||
return to && to !== name ? run(() => api.put(`${boot.base}/labels`, { type, name, new_name: to })) : undefined;
|
||||
};
|
||||
const remove = (type: string, name: string) =>
|
||||
window.confirm(t('Are you sure?')) ? run(() => api.delete(`${boot.base}/labels`, { type, name })) : undefined;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1 class="font-display mb-6 text-2xl font-bold">{{ t('Categories and tags') }}</h1>
|
||||
<p v-if="error" class="m-error mb-4">{{ error }}</p>
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
<section v-for="kind in kinds" :key="kind.type" class="m-card p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t(kind.title) }}</h2>
|
||||
<form class="mb-3 flex gap-2" @submit.prevent="add(kind.type)">
|
||||
<input v-model="adding[kind.type]" required maxlength="60" class="m-input" :aria-label="t(kind.title)" />
|
||||
<button type="submit" class="m-btn m-btn-primary">{{ t('Add') }}</button>
|
||||
</form>
|
||||
<ul class="divide-y divide-line">
|
||||
<li v-for="label in kind.type === 'category' ? categories : tags" :key="label.name" class="flex items-center justify-between gap-2 py-2 text-sm">
|
||||
<span class="min-w-0 truncate">{{ label.name }} <span class="text-xs text-muted">· {{ label.posts }}</span></span>
|
||||
<span class="flex gap-1">
|
||||
<button type="button" class="m-btn m-btn-secondary" @click="rename(kind.type, label.name)">{{ t('Rename') }}</button>
|
||||
<button type="button" class="m-btn m-btn-danger" @click="remove(kind.type, label.name)">{{ t('Delete') }}</button>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import Link from '../components/Link.vue';
|
||||
import { t } from '../i18n';
|
||||
import { state } from '../state';
|
||||
|
||||
// Pages and reviews are still plain lists (a paginated answer), so one read-only screen shows both.
|
||||
const props = defineProps<{ data: Record<string, any>[]; current_page: number; last_page: number; path: string }>();
|
||||
|
||||
const kind = computed(() => (state.path.includes('/reviews') ? 'reviews' : 'pages'));
|
||||
const heading = computed(() => (kind.value === 'reviews' ? 'Reviews' : 'Pages'));
|
||||
const title = (row: Record<string, any>) => (kind.value === 'reviews' ? row.author : row.title);
|
||||
const detail = (row: Record<string, any>) => (kind.value === 'reviews' ? (row.rating ? '★'.repeat(row.rating) : '') : row.slug);
|
||||
const live = (row: Record<string, any>) => (kind.value === 'reviews' ? row.is_visible : row.is_published);
|
||||
const page = (n: number) => `${state.path.split('?')[0]}?page=${n}`;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1 class="font-display mb-6 text-2xl font-bold">{{ t(heading) }}</h1>
|
||||
<p v-if="!props.data.length" class="m-card p-5 text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul v-else class="m-card divide-y divide-line">
|
||||
<li v-for="row in props.data" :key="row.id" class="flex items-center justify-between gap-3 p-4">
|
||||
<div class="min-w-0">
|
||||
<p class="truncate font-semibold">{{ title(row) }}</p>
|
||||
<p class="truncate text-xs text-muted">{{ detail(row) }}</p>
|
||||
</div>
|
||||
<span class="m-badge">{{ live(row) ? t('Published') : t('Draft') }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<nav v-if="props.last_page > 1" class="mt-4 flex gap-2">
|
||||
<Link v-if="props.current_page > 1" :href="page(props.current_page - 1)" class="m-btn m-btn-secondary">{{ t('Previous') }}</Link>
|
||||
<Link v-if="props.current_page < props.last_page" :href="page(props.current_page + 1)" class="m-btn m-btn-secondary">{{ t('Next') }}</Link>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ApiError, api, boot, upload, useForm } from '../api';
|
||||
import { t } from '../i18n';
|
||||
import { flash, reload } from '../state';
|
||||
|
||||
interface Item {
|
||||
id: number; name: string; filename: string; url: string; mime_type: string; is_image: boolean; size: number;
|
||||
width: number | null; height: number | null; alt: string | null; uploaded_by: string | null; usage_count: number;
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
items: Item[]; max_file_mb: number; extensions: string[];
|
||||
storage: { used: number; limit: number; left: number };
|
||||
}>();
|
||||
|
||||
const can = (permission: string) => boot.permissions.includes(permission);
|
||||
const busy = ref(false);
|
||||
const selected = ref<Item | null>(null);
|
||||
const form = useForm({ name: '', alt: '' });
|
||||
|
||||
const size = (bytes: number) => (bytes > 1e6 ? `${(bytes / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1e3))} kB`);
|
||||
|
||||
function choose(item: Item): void {
|
||||
selected.value = item;
|
||||
form.errors = {};
|
||||
form.values.name = item.name;
|
||||
form.values.alt = item.alt ?? '';
|
||||
}
|
||||
|
||||
async function send(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
busy.value = true;
|
||||
try {
|
||||
for (const file of Array.from(input.files ?? [])) {
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
await upload(`${boot.base}/media`, data);
|
||||
}
|
||||
flash(t('Uploaded.'));
|
||||
await reload();
|
||||
} catch (error) {
|
||||
flash(error instanceof ApiError ? (Object.values(error.errors)[0] ?? error.message) : t('Something went wrong. Try again.'), true);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function save(): Promise<void> {
|
||||
if (selected.value && (await form.send('put', `${boot.base}/media/${selected.value.id}`))) {
|
||||
flash(t('Saved.'));
|
||||
selected.value = null;
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(item: Item): Promise<void> {
|
||||
const warning = item.usage_count > 0 ? t('This file is in use. Delete it anyway?') : t('Are you sure?');
|
||||
|
||||
if (window.confirm(warning)) {
|
||||
await api.delete(`${boot.base}/media/${item.id}`);
|
||||
selected.value = null;
|
||||
flash(t('Deleted.'));
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 class="font-display text-2xl font-bold">{{ t('Media') }}</h1>
|
||||
<label v-if="can('media.upload')" class="m-btn m-btn-primary cursor-pointer" :class="busy ? 'opacity-50' : ''">
|
||||
{{ busy ? t('Uploading…') : t('Upload') }}
|
||||
<input type="file" multiple class="sr-only" :accept="extensions.map((e) => '.' + e).join(',')" :disabled="busy" @change="send" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mb-6 max-w-md" :title="`${size(storage.used)} / ${size(storage.limit)}`">
|
||||
<div class="h-2 overflow-hidden rounded-full bg-panel-2">
|
||||
<div class="h-full bg-brand" :style="{ width: Math.min(100, (storage.used / Math.max(1, storage.limit)) * 100) + '%' }" />
|
||||
</div>
|
||||
<p class="m-help">{{ size(storage.used) }} / {{ size(storage.limit) }} · {{ t('Largest file') }}: {{ max_file_mb }} MB</p>
|
||||
</div>
|
||||
|
||||
<form v-if="selected" class="m-card mb-6 flex max-w-3xl flex-wrap gap-5 p-5" @submit.prevent="save">
|
||||
<img v-if="selected.is_image" :src="selected.url" :alt="selected.alt ?? ''" class="h-32 w-32 rounded-lg object-cover" />
|
||||
<div class="min-w-0 flex-1 space-y-3">
|
||||
<div>
|
||||
<label class="m-label" for="m-name">{{ t('Name') }}</label>
|
||||
<input id="m-name" v-model="form.values.name" required maxlength="250" class="m-input" :disabled="!can('media.edit')" />
|
||||
<p v-if="form.errors.name" class="m-error">{{ form.errors.name }}</p>
|
||||
</div>
|
||||
<div v-if="selected.is_image">
|
||||
<label class="m-label" for="m-alt">{{ t('Alternative text') }}</label>
|
||||
<input id="m-alt" v-model="form.values.alt" maxlength="500" class="m-input" :disabled="!can('media.edit')" />
|
||||
</div>
|
||||
<p class="m-help">
|
||||
{{ selected.mime_type }} · {{ size(selected.size) }}<span v-if="selected.width"> · {{ selected.width }}×{{ selected.height }}</span>
|
||||
· {{ t('Used') }}: {{ selected.usage_count }}<span v-if="selected.uploaded_by"> · {{ selected.uploaded_by }}</span>
|
||||
</p>
|
||||
<p class="m-help break-all">{{ selected.url }}</p>
|
||||
<div class="flex gap-2">
|
||||
<button v-if="can('media.edit')" type="submit" class="m-btn m-btn-primary" :disabled="form.busy">{{ t('Save') }}</button>
|
||||
<button v-if="can('media.delete')" type="button" class="m-btn m-btn-danger" @click="remove(selected)">{{ t('Delete') }}</button>
|
||||
<button type="button" class="m-btn m-btn-secondary" @click="selected = null">{{ t('Cancel') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<p v-if="!items.length" class="m-card p-5 text-sm text-muted">{{ t('No files yet.') }}</p>
|
||||
<div v-else class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||
<button v-for="item in items" :key="item.id" type="button" class="m-card overflow-hidden text-left transition hover:border-brand" :class="selected?.id === item.id ? 'border-brand' : ''" @click="choose(item)">
|
||||
<img v-if="item.is_image" :src="item.url" :alt="item.alt ?? ''" loading="lazy" class="aspect-square w-full object-cover" />
|
||||
<span v-else class="grid aspect-square w-full place-items-center text-xs text-muted">{{ item.mime_type }}</span>
|
||||
<span class="block truncate px-2 py-1.5 text-xs">{{ item.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { boot, useForm } from '../api';
|
||||
import { ref } from 'vue';
|
||||
import Link from '../components/Link.vue';
|
||||
import MediaPicker from '../components/MediaPicker.vue';
|
||||
import { t } from '../i18n';
|
||||
import { flash, navigate } from '../state';
|
||||
|
||||
@@ -12,6 +14,7 @@ const form = useForm({
|
||||
cover_image: post?.cover_image ?? '', category: post?.category ?? '', tags: (post?.tags ?? []) as string[],
|
||||
is_featured: post?.is_featured ?? false, is_published: post?.is_published ?? false, published_at: post?.published_at ?? '',
|
||||
});
|
||||
const picking = ref(false);
|
||||
// Tags are typed as one comma separated line.
|
||||
let tagLine = (post?.tags ?? []).join(', ');
|
||||
|
||||
@@ -64,7 +67,10 @@ async function submit(): Promise<void> {
|
||||
<div class="grid gap-5 sm:grid-cols-2">
|
||||
<div>
|
||||
<label for="cover" class="m-label">{{ t('Cover image') }}</label>
|
||||
<input id="cover" v-model="form.values.cover_image" maxlength="2048" class="m-input" />
|
||||
<div class="flex gap-2">
|
||||
<input id="cover" v-model="form.values.cover_image" maxlength="2048" class="m-input" />
|
||||
<button v-if="boot.permissions.includes('media.view')" type="button" class="m-btn m-btn-secondary shrink-0" @click="picking = true">{{ t('Choose') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="tags" class="m-label">{{ t('Tags (comma separated)') }}</label>
|
||||
@@ -82,4 +88,5 @@ async function submit(): Promise<void> {
|
||||
</div>
|
||||
<button type="submit" class="m-btn m-btn-primary" :disabled="form.busy">{{ form.busy ? t('Saving…') : t('Save') }}</button>
|
||||
</form>
|
||||
<MediaPicker v-if="picking" @pick="(url) => { form.values.cover_image = url; picking = false; }" @close="picking = false" />
|
||||
</template>
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { boot } from '../api';
|
||||
import Link from '../components/Link.vue';
|
||||
import { t } from '../i18n';
|
||||
import { state } from '../state';
|
||||
|
||||
type Totals = { visitors: number; visits: number; page_views: number; average_seconds: number; bounce_rate: number };
|
||||
type Row = { name: string; visits: number; channel?: string };
|
||||
|
||||
const props = defineProps<{
|
||||
range: { key: string; label: string; from: string; to: string; compared_to: string | null };
|
||||
ranges: { key: string; label: string }[]; exports: Record<string, string>;
|
||||
totals: Totals; previous: Totals | null;
|
||||
series: { key: string; label: string; visitors: number; visits: number; page_views: number; bot_hits: number }[];
|
||||
pages: { path: string; title: string | null; views: number; average_seconds: number }[];
|
||||
posts: { title: string; slug: string; views: number; average_seconds: number }[];
|
||||
channels: Row[]; sources: Row[]; countries: Row[]; devices: Row[]; browsers: Row[]; systems: Row[];
|
||||
heatmap: { day: string; hours: number[] }[];
|
||||
bots: { total: number; previous: number | null; names: { name: string; kind: string; hits: number }[]; kinds: { name: string; hits: number }[]; pages: { path: string; hits: number }[] };
|
||||
}>();
|
||||
|
||||
const tiles = computed(() => [
|
||||
['Visitors', 'visitors'], ['Visits', 'visits'], ['Page views', 'page_views'], ['Average time', 'average_seconds'], ['Bounce rate', 'bounce_rate'],
|
||||
] as const);
|
||||
const value = (key: keyof Totals, n: number) => (key === 'average_seconds' ? `${Math.floor(n / 60)}:${String(n % 60).padStart(2, '0')}` : key === 'bounce_rate' ? `${n}%` : n.toLocaleString());
|
||||
const change = (key: keyof Totals) => {
|
||||
const before = props.previous?.[key];
|
||||
|
||||
return before ? Math.round(((props.totals[key] - before) / before) * 100) : null;
|
||||
};
|
||||
const top = computed(() => Math.max(1, ...props.series.map((s) => s.visits)));
|
||||
const heat = computed(() => Math.max(1, ...props.heatmap.flatMap((row) => row.hours)));
|
||||
const lists = computed(() => [
|
||||
['Channels', props.channels], ['Sources', props.sources], ['Countries', props.countries], ['Devices', props.devices], ['Browsers', props.browsers], ['Systems', props.systems],
|
||||
] as const);
|
||||
const rangeLink = (key: string) => `${boot.base}/statistics?range=${key}`;
|
||||
const csv = (sheet: string) => `${boot.base}/statistics/export?sheet=${sheet}&range=${new URLSearchParams(state.path.split('?')[1] ?? '').get('range') ?? props.range.key}`;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
|
||||
<h1 class="font-display text-2xl font-bold">{{ t('Statistics') }}</h1>
|
||||
<p class="text-sm text-muted">{{ range.from }} → {{ range.to }}<span v-if="range.compared_to"> · {{ t('compared with') }} {{ range.compared_to }}</span></p>
|
||||
</div>
|
||||
|
||||
<nav class="mb-6 flex flex-wrap gap-2">
|
||||
<Link v-for="item in ranges" :key="item.key" :href="rangeLink(item.key)" class="m-btn" :class="range.key === item.key ? 'm-btn-primary' : 'm-btn-secondary'">{{ item.label }}</Link>
|
||||
</nav>
|
||||
|
||||
<div class="mb-6 grid grid-cols-2 gap-3 md:grid-cols-5">
|
||||
<div v-for="[label, key] in tiles" :key="key" class="m-card p-4">
|
||||
<p class="text-2xl font-bold">{{ value(key, totals[key]) }}</p>
|
||||
<p class="m-help">{{ t(label) }}<span v-if="change(key) !== null" :class="(change(key) ?? 0) >= 0 ? 'text-emerald-500' : 'text-red-500'"> {{ (change(key) ?? 0) > 0 ? '+' : '' }}{{ change(key) }}%</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="m-card mb-6 p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t('Visits') }}</h2>
|
||||
<div class="flex h-40 items-end gap-px" role="img" :aria-label="t('Visits')">
|
||||
<div v-for="point in series" :key="point.key" class="min-w-px flex-1 rounded-t bg-brand" :style="{ height: Math.max(2, (point.visits / top) * 100) + '%' }" :title="`${point.label}: ${point.visits}`" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="mb-6 grid gap-6 md:grid-cols-2">
|
||||
<section class="m-card p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t('Pages') }}</h2>
|
||||
<p v-if="!pages.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul class="divide-y divide-line text-sm"><li v-for="row in pages" :key="row.path" class="flex justify-between gap-3 py-1.5"><span class="truncate">{{ row.title ?? row.path }}</span><span class="text-muted">{{ row.views }}</span></li></ul>
|
||||
</section>
|
||||
<section class="m-card p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t('Posts') }}</h2>
|
||||
<p v-if="!posts.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul class="divide-y divide-line text-sm"><li v-for="row in posts" :key="row.slug" class="flex justify-between gap-3 py-1.5"><span class="truncate">{{ row.title }}</span><span class="text-muted">{{ row.views }}</span></li></ul>
|
||||
</section>
|
||||
<section v-for="[title, rows] in lists" :key="title" class="m-card p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t(title) }}</h2>
|
||||
<p v-if="!rows.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul class="divide-y divide-line text-sm"><li v-for="row in rows" :key="row.name + (row.channel ?? '')" class="flex justify-between gap-3 py-1.5"><span class="truncate">{{ row.name || t('Direct') }}</span><span class="text-muted">{{ row.visits }}</span></li></ul>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="m-card mb-6 overflow-x-auto p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t('When people visit') }}</h2>
|
||||
<div class="space-y-0.5 text-xs">
|
||||
<div v-for="row in heatmap" :key="row.day" class="flex items-center gap-0.5">
|
||||
<span class="w-9 shrink-0 text-muted">{{ row.day }}</span>
|
||||
<span v-for="(n, hour) in row.hours" :key="hour" class="block h-5 min-w-3 flex-1 rounded-sm border border-line" :title="`${row.day} ${hour}:00 · ${n}`" :style="{ background: `color-mix(in srgb, var(--m-brand) ${Math.round((n / heat) * 100)}%, var(--m-panel-2))` }" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="m-card mb-6 p-4">
|
||||
<h2 class="mb-3 font-semibold">{{ t('Programs') }} <span class="text-sm font-normal text-muted">· {{ bots.total }}</span></h2>
|
||||
<p v-if="!bots.names.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
|
||||
<ul class="divide-y divide-line text-sm"><li v-for="row in bots.names" :key="row.name" class="flex justify-between gap-3 py-1.5"><span>{{ row.name }} <span class="text-xs text-muted">{{ row.kind }}</span></span><span class="text-muted">{{ row.hits }}</span></li></ul>
|
||||
</section>
|
||||
|
||||
<p class="flex flex-wrap items-center gap-2 text-sm">
|
||||
<span class="text-muted">{{ t('Download') }}:</span>
|
||||
<a v-for="(label, sheet) in exports" :key="sheet" :href="csv(String(sheet))" class="m-btn m-btn-secondary">{{ label }} (CSV)</a>
|
||||
</p>
|
||||
</template>
|
||||
+16
-2
@@ -7,15 +7,29 @@ import Login from './pages/Login.vue';
|
||||
import PostForm from './pages/PostForm.vue';
|
||||
import PostsIndex from './pages/PostsIndex.vue';
|
||||
import Profile from './pages/Profile.vue';
|
||||
import AccountsIndex from './pages/AccountsIndex.vue';
|
||||
import GroupsIndex from './pages/GroupsIndex.vue';
|
||||
import LabelsIndex from './pages/LabelsIndex.vue';
|
||||
import MediaLibrary from './pages/MediaLibrary.vue';
|
||||
import AuditLog from './pages/AuditLog.vue';
|
||||
import StatisticsReport from './pages/StatisticsReport.vue';
|
||||
import ListPage from './pages/ListPage.vue';
|
||||
|
||||
/** The screens that exist. Every other manager address shows `Fallback` until its module gets a screen. */
|
||||
const routes: { pattern: RegExp; component: any; guest?: boolean; data?: boolean }[] = [
|
||||
const routes: { pattern: RegExp; component: any; guest?: boolean; data?: boolean; source?: string }[] = [
|
||||
{ pattern: /^\/?$/, component: Dashboard, data: true },
|
||||
{ pattern: /^\/login$/, component: Login, guest: true },
|
||||
{ pattern: /^\/profile$/, component: Profile, data: true },
|
||||
{ pattern: /^\/posts$/, component: PostsIndex, data: true },
|
||||
{ pattern: /^\/posts\/create$/, component: PostForm, data: true },
|
||||
{ pattern: /^\/posts\/\d+\/edit$/, component: PostForm, data: true },
|
||||
{ pattern: /^\/media$/, component: MediaLibrary, data: true, source: '/media/items' },
|
||||
{ pattern: /^\/audit$/, component: AuditLog, data: true },
|
||||
{ pattern: /^\/statistics$/, component: StatisticsReport, data: true },
|
||||
{ pattern: /^\/accounts$/, component: AccountsIndex, data: true },
|
||||
{ pattern: /^\/groups$/, component: GroupsIndex, data: true },
|
||||
{ pattern: /^\/labels$/, component: LabelsIndex, data: true },
|
||||
{ pattern: /^\/(pages|reviews)$/, component: ListPage, data: true },
|
||||
];
|
||||
|
||||
export const state = reactive({
|
||||
@@ -60,7 +74,7 @@ export async function load(url: string): Promise<void> {
|
||||
state.props = {};
|
||||
|
||||
try {
|
||||
state.props = route?.data ? await api.get(url) : {};
|
||||
state.props = route?.data ? await api.get(route.source ? boot.base + route.source : url) : {};
|
||||
} catch (error) {
|
||||
if (error instanceof ApiError && error.status === 401) {
|
||||
window.location.assign(boot.base + '/login');
|
||||
|
||||
Reference in new issue
Block a user