Nextcloud, NetBox and n8n integrations
Three read-only integrations, each with a monitoring page, alerts, maintenance silencing and held-when-unreadable handling. Nextcloud: database needing upgrade (critical), maintenance mode, and the data disk running low; users, files and app updates with an admin app password. NetBox: no background worker running, counts, and a list of the servers this app manages that have no address in NetBox (a list, not an alert). n8n: an active workflow whose last run failed, clearing when it next succeeds. Disk messages for Immich, Paperless and Nextcloud now use the same units as the pages that show them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a16996d975
commit
4ff0b44943
46 files changed
+10137
-10
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { Router } from "express";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../db/client.js";
|
||||
import { integrations, nextcloudState } from "../db/schema.js";
|
||||
import { requireAuth } from "../auth/middleware.js";
|
||||
import { isNextcloudFresh, nextcloudProblems, nextcloudSyncStatuses } from "../services/nextcloudSync.js";
|
||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||
|
||||
export const nextcloudRouter = Router();
|
||||
nextcloudRouter.use(requireAuth);
|
||||
|
||||
/** Every Nextcloud, how it is, from what the last read stored: maintenance mode, the data disk, the users, the app updates and what is wrong. Everyone signed in can see it, like the other pages made of stored readings. */
|
||||
nextcloudRouter.get("/", asyncHandler(async (_req, res) => {
|
||||
const [rows, states, statuses] = await Promise.all([
|
||||
db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "nextcloud")).orderBy(integrations.name),
|
||||
db.select().from(nextcloudState),
|
||||
nextcloudSyncStatuses(),
|
||||
]);
|
||||
const byId = new Map(states.map((s) => [s.integrationId, s]));
|
||||
const now = Date.now();
|
||||
res.json({
|
||||
nextclouds: rows.map((r) => {
|
||||
const state = byId.get(r.id) ?? null;
|
||||
const status = statuses[r.id] ?? null;
|
||||
const fresh = isNextcloudFresh(status ?? undefined, now);
|
||||
return {
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
enabled: r.enabled,
|
||||
status,
|
||||
fresh,
|
||||
state: state
|
||||
? {
|
||||
version: state.version,
|
||||
maintenance: state.maintenance,
|
||||
needsUpgrade: state.needsUpgrade,
|
||||
detail: state.detail,
|
||||
freeBytes: state.freeBytes,
|
||||
users: state.users,
|
||||
files: state.files,
|
||||
active24h: state.active24h,
|
||||
appUpdates: state.appUpdates,
|
||||
updatedAt: state.updatedAt,
|
||||
}
|
||||
: null,
|
||||
problems: state && fresh ? nextcloudProblems(r.id, r.name, state) : [],
|
||||
};
|
||||
}),
|
||||
});
|
||||
}));
|
||||
Reference in new issue
Block a user