Compare commits

..

No commits in common. "09e74f9eb6ad2c11f382d759d507a3a20828d51d" and "58a2d2ad1995b94f843127d4d7173860e79aed1e" have entirely different histories.

13 changed files with 25 additions and 22 deletions

View File

@ -21,7 +21,7 @@
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="itemModifyModalStorageLocation" class="form-label">Select a storage location</label> <label for="itemModifyModalStorageLocation" class="form-label">Select a storage location</label>
<select class="form-select" id="itemModifyModalStorageLocation" name="storageLocationId"> <select class="form-select" id="itemModifyModalStorageLocation" name="storageLocation">
<option value=""><i>Do not assign a storage location</i></option> <option value=""><i>Do not assign a storage location</i></option>
<% it.storeLocs.forEach(function(locs){ %> <% it.storeLocs.forEach(function(locs){ %>
<option value="<%= locs.id %>"><%= locs.name %></option> <option value="<%= locs.id %>"><%= locs.name %></option>

View File

@ -17,7 +17,7 @@ function get(req: Request, res: Response) {
}) })
.then((item) => { .then((item) => {
if (item) { if (item) {
res.status(200).json(item); res.status(200).json(JSON.stringify(item));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'Category does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'Category does not exist' });
} }

View File

@ -43,7 +43,7 @@ async function get(req: Request, res: Response) {
}) })
.then((items) => { .then((items) => {
if (items) { if (items) {
res.status(200).json(items); res.status(200).json(JSON.stringify(items));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'Item does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'Item does not exist' });
} }
@ -117,7 +117,7 @@ async function get(req: Request, res: Response) {
}) })
.then((items) => { .then((items) => {
if (items) { if (items) {
res.status(200).json({ total: itemCountFiltered, totalNotFiltered: itemCountNotFiltered, items: items }); res.status(200).json(JSON.stringify({ total: itemCountFiltered, totalNotFiltered: itemCountNotFiltered, items: items }));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'Item does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'Item does not exist' });
} }

View File

@ -19,7 +19,7 @@ function get(req: Request, res: Response) {
} }
}) })
.then((items) => { .then((items) => {
res.status(200).json(items); res.status(200).json(JSON.stringify(items));
}) })
.catch((err) => { .catch((err) => {
log.db.error(err); log.db.error(err);

View File

@ -21,7 +21,7 @@ function get(req: Request, res: Response) {
}) })
.then((items) => { .then((items) => {
if (items) { if (items) {
res.status(200).json(items); res.status(200).json(JSON.stringify(items));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageLocation does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageLocation does not exist' });
} }
@ -40,7 +40,7 @@ function get(req: Request, res: Response) {
}) })
.then((items) => { .then((items) => {
if (items) { if (items) {
res.status(200).json(items); res.status(200).json(JSON.stringify(items));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageLocation does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageLocation does not exist' });
} }

View File

@ -23,7 +23,7 @@ function get(req: Request, res: Response) {
}) })
.then((items) => { .then((items) => {
if (items) { if (items) {
res.status(200).json(items); res.status(200).json(JSON.stringify(items));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageUnit does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageUnit does not exist' });
} }
@ -43,7 +43,7 @@ function get(req: Request, res: Response) {
}) })
.then((items) => { .then((items) => {
if (items) { if (items) {
res.status(200).json(items); res.status(200).json(JSON.stringify(items));
} else { } else {
res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageUnit does not exist' }); res.status(410).json({ errorcode: 'NOT_EXISTING', error: 'storageUnit does not exist' });
} }

View File

@ -29,9 +29,7 @@ function get(req: Request, res: Response) {
res.send(html); res.send(html);
}); });
} else { } else {
Eta.renderFile(__path + '/src/frontend/errors/404.eta.html', item).then((html) => { res.send('Item not found');
res.status(404).send(html);
});
} }
}); });
} }

View File

