diff --git a/config_menu.php b/config_menu.php
index 09ca707..74f0d26 100644
--- a/config_menu.php
+++ b/config_menu.php
@@ -41,17 +41,80 @@ function kft_bug_reporter_config_page() {
document.addEventListener("DOMContentLoaded", async function(event) {
// Get the configuration of the Kalifast API
- let config_data = await requestCore("Kalifast_Bug_Reporter", "Reporter", "get_kalifast_api_configuration");
- if(config_data.success) {
- document.getElementById("kft_bug_reporter_url").value = config_data.data.kft_api_host;
- document.getElementById("kft_bug_reporter_api_key").value = config_data.data.kft_api_key;
- document.querySelector(".kft_status").src = "https://kalifast.com/assets/img/devices_enable.png";
- }
+ reloadFields()
+
+
+ document.getElementById("submit_kft_bug_reporter_ticket_config").addEventListener("click", async function() {
+ let response = await requestCore("Kalifast_Bug_Reporter", "Reporter", "set_kalifast_ticket_config", {
+ "ei_pool_id": document.getElementById("kft_bug_reporter_pool").value,
+ "ei_delivery_id": document.getElementById("kft_bug_reporter_delivery").value,
+ "ei_user_id": document.getElementById("kft_bug_reporter_user").value
+ });
+ });
// Set the configuration of the Kalifast API in the form
document.getElementById("submit_kft_bug_reporter_config").addEventListener("click", submitConfigAPIForm);
});
+
+ async function reloadFields() {
+ let config_data = await requestCore("Kalifast_Bug_Reporter", "Reporter", "get_kalifast_api_configuration");
+ if(config_data.success) {
+ document.getElementById("kft_bug_reporter_url").value = config_data.data.api_config.kft_api_host;
+ document.getElementById("kft_bug_reporter_api_key").value = config_data.data.api_config.kft_api_key;
+ if(config_data.data.fields.deliveries && config_data.data.fields.pools && config_data.data.fields.users) {
+ document.querySelector(".kft_status").src = "https://kalifast.com/assets/img/devices_enable.png";
+ } else {
+ document.querySelector(".kft_status").src = "https://kalifast.com/assets/img/devices_not_connected.png";
+ }
+
+ console.log(config_data);
+
+
+
+ // Set the pools
+ let poolSelect = document.getElementById("kft_bug_reporter_pool");
+ poolSelect.innerHTML = "";
+ config_data.data.fields.pools.forEach(pool => {
+ let option = document.createElement("option");
+ option.value = pool.ei_pool_id;
+ option.text = pool.pool_name;
+ poolSelect.appendChild(option);
+ });
+ if(config_data.data.ticket_config) {
+ poolSelect.value = config_data.data.ticket_config.ei_pool_id;
+ }
+
+ // Set the deliveries
+ let deliverySelect = document.getElementById("kft_bug_reporter_delivery");
+ deliverySelect.innerHTML = "";
+ config_data.data.fields.deliveries.forEach(delivery => {
+ let option = document.createElement("option");
+ option.value = delivery.ei_delivery_id;
+ option.text = delivery.delivery_name;
+ deliverySelect.appendChild(option);
+ });
+ if(config_data.data.ticket_config) {
+ deliverySelect.value = config_data.data.ticket_config.ei_delivery_id;
+ }
+
+ // Set the users
+ let userSelect = document.getElementById("kft_bug_reporter_user");
+ userSelect.innerHTML = "";
+ config_data.data.fields.users.forEach(user => {
+ let option = document.createElement("option");
+ option.value = user.ei_user_id;
+ option.text = user.username;
+ userSelect.appendChild(option);
+ });
+ if(config_data.data.ticket_config) {
+ userSelect.value = config_data.data.ticket_config.ei_user_id;
+ }
+
+
+ }
+ }
+
// Config API form behavior
async function submitConfigAPIForm() {
console.log("Form submitted");
@@ -59,23 +122,21 @@ function kft_bug_reporter_config_page() {
"kft_api_host": document.getElementById("kft_bug_reporter_url").value,
"kft_api_key": document.getElementById("kft_bug_reporter_api_key").value,
});
- console.log(response);
+
if(response.success) {
- document.querySelector(".kft_status").src = "https://kalifast.com/assets/img/devices_enable.png";
- } else {
- document.querySelector(".kft_status").src = "https://kalifast.com/assets/img/devices_not_connected.png";
- }
+ reloadFields();
+ }
}
KFT-Bug-Reporter configuration
+
+