diff --git a/config/config.js b/config/config.js new file mode 100644 index 0000000..5d9bbe9 --- /dev/null +++ b/config/config.js @@ -0,0 +1,16 @@ +var config = { + dev: { + apiBaseURL: 'http://localhost:8080/hdpos/api' + }, + prod: { + apiBaseURL: 'http://V-XSTO-A01-IIDC.adic.lan/hdpos/api' + } +}; + +// Now we check the hostname where the script is running +var env = window.location.hostname.includes('localhost') ? 'dev' : 'prod'; + +var selectedConfig = config[env]; + +// Make the selected configuration available for other scripts +window.config = selectedConfig; \ No newline at end of file diff --git a/store/list/list.html b/store/list/list.html index f595fed..e259642 100644 --- a/store/list/list.html +++ b/store/list/list.html @@ -369,6 +369,7 @@ Contact: frederik.benoist@inetum.com + diff --git a/store/list/table.js b/store/list/table.js index dd4fc05..f991abf 100644 --- a/store/list/table.js +++ b/store/list/table.js @@ -75,7 +75,7 @@ var KTUsersList = function () { { data: 'telephone', name: "telephone"} ], ajax: { - "url": "http://localhost:8080/hdpos/api/stores/getAll", + "url": config.apiBaseURL + "/stores/getAll", "dataSrc": "" }, error: function (jqXHR, textStatus, errorThrown) { diff --git a/store/view/view-store.html b/store/view/view-store.html index badedc0..cb35aa7 100644 --- a/store/view/view-store.html +++ b/store/view/view-store.html @@ -807,6 +807,7 @@ Contact: frederik.benoist@inetum.com + diff --git a/store/view/view-store.js b/store/view/view-store.js index b17a47e..5ac6189 100644 --- a/store/view/view-store.js +++ b/store/view/view-store.js @@ -57,7 +57,7 @@ var KTStoreView = function () { }); // call StoreDetails API - fetch('http://localhost:8080/hdpos/api/stores/getStoreDetails?dbHost='+ipAddress+'&storeId='+storeId) + fetch(config.apiBaseURL + "/stores/getStoreDetails?dbHost="+ipAddress+"&storeId="+storeId) .then(response => response.json()) .then(data => { debugger; @@ -118,7 +118,7 @@ var KTStoreView = function () { left: 1 }, ajax: { - "url": "http://localhost:8080/hdpos/api/items/" + itemId, + "url": config.apiBaseURL + "/items/" + itemId, "dataSrc": "", "data": { "dbHost": ipAddress @@ -143,7 +143,7 @@ var KTStoreView = function () { }); } else { statusItem.innerHTML = 'Loading...'; - datatableItem.ajax.url("http://localhost:8080/hdpos/api/items/" + itemId); + datatableItem.ajax.url(config.apiBaseURL + "/items/" + itemId); datatableItem.ajax.reload(function() { dtUpdateStatus(statusItem, "Last refresh", "", false) }, true); @@ -168,7 +168,7 @@ var KTStoreView = function () { left: 1 }, ajax: { - "url": "http://localhost:8080/hdpos/api/items/" + itemId + "/options", + "url": config.apiBaseURL + "/items/" + itemId + "/options", "dataSrc": "", "data": { "dbHost": ipAddress @@ -199,7 +199,7 @@ var KTStoreView = function () { }); } else { statusItemOptions.innerHTML = 'Loading...'; - datatableItemOptions.ajax.url("http://localhost:8080/hdpos/api/items/" + itemId + "/options"); + datatableItemOptions.ajax.url(config.apiBaseURL + "/items/" + itemId + "/options"); datatableItemOptions.ajax.reload(function() { dtUpdateStatus(statusItemOptions, "Last refresh", "", false) }, true); @@ -224,7 +224,7 @@ var KTStoreView = function () { left: 1 }, ajax: { - "url": "http://localhost:8080/hdpos/api/items/" + itemId + "/price", + "url": config.apiBaseURL + "/items/" + itemId + "/price", "dataSrc": "", "data": { "dbHost": ipAddress @@ -256,7 +256,7 @@ var KTStoreView = function () { }); } else { statusItemPrice.innerHTML = 'Loading...'; - datatableItemPrice.ajax.url("http://localhost:8080/hdpos/api/items/" + itemId + "/price"); + datatableItemPrice.ajax.url(config.apiBaseURL + "/items/" + itemId + "/price"); datatableItemPrice.ajax.reload(function() { dtUpdateStatus(statusItemPrice, "Last refresh", "", false) }, true); @@ -281,7 +281,7 @@ var KTStoreView = function () { left: 1 }, ajax: { - "url": "http://localhost:8080/hdpos/api/items/" + itemId + "/stock", + "url": config.apiBaseURL + "/items/" + itemId + "/stock", "dataSrc": "", "data": { "dbHost": ipAddress @@ -307,7 +307,7 @@ var KTStoreView = function () { }); } else { statusItemStock.innerHTML = 'Loading...'; - datatableItemStock.ajax.url("http://localhost:8080/hdpos/api/items/" + itemId + "/stock"); + datatableItemStock.ajax.url(config.apiBaseURL + "/items/" + itemId + "/stock"); datatableItemStock.ajax.reload(function() { dtUpdateStatus(statusItemStock, "Last refresh", "", false) }, true); @@ -329,7 +329,7 @@ var KTStoreView = function () { paging: false, autoWidth: false, ajax: { - "url": "http://localhost:8080/hdpos/api/stores/version", + "url": config.apiBaseURL + "/stores/version", "dataSrc": "", "data": { "dbHost": ipAddress @@ -372,7 +372,7 @@ var KTStoreView = function () { paging: true, autoWidth: false, ajax: { - "url": "http://localhost:8080/hdpos/api/stores/sequence", + "url": config.apiBaseURL + "/stores/sequence", "dataSrc": "", "data": { "dbHost": ipAddress @@ -448,7 +448,7 @@ var KTStoreView = function () { left: 2 }, ajax: { - "url": "http://localhost:8080/hdpos/api/stores/signature", + "url": config.apiBaseURL + "/stores/signature", "dataSrc": "", "data": { "dbHost": ipAddress