@ -2,7 +2,9 @@ function getDataForEdit(name) {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: `/api/v1/categories?name=${name}`, url: `/api/v1/categories?name=${name}`,
success: function (result) { success: function (data) {
const result = JSON.parse(data);
// Get elements inside the editCategoryModal // Get elements inside the editCategoryModal
const modal_categoryName = document.getElementById('editCategoryModalName'); const modal_categoryName = document.getElementById('editCategoryModalName');
const modal_categoryDescription = document.getElementById('editCategoryModalDescription'); const modal_categoryDescription = document.getElementById('editCategoryModalDescription');

View File

@ -19,7 +19,8 @@ function getDataForEdit(id) {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: `/api/v1/items?id=${id}`, url: `/api/v1/items?id=${id}`,
success: function (result) { success: function (data) {
const result = JSON.parse(data);
// Get elements inside the editCategoryModal // Get elements inside the editCategoryModal
const modal_itemName = document.getElementById('itemModifyModalName'); const modal_itemName = document.getElementById('itemModifyModalName');
@ -41,7 +42,6 @@ function getDataForEdit(id) {
// Select the correct option in the dropdown // Select the correct option in the dropdown
const modal_itemCategoryOptions = modal_itemCategory.options; const modal_itemCategoryOptions = modal_itemCategory.options;
modal_itemCategoryOptions[0].selected = true;
for (let i = 0; i < modal_itemCategoryOptions.length; i++) { for (let i = 0; i < modal_itemCategoryOptions.length; i++) {
if (modal_itemCategoryOptions[i].value == result.categoryId) { if (modal_itemCategoryOptions[i].value == result.categoryId) {
modal_itemCategoryOptions[i].selected = true; modal_itemCategoryOptions[i].selected = true;
@ -50,7 +50,6 @@ function getDataForEdit(id) {
// Select the correct option in the dropdown // Select the correct option in the dropdown
const modal_itemStatusOptions = modal_itemStatus.options; const modal_itemStatusOptions = modal_itemStatus.options;
modal_itemStatusOptions[0].selected = true;
for (let i = 0; i < modal_itemStatusOptions.length; i++) { for (let i = 0; i < modal_itemStatusOptions.length; i++) {
if (modal_itemStatusOptions[i].value == result.statusId) { if (modal_itemStatusOptions[i].value == result.statusId) {
modal_itemStatusOptions[i].selected = true; modal_itemStatusOptions[i].selected = true;
@ -59,7 +58,6 @@ function getDataForEdit(id) {
// Select the correct option in the dropdown // Select the correct option in the dropdown
const modal_itemStorageLocationOptions = modal_itemStorageLocation.options; const modal_itemStorageLocationOptions = modal_itemStorageLocation.options;
modal_itemStorageLocationOptions[0].selected = true;
for (let i = 0; i < modal_itemStorageLocationOptions.length; i++) { for (let i = 0; i < modal_itemStorageLocationOptions.length; i++) {
if (modal_itemStorageLocationOptions[i].value == result.storageLocationId) { if (modal_itemStorageLocationOptions[i].value == result.storageLocationId) {
modal_itemStorageLocationOptions[i].selected = true; modal_itemStorageLocationOptions[i].selected = true;

View File

@ -68,7 +68,8 @@ function getDataForEdit(id) {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: `/api/v1/storageUnits?id=${id}`, url: `/api/v1/storageUnits?id=${id}`,
success: function (result) { success: function (data) {
const result = JSON.parse(data);
// Get elements inside the editCategoryModal // Get elements inside the editCategoryModal
const modal_unitName = document.getElementById('storageUnitModalName'); const modal_unitName = document.getElementById('storageUnitModalName');
@ -106,7 +107,8 @@ function getDataForEditLoc(id) {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: `/api/v1/storageLocations?id=${id}`, url: `/api/v1/storageLocations?id=${id}`,
success: function (result) { success: function (data) {
const result = JSON.parse(data);
// Get elements inside the editCategoryModal // Get elements inside the editCategoryModal
const modal_locationName = document.getElementById('storageLocationModalName'); const modal_locationName = document.getElementById('storageLocationModalName');

View File

@ -108,7 +108,8 @@ function preFillDeleteModalNxt(id, route, name, requestIdent='id') {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: `/api/v1/${route}?${requestIdent}=${id}`, url: `/api/v1/${route}?${requestIdent}=${id}`,
success: function (result) { success: function (data) {
const result = JSON.parse(data);
// Get elements inside the editCategoryModal // Get elements inside the editCategoryModal
const modal_categoryName = document.getElementById('deleteNamePlaceholder'); const modal_categoryName = document.getElementById('deleteNamePlaceholder');

View File

@ -23,7 +23,8 @@ function loadPageData() {
}, 1000); }, 1000);
} }
function dataResponseHandler(json) { function dataResponseHandler(res) {
json = JSON.parse(res);
// console.log(json) // console.log(json)
totalNotFiltered = json.totalNotFiltered; totalNotFiltered = json.totalNotFiltered;
total = json.total; total = json.total;

View File

@ -67,7 +67,8 @@ function handleSearchChange(e) {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: url, url: url,
success: function (result) { success: function (data) {
let result = JSON.parse(data);
let htmlResult = "" let htmlResult = ""
result.forEach(element => { result.forEach(element => {
console.log(element); console.log(element);