diff --git a/front/deviceDetails.php b/front/deviceDetails.php
index 26d58d45..36a77b85 100755
--- a/front/deviceDetails.php
+++ b/front/deviceDetails.php
@@ -416,12 +416,9 @@ async function renderSmallBoxes() {
showSpinner();
// Get data from the server
- const protocol = window.location.protocol.replace(':', '');
- const host = window.location.hostname;
const apiToken = getSetting("API_TOKEN");
- const port = getSetting("GRAPHQL_PORT"); // same port your Flask app runs on
- const apiBase = `${protocol}://${host}:${port}`;
+ const apiBase = getApiBase();
const url = `${apiBase}/device/${getMac()}?period=${encodeURIComponent(period)}`;
const response = await fetch(url, {
diff --git a/front/deviceDetailsEdit.php b/front/deviceDetailsEdit.php
index 971396b0..c76833e3 100755
--- a/front/deviceDetailsEdit.php
+++ b/front/deviceDetailsEdit.php
@@ -43,13 +43,10 @@ function getDeviceData() {
mac = getMac()
console.log(mac);
-
- const protocol = window.location.protocol.replace(':', '');
- const host = window.location.hostname;
const apiToken = getSetting("API_TOKEN");
- const port = getSetting("GRAPHQL_PORT");
+ let period = $("#period").val()
- const apiBase = `${protocol}://${host}:${port}`;
+ const apiBase = getApiBase();
const url = `${apiBase}/device/${mac}?period=${encodeURIComponent(period)}`;
// get data from server
diff --git a/front/deviceDetailsEvents.php b/front/deviceDetailsEvents.php
index 9c2351fa..69a6d96d 100755
--- a/front/deviceDetailsEvents.php
+++ b/front/deviceDetailsEvents.php
@@ -48,12 +48,9 @@ function loadEventsData() {
)
`;
- const protocol = window.location.protocol.replace(':', '');
- const host = window.location.hostname;
- const port = getSetting("GRAPHQL_PORT");
const apiToken = getSetting("API_TOKEN");
- const apiBase = `${protocol}://${host}:${port}`;
+ const apiBase = getApiBase();
const url = `${apiBase}/dbquery/read`;
$.ajax({
diff --git a/front/deviceDetailsPresence.php b/front/deviceDetailsPresence.php
index 9b731984..e8bdbae7 100755
--- a/front/deviceDetailsPresence.php
+++ b/front/deviceDetailsPresence.php
@@ -36,12 +36,9 @@
// ---------------------------------------
// query data
function loadPresenceData() {
- const protocol = window.location.protocol.replace(":", "");
- const host = window.location.hostname;
- const port = getSetting("GRAPHQL_PORT");
const apiToken = getSetting("API_TOKEN");
- const apiBase = `${protocol}://${host}:${port}`;
+ const apiBase = getApiBase();
const url = `${apiBase}/sessions/calendar`;
$('#calendar').fullCalendar('removeEventSources');
diff --git a/front/deviceDetailsSessions.php b/front/deviceDetailsSessions.php
index 84387e3c..ddb5806c 100755
--- a/front/deviceDetailsSessions.php
+++ b/front/deviceDetailsSessions.php
@@ -103,12 +103,9 @@ function loadSessionsData() {
showSpinner();
// Build API base
- const protocol = window.location.protocol.replace(':', '');
- const host = window.location.hostname;
- const port = getSetting("GRAPHQL_PORT"); // or whatever port your Flask API runs on
const apiToken = getSetting("API_TOKEN");
- const apiBase = `${protocol}://${host}:${port}`;
+ const apiBase = getApiBase();
const url = `${apiBase}/sessions/${getMac()}?period=${encodeURIComponent(period)}`;
// Call API with Authorization header
diff --git a/front/js/api.js b/front/js/api.js
new file mode 100644
index 00000000..22f25e7c
--- /dev/null
+++ b/front/js/api.js
@@ -0,0 +1,15 @@
+function getApiBase()
+{
+ apiBase = getSetting("BACKEND_API_URL");
+
+ if(apiBase == "")
+ {
+ const protocol = window.location.protocol.replace(':', '');
+ const host = window.location.hostname;
+ const port = getSetting("GRAPHQL_PORT");
+
+ apiBase = `${protocol}://${host}:${port}`;
+ }
+
+ return apiBase;
+}
\ No newline at end of file
diff --git a/front/php/templates/header.php b/front/php/templates/header.php
index 55919a89..08f59242 100755
--- a/front/php/templates/header.php
+++ b/front/php/templates/header.php
@@ -44,6 +44,7 @@
+
diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json
index e82ebe82..84f42b0e 100644
--- a/front/php/templates/language/ar_ar.json
+++ b/front/php/templates/language/ar_ar.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Object Type",
"AppEvents_Plugin": "المكونات الإضافية",
"AppEvents_Type": "النوع",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "هل تريد تنفيذ هذا الإجراء؟",
"BackDevDetail_Actions_Not_Registered": "لم يتم تسجيل الإجراء: ",
"BackDevDetail_Actions_Title_Run": "تنفيذ الإجراء",
diff --git a/front/php/templates/language/ca_ca.json b/front/php/templates/language/ca_ca.json
index 64601aa8..75751961 100644
--- a/front/php/templates/language/ca_ca.json
+++ b/front/php/templates/language/ca_ca.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Tipus d'objecte",
"AppEvents_Plugin": "Plugin",
"AppEvents_Type": "Tipus",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Vol executar aquesta comanda?",
"BackDevDetail_Actions_Not_Registered": "Comanda no registrada: ",
"BackDevDetail_Actions_Title_Run": "Executar la comanda",
@@ -763,4 +765,4 @@
"settings_system_label": "Sistema",
"settings_update_item_warning": "Actualitza el valor sota. Sigues curós de seguir el format anterior. No hi ha validació.",
"test_event_tooltip": "Deseu els canvis primer abans de comprovar la configuració."
-}
+}
\ No newline at end of file
diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json
index 36c29d46..60d6d36a 100644
--- a/front/php/templates/language/cs_cz.json
+++ b/front/php/templates/language/cs_cz.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "",
"AppEvents_Plugin": "Zásuvný modul",
"AppEvents_Type": "Typ",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "",
"BackDevDetail_Actions_Not_Registered": "",
"BackDevDetail_Actions_Title_Run": "Spustit akci",
diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json
index 5782cf6c..7a7c0143 100644
--- a/front/php/templates/language/de_de.json
+++ b/front/php/templates/language/de_de.json
@@ -29,6 +29,8 @@
"AppEvents_Type": "Typ",
"Apprise_display_name": "Apprise",
"Apprise_icon": "",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Möchtest du die Aktion ausführen?",
"BackDevDetail_Actions_Not_Registered": "Aktion nicht registriert: ",
"BackDevDetail_Actions_Title_Run": "Aktion ausführen",
diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json
index 66ef989d..207f39b8 100755
--- a/front/php/templates/language/en_us.json
+++ b/front/php/templates/language/en_us.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Object Type",
"AppEvents_Plugin": "Plugin",
"AppEvents_Type": "Type",
+ "BACKEND_API_URL_description": "Used to generate backend API URLs. Specify if you use reverse proxy to map to your GRAPHQL_PORT. Enter full URL starting with http:// including the port number (no trailing slash /).",
+ "BACKEND_API_URL_name": "Backend API URL",
"BackDevDetail_Actions_Ask_Run": "Do you want to execute the action?",
"BackDevDetail_Actions_Not_Registered": "Action not registered: ",
"BackDevDetail_Actions_Title_Run": "Run action",
diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json
index 01aa9461..91ae1760 100755
--- a/front/php/templates/language/es_es.json
+++ b/front/php/templates/language/es_es.json
@@ -29,6 +29,8 @@
"AppEvents_Type": "Tipo",
"Apprise_display_name": "Apprise",
"Apprise_icon": "",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "¿Desea ejecutar la acción?",
"BackDevDetail_Actions_Not_Registered": "Acción no registrada: ",
"BackDevDetail_Actions_Title_Run": "Ejecutar acción",
diff --git a/front/php/templates/language/fa_fa.json b/front/php/templates/language/fa_fa.json
index c3775999..65a73f0f 100644
--- a/front/php/templates/language/fa_fa.json
+++ b/front/php/templates/language/fa_fa.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "",
"AppEvents_Plugin": "",
"AppEvents_Type": "",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "",
"BackDevDetail_Actions_Not_Registered": "",
"BackDevDetail_Actions_Title_Run": "",
diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json
index e263bce1..0faa2a21 100644
--- a/front/php/templates/language/fr_fr.json
+++ b/front/php/templates/language/fr_fr.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Type d'objet",
"AppEvents_Plugin": "Plugin",
"AppEvents_Type": "Type",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Voulez-vous exécuter cette action ?",
"BackDevDetail_Actions_Not_Registered": "Action non enregistrée : ",
"BackDevDetail_Actions_Title_Run": "Lancer l'action",
@@ -763,4 +765,4 @@
"settings_system_label": "Système",
"settings_update_item_warning": "Mettre à jour la valeur ci-dessous. Veillez à bien suivre le même format qu'auparavant. Il n'y a pas de pas de contrôle.",
"test_event_tooltip": "Enregistrer d'abord vos modifications avant de tester vôtre paramétrage."
-}
+}
\ No newline at end of file
diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json
index ef2eefa4..145afb55 100644
--- a/front/php/templates/language/it_it.json
+++ b/front/php/templates/language/it_it.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Tipo oggetto",
"AppEvents_Plugin": "Plugin",
"AppEvents_Type": "Tipo",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Vuoi eseguire questa azione?",
"BackDevDetail_Actions_Not_Registered": "Azione non registrata: ",
"BackDevDetail_Actions_Title_Run": "Esegui azione",
@@ -763,4 +765,4 @@
"settings_system_label": "Sistema",
"settings_update_item_warning": "Aggiorna il valore qui sotto. Fai attenzione a seguire il formato precedente. La convalida non viene eseguita.",
"test_event_tooltip": "Salva le modifiche prima di provare le nuove impostazioni."
-}
+}
\ No newline at end of file
diff --git a/front/php/templates/language/ja_jp.json b/front/php/templates/language/ja_jp.json
index 4ed4f098..e64f5af8 100644
--- a/front/php/templates/language/ja_jp.json
+++ b/front/php/templates/language/ja_jp.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "オブジェクトタイプ",
"AppEvents_Plugin": "プラグイン",
"AppEvents_Type": "種別",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "このアクションを実行してよろしいですか?",
"BackDevDetail_Actions_Not_Registered": "登録されていないアクション: ",
"BackDevDetail_Actions_Title_Run": "アクションを実行",
diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json
index 8382c221..930eb881 100755
--- a/front/php/templates/language/nb_no.json
+++ b/front/php/templates/language/nb_no.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Objekttype",
"AppEvents_Plugin": "Programtillegg",
"AppEvents_Type": "Type",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Vil du utføre handlingen?",
"BackDevDetail_Actions_Not_Registered": "Handling ikke registrert: ",
"BackDevDetail_Actions_Title_Run": "Utfør handling",
diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json
index 474ffa5a..43a8005c 100755
--- a/front/php/templates/language/pl_pl.json
+++ b/front/php/templates/language/pl_pl.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Typ obiektu",
"AppEvents_Plugin": "Wtyczka",
"AppEvents_Type": "Typ",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Czy chcesz wykonać tę akcję?",
"BackDevDetail_Actions_Not_Registered": "Akcja nie jest zarejestrowana: ",
"BackDevDetail_Actions_Title_Run": "Uruchom akcję",
diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json
index ff865475..c6fb8e21 100644
--- a/front/php/templates/language/pt_br.json
+++ b/front/php/templates/language/pt_br.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Tipo de Objeto",
"AppEvents_Plugin": "Plugin",
"AppEvents_Type": "Tipo",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Você deseja executar esta ação?",
"BackDevDetail_Actions_Not_Registered": "Ação não registrada: ",
"BackDevDetail_Actions_Title_Run": "Executar ação",
@@ -763,4 +765,4 @@
"settings_system_label": "",
"settings_update_item_warning": "",
"test_event_tooltip": "Guarde as alterações antes de testar as definições."
-}
+}
\ No newline at end of file
diff --git a/front/php/templates/language/pt_pt.json b/front/php/templates/language/pt_pt.json
index b556eadc..0cff2bb2 100755
--- a/front/php/templates/language/pt_pt.json
+++ b/front/php/templates/language/pt_pt.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Tipo de Objeto",
"AppEvents_Plugin": "Plugin",
"AppEvents_Type": "Tipo",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Deseja executar esta ação?",
"BackDevDetail_Actions_Not_Registered": "Ação não registada: ",
"BackDevDetail_Actions_Title_Run": "Executar ação",
diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json
index 7613a5ff..bfb6d48a 100644
--- a/front/php/templates/language/ru_ru.json
+++ b/front/php/templates/language/ru_ru.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Тип объекта",
"AppEvents_Plugin": "Плагин",
"AppEvents_Type": "Тип",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Вы хотите выполнить действие?",
"BackDevDetail_Actions_Not_Registered": "Действие не зарегистрировано:· ",
"BackDevDetail_Actions_Title_Run": "Запустить действие",
diff --git a/front/php/templates/language/sv_sv.json b/front/php/templates/language/sv_sv.json
index e901b58d..5e4b2ba1 100644
--- a/front/php/templates/language/sv_sv.json
+++ b/front/php/templates/language/sv_sv.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "",
"AppEvents_Plugin": "",
"AppEvents_Type": "",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "",
"BackDevDetail_Actions_Not_Registered": "",
"BackDevDetail_Actions_Title_Run": "",
diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json
index bbb2964d..836c58f8 100755
--- a/front/php/templates/language/tr_tr.json
+++ b/front/php/templates/language/tr_tr.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Nesne Tipi",
"AppEvents_Plugin": "Eklenti",
"AppEvents_Type": "Tür",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "İşlemi gerçekleştirmek istiyor musunuz?",
"BackDevDetail_Actions_Not_Registered": "Eylem kaydedilmedi: ",
"BackDevDetail_Actions_Title_Run": "Eylemi çalıştır",
diff --git a/front/php/templates/language/uk_ua.json b/front/php/templates/language/uk_ua.json
index 0c933ca9..c8ba1d68 100644
--- a/front/php/templates/language/uk_ua.json
+++ b/front/php/templates/language/uk_ua.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "Тип об'єкта",
"AppEvents_Plugin": "Плагін",
"AppEvents_Type": "Тип",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "Ви хочете виконати дію?",
"BackDevDetail_Actions_Not_Registered": "Дія не зареєстрована: ",
"BackDevDetail_Actions_Title_Run": "Запустити дію",
@@ -763,4 +765,4 @@
"settings_system_label": "Система",
"settings_update_item_warning": "Оновіть значення нижче. Слідкуйте за попереднім форматом. Перевірка не виконана.",
"test_event_tooltip": "Перш ніж перевіряти налаштування, збережіть зміни."
-}
+}
\ No newline at end of file
diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json
index 5404dd2d..43f617dc 100755
--- a/front/php/templates/language/zh_cn.json
+++ b/front/php/templates/language/zh_cn.json
@@ -27,6 +27,8 @@
"AppEvents_ObjectType": "对象类型",
"AppEvents_Plugin": "插件",
"AppEvents_Type": "类型",
+ "BACKEND_API_URL_description": "",
+ "BACKEND_API_URL_name": "",
"BackDevDetail_Actions_Ask_Run": "您要执行此操作吗?",
"BackDevDetail_Actions_Not_Registered": "未注册的操作: ",
"BackDevDetail_Actions_Title_Run": "运行动作",
diff --git a/front/presence.php b/front/presence.php
index a7c0c579..bdcfb22b 100755
--- a/front/presence.php
+++ b/front/presence.php
@@ -421,12 +421,9 @@ function getDevicesPresence (status) {
$('#tableDevicesBox')[0].className = 'box box-'+ color;
$('#tableDevicesTitle').html (tableTitle);
- const protocol = window.location.protocol.replace(':', '');
- const host = window.location.hostname;
- const port = getSetting("GRAPHQL_PORT"); // Or Flask server port
const apiToken = getSetting("API_TOKEN");
- const apiBase = `${protocol}://${host}:${port}`;
+ const apiBase = getApiBase();
// -----------------------------
// Load Devices as Resources
diff --git a/server/initialise.py b/server/initialise.py
index aee564bf..99c51b10 100755
--- a/server/initialise.py
+++ b/server/initialise.py
@@ -270,6 +270,15 @@ def importConfigs(pm, db, all_plugins):
"[]",
"General",
)
+ conf.BACKEND_API_URL = ccd(
+ "BACKEND_API_URL",
+ "",
+ c_d,
+ "API URL",
+ '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}',
+ "[]",
+ "General",
+ )
conf.DAYS_TO_KEEP_EVENTS = ccd(
"DAYS_TO_KEEP_EVENTS",
90,