Loading client/localapi.cpp +26 −0 Changes for client/localapi.cpp: 26 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -367,6 +367,32 @@ void LocalApi::fetchThemeColors() { }); } void LocalApi::fetchSurveyList() { QJsonArray cmds; QJsonObject cmd; cmd["command"] = "list_surveys"; cmds.append(cmd); _pub->apiRequest(cmds, [this](bool ok, const QJsonArray &resp) { if (!ok) { emit statusMessage("Failed to fetch survey list"); return; } for (int i = 0; i < resp.size(); ++i) { QJsonObject obj = resp.at(i).toObject(); if (obj.contains("surveys")) { QJsonArray surveys = obj["surveys"].toArray(); QJsonArray names; for (int j = 0; j < surveys.size(); ++j) names.append(surveys.at(j).toString()); emit surveyListLoaded(QString::fromUtf8(QJsonDocument(names).toJson(QJsonDocument::Compact))); return; } } emit surveyListLoaded("[]"); }); } void LocalApi::publishToTarget(const QString &target, const QString ¶msJson) { if (!_pub->isConfigured()) { emit publishCompleted(false, "Not connected"); Loading client/localapi.h +4 −0 Changes for client/localapi.h: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -74,6 +74,9 @@ public: /* Theme colors (requires connection) */ Q_INVOKABLE void fetchThemeColors(); /* Survey list (requires connection) */ Q_INVOKABLE void fetchSurveyList(); /* Publish (requires connection) */ Q_INVOKABLE void fetchPublishTargets(); Q_INVOKABLE void publishToTarget(const QString &target, const QString ¶msJson); Loading Loading @@ -113,6 +116,7 @@ signals: void publishTargetsLoaded(const QString &json); void publishCompleted(bool ok, const QString &msg); void themeColorsLoaded(const QString &json); void surveyListLoaded(const QString &json); void savedConnectionsChanged(); private: Loading client/qml/PropertyPanel.qml +205 −2 Changes for client/qml/PropertyPanel.qml: 205 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ ColumnLayout { _debounceTimer = timer } function fetchSurveyList(fieldKey, currentValue) { localApi.fetchSurveyList() } /* No selection placeholder */ Label { visible: currentUuid === "" Loading Loading @@ -126,7 +130,7 @@ ColumnLayout { /* text / number */ TextField { visible: !["richtext","select","checkbox","color","textarea","image"].includes(field.type) visible: !["richtext","select","checkbox","color","color_var","textarea","image","media_browse","survey_select"].includes(field.type) && !field.key.endsWith("_src") && field.key !== "media_id" Layout.fillWidth: true text: val Loading @@ -138,7 +142,7 @@ ColumnLayout { /* image / media URL field with browse button */ RowLayout { visible: field.type === "image" || field.key.endsWith("_src") || field.key === "media_id" visible: (field.type === "image" || field.key.endsWith("_src")) && field.type !== "media_browse" && field.key !== "media_id" Layout.fillWidth: true spacing: 4 Loading Loading @@ -253,6 +257,186 @@ ColumnLayout { onTextChanged: propPanel.debounceSave(field.key, text) } } /* color_var — three modes: none / theme variable / custom RGBA */ ColumnLayout { visible: field.type === "color_var" Layout.fillWidth: true spacing: 4 property string cvMode: { var v = String(val) if (!v || v === "") return "none" if (v.startsWith("var(")) return "theme" return "custom" } ComboBox { id: cvModeCombo Layout.fillWidth: true font.pixelSize: 12 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary model: [ { text: "None (default)", value: "none" }, { text: "Theme Variable", value: "theme" }, { text: "Custom RGBA", value: "custom" } ] textRole: "text" valueRole: "value" currentIndex: parent.cvMode === "theme" ? 1 : (parent.cvMode === "custom" ? 2 : 0) background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onActivated: { if (currentValue === "none") { propPanel.saveProperty(field.key, "") propPanel.loadProperties(propPanel.currentUuid) } } } /* Theme variable selector */ ComboBox { visible: cvModeCombo.currentValue === "theme" Layout.fillWidth: true font.pixelSize: 12 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary model: [ "--blogi-bg", "--blogi-surface", "--blogi-surface-a", "--blogi-text", "--blogi-text-muted", "--blogi-accent", "--blogi-accent-dark", "--blogi-border", "--blogi-bg-alt", "--blogi-error", "--blogi-success-bg", "--blogi-success-text", "--blogi-nav-active", "--blogi-nav-hover", "--blogi-nav-border" ] background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } currentIndex: { var v = String(val) var varName = v.replace("var(", "").replace(")", "") for (var i = 0; i < model.length; i++) if (model[i] === varName) return i return 0 } onActivated: { propPanel.saveProperty(field.key, "var(" + model[currentIndex] + ")") propPanel.loadProperties(propPanel.currentUuid) } } /* Custom RGBA: swatch + picker */ RowLayout { visible: cvModeCombo.currentValue === "custom" Layout.fillWidth: true spacing: 8 Rectangle { width: 28; height: 28; radius: Theme.radius color: { var v = String(val) if (v && !v.startsWith("var(") && v !== "") return v return "#ffffff" } border.color: Theme.border MouseArea { anchors.fill: parent onClicked: { colorDialogLoader.fieldKey = field.key colorDialogLoader.initialColor = parent.color colorDialogLoader.active = true colorDialogLoader.item.open() } } } TextField { text: val || "" font.pixelSize: 12; color: Theme.textPrimary Layout.fillWidth: true background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onTextEdited: propPanel.debounceSave(field.key, text) } } } /* media_browse — file picker via MediaDB (for video src etc.) */ RowLayout { visible: field.type === "media_browse" || field.key === "media_id" Layout.fillWidth: true spacing: 4 TextField { id: mediaBrowseField Layout.fillWidth: true text: val font.pixelSize: 13; color: Theme.textPrimary placeholderText: qsTr("Browse media...") background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onTextEdited: propPanel.debounceSave(field.key, text) } Button { text: "..." implicitWidth: 32; implicitHeight: 28 background: Rectangle { color: parent.hovered ? Theme.bgHover : Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } contentItem: Text { text: parent.text; color: Theme.textPrimary; font.pixelSize: 13; font.bold: true; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter } onClicked: { mediaBrowserLoader.fieldKey = field.key mediaBrowserLoader.targetField = mediaBrowseField mediaBrowserLoader.active = true mediaBrowserLoader.item.open() } } } /* survey_select — fetch list from server and pick */ ColumnLayout { visible: field.type === "survey_select" Layout.fillWidth: true spacing: 4 RowLayout { Layout.fillWidth: true spacing: 4 ComboBox { id: surveyCombo Layout.fillWidth: true font.pixelSize: 13 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary textRole: "text" model: ListModel { id: surveyListModel } background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onActivated: { if (currentIndex >= 0) { var item = surveyListModel.get(currentIndex) if (item) propPanel.saveProperty(field.key, item.text) } } Component.onCompleted: propPanel.fetchSurveyList(field.key, val) } Button { text: "⟳" implicitWidth: 32; implicitHeight: 28 background: Rectangle { color: parent.hovered ? Theme.bgHover : Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } contentItem: Text { text: parent.text; color: Theme.textPrimary; font.pixelSize: 13; font.bold: true; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter } onClicked: propPanel.fetchSurveyList(field.key, val) } } TextField { Layout.fillWidth: true text: val font.pixelSize: 11; color: Theme.textMuted placeholderText: qsTr("or type survey name manually") background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onTextEdited: propPanel.debounceSave(field.key, text) } } } } Loading Loading @@ -333,4 +517,23 @@ ColumnLayout { onRejected: mediaBrowserLoader.active = false } } /* ---- Survey list signal handler ---- */ Connections { target: localApi function onSurveyListLoaded(json) { var list = JSON.parse(json) surveyListModel.clear() for (var i = 0; i < list.length; i++) surveyListModel.append({"text": list[i]}) // Re-select current value var curVal = propPanel.currentProps["survey_name"] || "" for (var j = 0; j < surveyListModel.count; j++) { if (surveyListModel.get(j).text === curVal) { surveyCombo.currentIndex = j break } } } } } client/widgets/survey/survey.cpp +1 −1 Changes for client/widgets/survey/survey.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ extern "C" { if (responsive) json_object_object_add(f, "responsive", json_object_new_boolean(true)); json_object_array_add(arr, f); }; addField("survey_name", "Survey Name", "text", "kundenzufriedenheit"); addField("survey_name", "Survey Name", "survey_select", "kundenzufriedenheit"); addField("survey_title", "Display Title", "text", "Ihre Meinung"); addField("width", "Width", "text", "e.g. 100%", true); addField("height", "Height", "text", "e.g. auto", true); Loading plugins/survey/survey.cpp +27 −0 Changes for plugins/survey/survey.cpp: 27 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -163,6 +163,33 @@ namespace blogi { return settingsIndex(tid, req); } // ----- JSON API (called from /api) ----- void JsonApi(const int tid, json_object *request, json_object *response, const uuid::uuid &authid) override { json_object *cmd_obj = nullptr; if (!json_object_object_get_ex(request, "command", &cmd_obj)) return; const char *command = json_object_get_string(cmd_obj); if (!command) return; if (strcmp(command, "list_surveys") == 0) { json_object *surveys = json_object_new_array(); try { dbpp::SQL sql; dbpp::DBResult res; sql << "SELECT name FROM survey_templates ORDER BY name"; int n = Args->database[tid]->exec(sql, res); for (int si = 0; si < n; si++) { if (res[si][0]) json_object_array_add(surveys, json_object_new_string(res[si][0])); } } catch (...) { std::cerr << "list_surveys: DB error" << std::endl; } json_object_object_add(response, "status", json_object_new_string("success")); json_object_object_add(response, "surveys", surveys); } } // ----- Controller ----- bool Controller(const int tid, libhttppp::HttpRequest &req, libhtmlpp::HtmlElement *page, const std::string &sessionid) { Loading Loading
client/localapi.cpp +26 −0 Changes for client/localapi.cpp: 26 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -367,6 +367,32 @@ void LocalApi::fetchThemeColors() { }); } void LocalApi::fetchSurveyList() { QJsonArray cmds; QJsonObject cmd; cmd["command"] = "list_surveys"; cmds.append(cmd); _pub->apiRequest(cmds, [this](bool ok, const QJsonArray &resp) { if (!ok) { emit statusMessage("Failed to fetch survey list"); return; } for (int i = 0; i < resp.size(); ++i) { QJsonObject obj = resp.at(i).toObject(); if (obj.contains("surveys")) { QJsonArray surveys = obj["surveys"].toArray(); QJsonArray names; for (int j = 0; j < surveys.size(); ++j) names.append(surveys.at(j).toString()); emit surveyListLoaded(QString::fromUtf8(QJsonDocument(names).toJson(QJsonDocument::Compact))); return; } } emit surveyListLoaded("[]"); }); } void LocalApi::publishToTarget(const QString &target, const QString ¶msJson) { if (!_pub->isConfigured()) { emit publishCompleted(false, "Not connected"); Loading
client/localapi.h +4 −0 Changes for client/localapi.h: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -74,6 +74,9 @@ public: /* Theme colors (requires connection) */ Q_INVOKABLE void fetchThemeColors(); /* Survey list (requires connection) */ Q_INVOKABLE void fetchSurveyList(); /* Publish (requires connection) */ Q_INVOKABLE void fetchPublishTargets(); Q_INVOKABLE void publishToTarget(const QString &target, const QString ¶msJson); Loading Loading @@ -113,6 +116,7 @@ signals: void publishTargetsLoaded(const QString &json); void publishCompleted(bool ok, const QString &msg); void themeColorsLoaded(const QString &json); void surveyListLoaded(const QString &json); void savedConnectionsChanged(); private: Loading
client/qml/PropertyPanel.qml +205 −2 Changes for client/qml/PropertyPanel.qml: 205 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ ColumnLayout { _debounceTimer = timer } function fetchSurveyList(fieldKey, currentValue) { localApi.fetchSurveyList() } /* No selection placeholder */ Label { visible: currentUuid === "" Loading Loading @@ -126,7 +130,7 @@ ColumnLayout { /* text / number */ TextField { visible: !["richtext","select","checkbox","color","textarea","image"].includes(field.type) visible: !["richtext","select","checkbox","color","color_var","textarea","image","media_browse","survey_select"].includes(field.type) && !field.key.endsWith("_src") && field.key !== "media_id" Layout.fillWidth: true text: val Loading @@ -138,7 +142,7 @@ ColumnLayout { /* image / media URL field with browse button */ RowLayout { visible: field.type === "image" || field.key.endsWith("_src") || field.key === "media_id" visible: (field.type === "image" || field.key.endsWith("_src")) && field.type !== "media_browse" && field.key !== "media_id" Layout.fillWidth: true spacing: 4 Loading Loading @@ -253,6 +257,186 @@ ColumnLayout { onTextChanged: propPanel.debounceSave(field.key, text) } } /* color_var — three modes: none / theme variable / custom RGBA */ ColumnLayout { visible: field.type === "color_var" Layout.fillWidth: true spacing: 4 property string cvMode: { var v = String(val) if (!v || v === "") return "none" if (v.startsWith("var(")) return "theme" return "custom" } ComboBox { id: cvModeCombo Layout.fillWidth: true font.pixelSize: 12 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary model: [ { text: "None (default)", value: "none" }, { text: "Theme Variable", value: "theme" }, { text: "Custom RGBA", value: "custom" } ] textRole: "text" valueRole: "value" currentIndex: parent.cvMode === "theme" ? 1 : (parent.cvMode === "custom" ? 2 : 0) background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onActivated: { if (currentValue === "none") { propPanel.saveProperty(field.key, "") propPanel.loadProperties(propPanel.currentUuid) } } } /* Theme variable selector */ ComboBox { visible: cvModeCombo.currentValue === "theme" Layout.fillWidth: true font.pixelSize: 12 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary model: [ "--blogi-bg", "--blogi-surface", "--blogi-surface-a", "--blogi-text", "--blogi-text-muted", "--blogi-accent", "--blogi-accent-dark", "--blogi-border", "--blogi-bg-alt", "--blogi-error", "--blogi-success-bg", "--blogi-success-text", "--blogi-nav-active", "--blogi-nav-hover", "--blogi-nav-border" ] background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } currentIndex: { var v = String(val) var varName = v.replace("var(", "").replace(")", "") for (var i = 0; i < model.length; i++) if (model[i] === varName) return i return 0 } onActivated: { propPanel.saveProperty(field.key, "var(" + model[currentIndex] + ")") propPanel.loadProperties(propPanel.currentUuid) } } /* Custom RGBA: swatch + picker */ RowLayout { visible: cvModeCombo.currentValue === "custom" Layout.fillWidth: true spacing: 8 Rectangle { width: 28; height: 28; radius: Theme.radius color: { var v = String(val) if (v && !v.startsWith("var(") && v !== "") return v return "#ffffff" } border.color: Theme.border MouseArea { anchors.fill: parent onClicked: { colorDialogLoader.fieldKey = field.key colorDialogLoader.initialColor = parent.color colorDialogLoader.active = true colorDialogLoader.item.open() } } } TextField { text: val || "" font.pixelSize: 12; color: Theme.textPrimary Layout.fillWidth: true background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onTextEdited: propPanel.debounceSave(field.key, text) } } } /* media_browse — file picker via MediaDB (for video src etc.) */ RowLayout { visible: field.type === "media_browse" || field.key === "media_id" Layout.fillWidth: true spacing: 4 TextField { id: mediaBrowseField Layout.fillWidth: true text: val font.pixelSize: 13; color: Theme.textPrimary placeholderText: qsTr("Browse media...") background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onTextEdited: propPanel.debounceSave(field.key, text) } Button { text: "..." implicitWidth: 32; implicitHeight: 28 background: Rectangle { color: parent.hovered ? Theme.bgHover : Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } contentItem: Text { text: parent.text; color: Theme.textPrimary; font.pixelSize: 13; font.bold: true; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter } onClicked: { mediaBrowserLoader.fieldKey = field.key mediaBrowserLoader.targetField = mediaBrowseField mediaBrowserLoader.active = true mediaBrowserLoader.item.open() } } } /* survey_select — fetch list from server and pick */ ColumnLayout { visible: field.type === "survey_select" Layout.fillWidth: true spacing: 4 RowLayout { Layout.fillWidth: true spacing: 4 ComboBox { id: surveyCombo Layout.fillWidth: true font.pixelSize: 13 palette.text: Theme.textPrimary palette.buttonText: Theme.textPrimary textRole: "text" model: ListModel { id: surveyListModel } background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onActivated: { if (currentIndex >= 0) { var item = surveyListModel.get(currentIndex) if (item) propPanel.saveProperty(field.key, item.text) } } Component.onCompleted: propPanel.fetchSurveyList(field.key, val) } Button { text: "⟳" implicitWidth: 32; implicitHeight: 28 background: Rectangle { color: parent.hovered ? Theme.bgHover : Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } contentItem: Text { text: parent.text; color: Theme.textPrimary; font.pixelSize: 13; font.bold: true; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter } onClicked: propPanel.fetchSurveyList(field.key, val) } } TextField { Layout.fillWidth: true text: val font.pixelSize: 11; color: Theme.textMuted placeholderText: qsTr("or type survey name manually") background: Rectangle { color: Theme.bgTertiary; border.color: Theme.border; radius: Theme.radius } onTextEdited: propPanel.debounceSave(field.key, text) } } } } Loading Loading @@ -333,4 +517,23 @@ ColumnLayout { onRejected: mediaBrowserLoader.active = false } } /* ---- Survey list signal handler ---- */ Connections { target: localApi function onSurveyListLoaded(json) { var list = JSON.parse(json) surveyListModel.clear() for (var i = 0; i < list.length; i++) surveyListModel.append({"text": list[i]}) // Re-select current value var curVal = propPanel.currentProps["survey_name"] || "" for (var j = 0; j < surveyListModel.count; j++) { if (surveyListModel.get(j).text === curVal) { surveyCombo.currentIndex = j break } } } } }
client/widgets/survey/survey.cpp +1 −1 Changes for client/widgets/survey/survey.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ extern "C" { if (responsive) json_object_object_add(f, "responsive", json_object_new_boolean(true)); json_object_array_add(arr, f); }; addField("survey_name", "Survey Name", "text", "kundenzufriedenheit"); addField("survey_name", "Survey Name", "survey_select", "kundenzufriedenheit"); addField("survey_title", "Display Title", "text", "Ihre Meinung"); addField("width", "Width", "text", "e.g. 100%", true); addField("height", "Height", "text", "e.g. auto", true); Loading
plugins/survey/survey.cpp +27 −0 Changes for plugins/survey/survey.cpp: 27 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -163,6 +163,33 @@ namespace blogi { return settingsIndex(tid, req); } // ----- JSON API (called from /api) ----- void JsonApi(const int tid, json_object *request, json_object *response, const uuid::uuid &authid) override { json_object *cmd_obj = nullptr; if (!json_object_object_get_ex(request, "command", &cmd_obj)) return; const char *command = json_object_get_string(cmd_obj); if (!command) return; if (strcmp(command, "list_surveys") == 0) { json_object *surveys = json_object_new_array(); try { dbpp::SQL sql; dbpp::DBResult res; sql << "SELECT name FROM survey_templates ORDER BY name"; int n = Args->database[tid]->exec(sql, res); for (int si = 0; si < n; si++) { if (res[si][0]) json_object_array_add(surveys, json_object_new_string(res[si][0])); } } catch (...) { std::cerr << "list_surveys: DB error" << std::endl; } json_object_object_add(response, "status", json_object_new_string("success")); json_object_object_add(response, "surveys", surveys); } } // ----- Controller ----- bool Controller(const int tid, libhttppp::HttpRequest &req, libhtmlpp::HtmlElement *page, const std::string &sessionid) { Loading