diff --git a/db/changes/10280-valentineDay/00-itemImageQueue.sql b/db/changes/10280-valentineDay/00-itemImageQueue.sql new file mode 100644 index 000000000..41c55552d --- /dev/null +++ b/db/changes/10280-valentineDay/00-itemImageQueue.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`itemImageQueue` + ADD attempts INT default 0 NULL AFTER error; diff --git a/front/core/components/table/style.scss b/front/core/components/table/style.scss index 8d35c374c..7d90d4db6 100644 --- a/front/core/components/table/style.scss +++ b/front/core/components/table/style.scss @@ -85,6 +85,25 @@ vn-table { max-width: 400px; min-width: 0; } + &[vn-fetched-tags] { + width: 235px; + min-width: 155px; + & > vn-one { + overflow: hidden; + text-overflow: ellipsis; + font-size: 0.75rem; + } + + & > vn-one:nth-child(2) h3 { + color: $color-font-secondary; + text-transform: uppercase; + line-height: initial; + font-size: 0.75rem + } + } + &[vn-fetched-tags][wide] { + width: 430px; + } vn-icon.bright, i.bright { color: #f7931e; } diff --git a/modules/client/front/consumption/index.html b/modules/client/front/consumption/index.html index 1038d4a60..b2128ee11 100644 --- a/modules/client/front/consumption/index.html +++ b/modules/client/front/consumption/index.html @@ -64,12 +64,15 @@ {{::sale.shipped | date: 'dd/MM/yyyy'}} - + + {{::sale.concept}} + +

{{::sale.subName}}

+
+ tabindex="-1">
{{::sale.quantity | dashIfEmpty}} diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 6ab675d76..6c4802816 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -97,12 +97,15 @@ {{::buy.description | dashIfEmpty}}
{{::buy.size}} - + + {{::buy.name}} + +

{{::buy.subName}}

+
+ tabindex="-1">
diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 6d5387459..2843ecc46 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -142,12 +142,12 @@ {{::line.item.minPrice | currency: 'EUR':2}} - + + {{::line.item.name}} + tabindex="-1"> diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index ce52c103b..b8a03e1c1 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -18,39 +18,50 @@ module.exports = Self => { Self.downloadImages = async() => { const models = Self.app.models; + const container = await models.TempContainer.container('salix-image'); + const tempPath = path.join(container.client.root, container.name); + const maxAttempts = 3; - try { - const tempPath = path.join('/tmp/salix-image'); + const images = await Self.find({ + where: {attempts: {eq: maxAttempts}} + }); - // Create temporary path - await fs.mkdir(tempPath, {recursive: true}); + for (let image of images) { + const currentStamp = new Date().getTime(); + const updatedStamp = image.updated.getTime(); + const graceTime = Math.abs(currentStamp - updatedStamp); + const maxTTL = 3600 * 48 * 1000; // 48 hours in ms; - const timer = setInterval(async() => { - const image = await Self.findOne({ - where: {error: null, url: {neq: null}} - }); + if (graceTime >= maxTTL) + await Self.destroyById(image.itemFk); + } - // Exit loop - if (!image) return clearInterval(timer); + download(); - const srcFile = image.url.split('/').pop(); - const fileName = srcFile.split('.')[0]; - const file = `${fileName}.png`; - const filePath = path.join(tempPath, file); + async function download() { + const image = await Self.findOne({ + where: {url: {neq: null}, attempts: {lt: maxAttempts}}, + order: 'attempts, updated' + }); + + if (!image) return; + + const srcFile = image.url.split('/').pop(); + const dotIndex = srcFile.lastIndexOf('.'); + const fileName = srcFile.substring(0, dotIndex); + const file = `${fileName}.png`; + const filePath = path.join(tempPath, file); + + https.get(image.url, async response => { + if (response.statusCode != 200) { + const error = new Error(`Could not download the image. Status code ${response.statusCode}`); + + return await errorHandler(image.itemFk, error, filePath); + } const writeStream = fs.createWriteStream(filePath); writeStream.on('open', () => { - https.get(image.url, async response => { - if (response.statusCode != 200) { - const error = new Error(`Could not download the image. Status code ${response.statusCode}`); - - return await errorHandler(image.itemFk, error, filePath); - } - - response.pipe(writeStream); - }).on('error', async error => { - await errorHandler(image.itemFk, error, filePath); - }); + response.pipe(writeStream); }); writeStream.on('error', async error => { @@ -58,31 +69,44 @@ module.exports = Self => { }); writeStream.on('finish', async function() { + writeStream.end(); + }); + + writeStream.on('close', async function() { try { await models.Image.registerImage('catalog', filePath, fileName, image.itemFk); await image.destroy(); + + download(); } catch (error) { await errorHandler(image.itemFk, error, filePath); } }); - }, 1000); - } catch (error) { - throw new Error('Try-catch error: ', error); + }).on('error', async error => { + await errorHandler(image.itemFk, error, filePath); + }); } async function errorHandler(rowId, error, filePath) { try { const row = await Self.findById(rowId); - if (!row) - throw new Error(`Could not update due error ${error}`); + if (!row) return; - await row.updateAttribute('error', error); + if (row.attempts < maxAttempts) { + await row.updateAttributes({ + error: error, + attempts: row.attempts + 1, + updated: new Date() + }); + } if (filePath && fs.existsSync(filePath)) await fs.unlink(filePath); + + download(); } catch (err) { - throw new Error(`ErrorHandler error: ${err}`); + throw new Error(`Image download failed: ${err}`); } } }; diff --git a/modules/item/back/models/item-image-queue.json b/modules/item/back/models/item-image-queue.json index 6e248ac96..a4b65b204 100644 --- a/modules/item/back/models/item-image-queue.json +++ b/modules/item/back/models/item-image-queue.json @@ -9,17 +9,26 @@ }, "properties": { "itemFk": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "url": { - "type": "String", + "type": "string", "required": true }, "error": { - "type": "String", + "type": "string", "required": true + }, + "attempts": { + "type": "number" + }, + "created": { + "type": "date" + }, + "updated": { + "type": "date" } }, "relations": { diff --git a/modules/item/front/fetched-tags/index.html b/modules/item/front/fetched-tags/index.html index 6982ab6ac..472fa676b 100644 --- a/modules/item/front/fetched-tags/index.html +++ b/modules/item/front/fetched-tags/index.html @@ -1,8 +1,4 @@ - {{$ctrl.name}} - -

{{$ctrl.subName}}

-
vn-horizontal { align-items: center; - & > vn-one { - overflow: hidden; - text-overflow: ellipsis; - min-width: 80px; - } + & > vn-auto { + flex-wrap: wrap; - & > vn-one:nth-child(2) h3 { - color: $color-font-secondary; - text-transform: uppercase; - line-height: initial; - text-align: center; - font-size: 1rem + & > .inline-tag { + margin: 1px; + } } & > vn-auto { display: flex; - padding-left: 6px; - min-width: 192px; & > .inline-tag { - display: inline-block; color: $color-font-secondary; - margin-left: 6px; text-align: center; font-size: .75rem; - height: 20px; + height: 12px; padding: 1px; - border-radius: 1px; width: 64px; min-width: 64px; + max-width: 64px; + flex: 1; border: 1px solid $color-spacer; &.empty { @@ -44,22 +32,5 @@ vn-fetched-tags { } } } - @media screen and (max-width: 1600px) { - flex-direction: column; - - & > vn-one { - padding-bottom: 3px - } - & > vn-auto { - white-space: initial; - padding-left: 0; - flex-wrap: wrap; - justify-content: center; - - & > .inline-tag { - margin: 1px; - } - } - } } } \ No newline at end of file diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index 770405e3a..d709de814 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -22,13 +22,13 @@ model="model"> -
+
- Item ID - Item + Item ID + Description Warehouse P.P.U. P.P.P. @@ -40,7 +40,7 @@ - + - - - - - + + {{price.name}} + +

{{price.subName}}

+
+ +
Id Grouping Packing - Description + Description Stems Size Niche @@ -50,12 +50,15 @@ {{::item.grouping | dashIfEmpty}} {{::item.packing | dashIfEmpty}} - + + {{::item.name}} + +

{{::item.subName}}

+
+ item="item" + tabindex="-1">
{{::item.stems}} diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss index c3d65349e..b0b94c19d 100644 --- a/modules/item/front/index/style.scss +++ b/modules/item/front/index/style.scss @@ -21,9 +21,6 @@ vn-item-product { vn-label-value:first-of-type section{ margin-top: 9px; } - vn-fetched-tags vn-horizontal{ - margin-top: 14px; - } } vn-table { diff --git a/modules/order/front/line/index.html b/modules/order/front/line/index.html index 51702e16e..957b59cfe 100644 --- a/modules/order/front/line/index.html +++ b/modules/order/front/line/index.html @@ -21,7 +21,7 @@ Id Description Warehouse - Shipped + Shipped Quantity Price Amount @@ -42,16 +42,19 @@ {{::row.itemFk | zeroFill:6}}
- + + {{::row.item.name}} + +

{{::row.item.subName}}

+
+ tabindex="-1">
- {{::row.warehouse.name}} - {{::row.shipped | date: 'dd/MM/yyyy'}} + {{::row.warehouse.name}} + {{::row.shipped | date: 'dd/MM/yyyy'}} {{::row.quantity}} {{::row.price | currency: 'EUR':2}} diff --git a/modules/order/front/summary/index.html b/modules/order/front/summary/index.html index 6a19b12e3..3f20467d5 100644 --- a/modules/order/front/summary/index.html +++ b/modules/order/front/summary/index.html @@ -98,12 +98,15 @@ {{::row.itemFk | zeroFill:6}} - + + {{::row.item.name}} + +

{{::row.item.subName}}

+
+ tabindex="-1">
{{::row.quantity}} diff --git a/modules/order/front/volume/index.html b/modules/order/front/volume/index.html index f15e4897b..078ac9280 100644 --- a/modules/order/front/volume/index.html +++ b/modules/order/front/volume/index.html @@ -24,31 +24,34 @@ - Item + Item Description - Quantity - m³ per quantity + Quantity + m³ per quantity - + {{::row.itemFk}} - + + {{::row.item.name}} + +

{{::row.item.subName}}

+
+ tabindex="-1">
- {{::row.quantity}} - {{::row.volume | number:3}} + {{::row.quantity}} + {{::row.volume | number:3}}
diff --git a/modules/supplier/front/consumption/index.html b/modules/supplier/front/consumption/index.html index a0df60ea9..9e65fc34f 100644 --- a/modules/supplier/front/consumption/index.html +++ b/modules/supplier/front/consumption/index.html @@ -37,7 +37,7 @@ Entry - {{::entry.id}} + {{::entry.id}} Date {{::entry.shipped | date: 'dd/MM/yyyy'}} Reference @@ -51,10 +51,15 @@ {{::buy.itemName}}
- + + + +

{{::buy.subName}}

+
+ item="::buy" + tabindex="-1">
{{::buy.quantity | dashIfEmpty}} diff --git a/modules/ticket/front/basic-data/step-two/index.html b/modules/ticket/front/basic-data/step-two/index.html index fe0667c49..5bea7bd47 100644 --- a/modules/ticket/front/basic-data/step-two/index.html +++ b/modules/ticket/front/basic-data/step-two/index.html @@ -18,11 +18,15 @@ {{("000000"+sale.itemFk).slice(-6)}} - + + {{::sale.item.name}} + +

{{::sale.item.subName}}

+
+ tabindex="-1">
{{::sale.quantity}} diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index f47521e4d..ac109c334 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -29,12 +29,15 @@ {{sale.itemFk | zeroFill:6}} - + + {{::sale.item.name}} + +

{{::sale.item.subName}}

+
+ tabindex="-1"> diff --git a/modules/ticket/front/sale-checked/index.html b/modules/ticket/front/sale-checked/index.html index 78ed6dfdc..8c65c1a0a 100644 --- a/modules/ticket/front/sale-checked/index.html +++ b/modules/ticket/front/sale-checked/index.html @@ -34,12 +34,15 @@ {{::sale.itemFk | zeroFill:6}}
- + + {{::sale.item.name}} + +

{{::sale.item.subName}}

+
+ tabindex="-1">
{{::sale.quantity}} diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 100021f13..4e80b3565 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -8,7 +8,7 @@ auto-load="true"> - + @@ -39,12 +39,15 @@ {{sale.itemFk | zeroFill:6}}
- + + {{::sale.item.name}} + +

{{::sale.item.subName}}

+
+ tabindex="-1">
{{::sale.quantity}} diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index ed3cbc02b..d7dfa802c 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -58,8 +58,8 @@ - Id - Quantity + Id + Quantity Item Price Disc @@ -97,7 +97,7 @@ zoom-image="{{::$root.imagePath('catalog', '1600x900', sale.itemFk)}}" on-error-src/>
- + {{sale.itemFk}} @@ -117,7 +117,7 @@ - + {{sale.quantity}} - + + {{sale.concept}} + +

{{::sale.subName}}

+
+ tabindex="-1">
diff --git a/modules/ticket/front/sale/style.scss b/modules/ticket/front/sale/style.scss index ea7c65385..a55487978 100644 --- a/modules/ticket/front/sale/style.scss +++ b/modules/ticket/front/sale/style.scss @@ -23,6 +23,25 @@ vn-ticket-sale { margin: 3px; } } + vn-td-editable[vn-fetched-tags] { + & text { + max-width: 430px; + min-width: 150px; + & vn-one { + overflow: hidden; + text-overflow: ellipsis; + font-size: 0.75rem; + } + + & vn-one:nth-child(2) h3 { + color: $color-font-secondary; + text-transform: uppercase; + line-height: initial; + font-size: 0.75rem + } + } + } + vn-dialog.edit { @extend .edit-popover; diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index dcd4470e4..c29735a1b 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -149,12 +149,15 @@
{{::sale.quantity}} - - + {{::sale.item.name}} + +

{{::sale.item.subName}}

+
+ + tabindex="-1">
{{::sale.price | currency: 'EUR':2}} diff --git a/modules/ticket/front/volume/index.html b/modules/ticket/front/volume/index.html index 3378b70a1..eb2a07d26 100644 --- a/modules/ticket/front/volume/index.html +++ b/modules/ticket/front/volume/index.html @@ -42,12 +42,16 @@ {{sale.itemFk | zeroFill:6}}
- - + {{::sale.item.name}} + +

{{::sale.item.subName}}

+
+ + tabindex="-1"> +
{{::sale.quantity}} {{::sale.saleVolume.volume | number:3}}