From f2c3bd7b77d5aa353a7b3b2e9119c2789f910a3a Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 1 May 2026 18:22:39 -0700 Subject: [PATCH] fix(admin/view): define basePath in plugin IIFE scopes (#9298) The plugin.templ and plugin_lane.templ components use basePath() in their IIFE (Immediately Invoked Function Expression) scopes to handle subdirectory deployments. However, basePath was not defined locally, causing "basePath is not defined" errors when accessing plugin pages. Added local basePath function definitions in both files, matching the pattern from admin.js. This function checks window.__BASE_PATH__ (set by the layout during page initialization) and prepends it to API paths. --- weed/admin/view/app/plugin.templ | 4 ++++ weed/admin/view/app/plugin_lane.templ | 4 ++++ weed/admin/view/app/plugin_lane_templ.go | 2 +- weed/admin/view/app/plugin_templ.go | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/weed/admin/view/app/plugin.templ b/weed/admin/view/app/plugin.templ index 46213490c..3ea0e00dd 100644 --- a/weed/admin/view/app/plugin.templ +++ b/weed/admin/view/app/plugin.templ @@ -597,6 +597,10 @@ templ Plugin(page string, initialJob string, lane string) { var pluginLane = String(page.getAttribute('data-plugin-lane') || '').trim(); + function basePath(path) { + return (window.__BASE_PATH__ || '') + path; + } + var state = { selectedJobType: '', jobTypes: [], diff --git a/weed/admin/view/app/plugin_lane.templ b/weed/admin/view/app/plugin_lane.templ index 544ef9452..ea49e2b31 100644 --- a/weed/admin/view/app/plugin_lane.templ +++ b/weed/admin/view/app/plugin_lane.templ @@ -80,6 +80,10 @@ templ PluginLane(page string, lane string) { const lane = page.dataset.pluginLane || ''; if (!lane) return; + function basePath(path) { + return (window.__BASE_PATH__ || '') + path; + } + function fetchAndRender(url, containerId, renderFn) { fetch(basePath(url)) .then(r => r.json()) diff --git a/weed/admin/view/app/plugin_lane_templ.go b/weed/admin/view/app/plugin_lane_templ.go index 241ba3523..614dd28f8 100644 --- a/weed/admin/view/app/plugin_lane_templ.go +++ b/weed/admin/view/app/plugin_lane_templ.go @@ -85,7 +85,7 @@ func PluginLane(page string, lane string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " scheduling lane.

All Workers
Lane Scheduler Status
Loading scheduler status...
Job Types
Loading job types...
Connected Workers
Loading workers...
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, " scheduling lane.

All Workers
Lane Scheduler Status
Loading scheduler status...
Job Types
Loading job types...
Connected Workers
Loading workers...
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/weed/admin/view/app/plugin_templ.go b/weed/admin/view/app/plugin_templ.go index 92d064d48..3a2ed0622 100644 --- a/weed/admin/view/app/plugin_templ.go +++ b/weed/admin/view/app/plugin_templ.go @@ -104,7 +104,7 @@ func Plugin(page string, initialJob string, lane string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "

Workers

0

Active Jobs

0

Activities (recent)

0

Next Run

-

Per Job Type Summary
Job TypeActive JobsRecent Activities
Loading...
Scheduler State
Sequential scheduler with per-job runtime limits
Job TypeEnabledDetectorIn FlightMax RuntimeExec GlobalExec/WorkerExecutor WorkersEffective ExecLast Run
Loading...
Workers
WorkerAddressCapabilitiesLoad
Loading...
Job Type Configuration
Not loaded
Selected Job Type
-
Descriptor
Select a job type to load schema and config.
Admin Config Form
No admin form loaded.
Worker Config Form
No worker form loaded.
Job Scheduling Settings
How often to check for new work.
Per-attempt deadline for one job. Size-aware tasks may extend this automatically.
Next Run
Scheduler
-
Not scheduled
Run History
Keep last 10 success + last 10 errors
Successful Runs
TimeJob IDWorkerDuration
No data
Error Runs
TimeJob IDWorkerError
No data
Detection Results
Run detection to see proposals.
Job Queue
States: pending/assigned/running
Job IDTypeStateProgressWorkerUpdatedMessage
Loading...
Detection Jobs
Detection activities for selected job type
TimeJob TypeRequest IDWorkerStageSourceMessage
Loading...
Execution Jobs
Job IDTypeStateProgressWorkerUpdatedMessage
Loading...
Execution Activities
Non-detection events only
TimeJob TypeJob IDSourceStageMessage
Loading...
Job Detail
Select a job to view details.
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "

Workers

0

Active Jobs

0

Activities (recent)

0

Next Run

-

Per Job Type Summary
Job TypeActive JobsRecent Activities
Loading...
Scheduler State
Sequential scheduler with per-job runtime limits
Job TypeEnabledDetectorIn FlightMax RuntimeExec GlobalExec/WorkerExecutor WorkersEffective ExecLast Run
Loading...
Workers
WorkerAddressCapabilitiesLoad
Loading...
Job Type Configuration
Not loaded
Selected Job Type
-
Descriptor
Select a job type to load schema and config.
Admin Config Form
No admin form loaded.
Worker Config Form
No worker form loaded.
Job Scheduling Settings
How often to check for new work.
Per-attempt deadline for one job. Size-aware tasks may extend this automatically.
Next Run
Scheduler
-
Not scheduled
Run History
Keep last 10 success + last 10 errors
Successful Runs
TimeJob IDWorkerDuration
No data
Error Runs
TimeJob IDWorkerError
No data
Detection Results
Run detection to see proposals.
Job Queue
States: pending/assigned/running
Job IDTypeStateProgressWorkerUpdatedMessage
Loading...
Detection Jobs
Detection activities for selected job type
TimeJob TypeRequest IDWorkerStageSourceMessage
Loading...
Execution Jobs
Job IDTypeStateProgressWorkerUpdatedMessage
Loading...
Execution Activities
Non-detection events only
TimeJob TypeJob IDSourceStageMessage
Loading...
Job Detail
Select a job to view details.
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }