implemented ui functions for managing products, uploading images and editiing users

This commit is contained in:
2025-03-09 23:09:49 +01:00
parent fa7f3004fa
commit bd43f03507
23 changed files with 888 additions and 83 deletions

View File

@@ -19,6 +19,12 @@ let _api = {
headers: new Headers({ 'content-type': 'application/json' })
};
const response = await fetch(_apiConfig.basePath + path, options);
if(response.status == 404) {
return {
count: 0,
result: []
}
}
// Handle the response
if (!response.ok) {
console.error('Failed to fetch:', response.statusText);
@@ -190,13 +196,14 @@ function returnTableDataByTableName(tableName, search="", orderBy="asc", sort=""
}
async function getCountByTable(tableName, search="") {
let baseString = tableName + '?count=true';
let baseString = tableName + '';
if (search && search.length > 0) {
baseString += '&search=' + search;
baseString += '?search=' + search;
}
// Stored in `data:count:${tableName}`
let result = await _api.get(baseString);
console.debug('Count result:', result);
result = result.count;
if (typeof result !== 'number') {
_testPageWarn('Count was not a number, was: ' + result);
console.warn('Count was not a number, was: ' + result);
@@ -214,6 +221,8 @@ function _testPageFail(reason) {
}
function _testPageWarn(reason) {
console.warn('API Wrapper Test Warning, reason: ' + reason);
return;
document.getElementById('heroStatus').classList.remove('is-success');
document.getElementById('heroStatus').classList.add('is-warning');