Projektseite wie Plancraft, Zahlungsplan automatisch, Spaltenbreiten im Terminplan (0.6.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
This commit is contained in:
@@ -8,6 +8,13 @@ export interface NextcloudZugang {
|
||||
passwort: string;
|
||||
}
|
||||
|
||||
export interface AblageEintrag {
|
||||
name: string;
|
||||
ordner: boolean;
|
||||
groesse: number;
|
||||
geaendert: string | null;
|
||||
}
|
||||
|
||||
export const STATUSORDNER: Record<string, string> = {
|
||||
anfrage: "01 Angebot",
|
||||
angebot: "01 Angebot",
|
||||
@@ -66,6 +73,37 @@ export class Nextcloud {
|
||||
.map((h) => h.slice(decodeURIComponent(basis).length + 1));
|
||||
}
|
||||
|
||||
/** Inhalt eines Ordners mit Art, Größe und Änderungsdatum, Ordner zuerst (Ablage auf der Projektseite) */
|
||||
async inhalt(pfad: string): Promise<AblageEintrag[] | null> {
|
||||
const r = await this.anfrage("PROPFIND", pfad, { depth: "1" });
|
||||
if (r.status === 404) return null;
|
||||
if (r.status !== 207) throw new Error(`Nextcloud antwortet mit ${r.status} für ${pfad}`);
|
||||
const xml = await r.text();
|
||||
const basis = decodeURIComponent(new URL(this.adresse(pfad)).pathname.replace(/\/+$/, ""));
|
||||
const eintraege: AblageEintrag[] = [];
|
||||
for (const m of xml.matchAll(/<d:response>([\s\S]*?)<\/d:response>/gi)) {
|
||||
const teil = m[1]!;
|
||||
const href = decodeURIComponent(/<d:href>([^<]+)<\/d:href>/i.exec(teil)?.[1] ?? "").replace(/\/+$/, "");
|
||||
if (href === basis || !href.startsWith(basis + "/")) continue;
|
||||
const wert = (tag: string) => new RegExp(`<d:${tag}>([^<]*)</d:${tag}>`, "i").exec(teil)?.[1];
|
||||
eintraege.push({
|
||||
name: href.slice(basis.length + 1),
|
||||
ordner: /<d:collection\s*\/>/i.test(teil),
|
||||
groesse: Number(wert("getcontentlength") ?? 0),
|
||||
geaendert: wert("getlastmodified") ? new Date(wert("getlastmodified")!).toISOString() : null,
|
||||
});
|
||||
}
|
||||
return eintraege.sort((a, b) => Number(b.ordner) - Number(a.ordner) || a.name.localeCompare(b.name, "de"));
|
||||
}
|
||||
|
||||
/** Eine Datei abrufen, um sie durchzureichen */
|
||||
async datei(pfad: string): Promise<Response> {
|
||||
const r = await this.anfrage("GET", pfad);
|
||||
if (r.status === 404) throw Object.assign(new Error("Datei nicht gefunden"), { statusCode: 404 });
|
||||
if (!r.ok) throw new Error(`Nextcloud antwortet mit ${r.status} für ${pfad}`);
|
||||
return r;
|
||||
}
|
||||
|
||||
async ordner(pfad: string): Promise<void> {
|
||||
const r = await this.anfrage("MKCOL", pfad);
|
||||
if (!(r.status === 201 || r.status === 405)) throw new Error(`Ordner ${pfad} ließ sich nicht anlegen (${r.status})`);
|
||||
|
||||
Reference in New Issue
Block a user