This commit is contained in:
Sven Steinert
2026-05-04 19:20:22 +02:00
parent fce31ebcd7
commit ec97e1097c
1254 changed files with 421 additions and 174285 deletions

View File

@@ -25,6 +25,8 @@
this.root = root;
this.template = null;
this.dragIndex = -1;
this.gitlabTemplatePath = "";
this.gitlabTemplateModule = "";
this.storageKey = "obyteQaToolState:" + window.location.pathname;
this.els = this.collectElements();
this.init();
@@ -128,11 +130,15 @@
self.loadGitlabTemplate(event.target.value);
});
bind(this.els.addStep, "click", function () {
bind(this.els.addStep, "click", function (event) {
event.preventDefault();
event.stopImmediatePropagation();
self.addStep();
});
bind(this.els.addGroup, "click", function () {
bind(this.els.addGroup, "click", function (event) {
event.preventDefault();
event.stopImmediatePropagation();
self.addGroup();
});
@@ -274,13 +280,15 @@
QaTool.prototype.loadGitlabTemplate = async function (path) {
if (!path) {
this.gitlabTemplatePath = "";
this.gitlabTemplateModule = "";
return;
}
try {
this.setTag(this.els.gitlabTplStatus, "GitLab: lade Datei", "");
var data = await this.api("template?path=" + encodeURIComponent(path));
this.loadTemplateText(data.content || "", path.split("/").pop());
this.loadTemplateText(data.content || "", path.split("/").pop(), data.path || path);
this.setTag(this.els.gitlabTplStatus, "GitLab: geladen", "ok");
} catch (error) {
this.setTag(this.els.gitlabTplStatus, "GitLab: Fehler", "bad");
@@ -305,10 +313,12 @@
}
};
QaTool.prototype.loadTemplateText = function (text, fallbackName) {
QaTool.prototype.loadTemplateText = function (text, fallbackName, sourcePath) {
var parsed = parseTemplateText(text);
var normalized = normalizeTemplate(parsed, fallbackName || "Template");
this.template = normalized;
this.gitlabTemplatePath = sourcePath || "";
this.gitlabTemplateModule = sourcePath ? (normalized.module || "") : "";
if (this.els.tplName) {
this.els.tplName.textContent = normalized.name || fallbackName || "Template";
@@ -440,7 +450,9 @@
return;
}
var rows = Array.prototype.slice.call(this.els.stepsTableBody.querySelectorAll("tr"));
var rows = Array.prototype.slice.call(this.els.stepsTableBody.querySelectorAll("tr")).filter(function (row) {
return !row.classList.contains("oqt-empty-row");
});
this.template.steps = rows.map(function (row, index) {
var kind = row.dataset.kind || "step";
if (kind === "group") {
@@ -474,6 +486,8 @@
pbx_version: config.defaultPbxVersion || "",
steps: []
};
this.gitlabTemplatePath = "";
this.gitlabTemplateModule = "";
if (this.els.tplName) {
this.els.tplName.textContent = this.template.name;
}
@@ -481,8 +495,11 @@
};
QaTool.prototype.addStep = function () {
var hadTemplate = !!this.template;
this.ensureTemplate();
this.captureEditsIntoTemplate();
if (hadTemplate) {
this.captureEditsIntoTemplate();
}
this.template.steps.push({
kind: "step",
id: "",
@@ -499,8 +516,11 @@
};
QaTool.prototype.addGroup = function () {
var hadTemplate = !!this.template;
this.ensureTemplate();
this.captureEditsIntoTemplate();
if (hadTemplate) {
this.captureEditsIntoTemplate();
}
this.template.steps.push({
kind: "group",
title: "Neue Gruppe",
@@ -882,6 +902,8 @@
pbx_version: run.pbx_version || "",
steps: run.steps
}, file.name);
this.gitlabTemplatePath = "";
this.gitlabTemplateModule = "";
if (this.els.tplName) {
this.els.tplName.textContent = run.name || file.name;
@@ -1251,8 +1273,8 @@
if (data.report_id) {
parts.push("Report-ID: " + data.report_id);
}
if (data.pdf_url) {
parts.push('<a href="' + escAttr(data.pdf_url) + '" target="_blank" rel="noopener">PDF in Mediathek öffnen</a>');
if (data.pdf_stored) {
parts.push("PDF geschuetzt gespeichert");
}
if (data.docbee && data.docbee.ok) {
var docbeeLink = data.docbee.url ? ' <a href="' + escAttr(data.docbee.url) + '" target="_blank" rel="noopener">DocBee öffnen</a>' : "";
@@ -1295,11 +1317,16 @@
button.classList.add("is-busy");
}
this.showMessage("GitLab: Template wird geschrieben...", "");
var sourcePath = this.gitlabTemplatePath && sameModuleName(template.module, this.gitlabTemplateModule)
? this.gitlabTemplatePath
: "";
var data = await this.api("gitlab/template", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ template: template, yaml: yaml })
body: JSON.stringify({ template: template, yaml: yaml, source_path: sourcePath })
});
this.gitlabTemplatePath = data.path || sourcePath || "";
this.gitlabTemplateModule = template.module || "";
this.showMessage("GitLab: Template gespeichert: " + (data.path || ""), "ok");
} catch (error) {
this.showMessage("GitLab-Push fehlgeschlagen: " + error.message, "bad");
@@ -1800,6 +1827,10 @@
.replace(/[^\w.-]/g, "") || "qa";
}
function sameModuleName(left, right) {
return String(left || "").trim() === String(right || "").trim();
}
function mdCell(valueToEscape) {
return String(valueToEscape || "").replace(/\|/g, "\\|").replace(/\n/g, " ");
}