Attachment fixes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2022-11-10 11:51:14 +01:00
parent 133897c29f
commit 303020a731
15 changed files with 101 additions and 71 deletions

20
package-lock.json generated
View File

@ -60,6 +60,7 @@
"del": "^2.2.2", "del": "^2.2.2",
"eslint": "^7.11.0", "eslint": "^7.11.0",
"eslint-config-google": "^0.11.0", "eslint-config-google": "^0.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jasmine": "^2.10.1", "eslint-plugin-jasmine": "^2.10.1",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"fancy-log": "^1.3.2", "fancy-log": "^1.3.2",
@ -7231,6 +7232,18 @@
"eslint": ">=5.4.0" "eslint": ">=5.4.0"
} }
}, },
"node_modules/eslint-config-prettier": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
"peerDependencies": {
"eslint": ">=7.0.0"
}
},
"node_modules/eslint-plugin-jasmine": { "node_modules/eslint-plugin-jasmine": {
"version": "2.10.1", "version": "2.10.1",
"dev": true, "dev": true,
@ -31744,6 +31757,13 @@
"dev": true, "dev": true,
"requires": {} "requires": {}
}, },
"eslint-config-prettier": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true,
"requires": {}
},
"eslint-plugin-jasmine": { "eslint-plugin-jasmine": {
"version": "2.10.1", "version": "2.10.1",
"dev": true "dev": true

View File

@ -63,6 +63,7 @@
"del": "^2.2.2", "del": "^2.2.2",
"eslint": "^7.11.0", "eslint": "^7.11.0",
"eslint-config-google": "^0.11.0", "eslint-config-google": "^0.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jasmine": "^2.10.1", "eslint-plugin-jasmine": "^2.10.1",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"fancy-log": "^1.3.2", "fancy-log": "^1.3.2",

View File

@ -1,9 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html v-bind:lang="$i18n.locale"> <html v-bind:lang="$i18n.locale">
<head> <head>
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width" />
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no" />
</head> </head>
<body> <body>
@ -11,7 +10,6 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<!-- Empty block -->
<div class="grid-row"> <div class="grid-row">
<div class="grid-block empty"></div> <div class="grid-block empty"></div>
</div> </div>
@ -30,7 +28,6 @@
</div> </div>
</div> </div>
</slot> </slot>
<!-- Empty block -->
<div class="grid-row"> <div class="grid-row">
<div class="grid-block empty"></div> <div class="grid-block empty"></div>
</div> </div>
@ -39,5 +36,4 @@
</tbody> </tbody>
</table> </table>
</body> </body>
</html> </html>

View File

@ -1,4 +1,5 @@
const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');

View File

@ -32,7 +32,7 @@ class Email extends Component {
const rendered = await this.render(); const rendered = await this.render();
const attachments = []; const attachments = [];
const getAttachments = async(componentPath, files) => { const getAttachments = async(componentPath, files) => {
for (file of files) { for (const file of files) {
const fileCopy = Object.assign({}, file); const fileCopy = Object.assign({}, file);
const fileName = fileCopy.filename; const fileName = fileCopy.filename;
@ -54,14 +54,21 @@ class Email extends Component {
} }
}; };
async function getSubcomponentAttachments(instance) {
if (instance.components) { if (instance.components) {
const components = instance.components; const components = instance.components;
for (let componentName in components) { for (let componentName in components) {
const component = components[componentName]; const component = components[componentName];
const componentPath = `./components/${componentName}`; const componentPath = `./components/${componentName}`;
await getAttachments(componentPath, component.attachments); await getAttachments(componentPath, component.attachments);
if (component.components)
await getSubcomponentAttachments(component)
} }
} }
}
await getSubcomponentAttachments(instance)
if (this.attachments) if (this.attachments)
await getAttachments(this.path, this.attachments); await getAttachments(this.path, this.attachments);

View File

@ -0,0 +1,6 @@
[
{
"filename": "client-debt-statement.pdf",
"component": "client-debt-statement"
}
]

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1> <h1>{{ $t('title') }}</h1>
@ -28,4 +28,4 @@
</attachment> </attachment>
</div> </div>
</div> </div>
</report-body> </email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1> <h1>{{ $t('title') }}</h1>
@ -7,8 +7,10 @@
<p v-html="$t('totalResolved', [resolvedTickets])"></p> <p v-html="$t('totalResolved', [resolvedTickets])"></p>
<p v-html="$t('grafanaLink')"></p> <p v-html="$t('grafanaLink')"></p>
<div class="external-link vn-pa-sm vn-m-md"> <div class="external-link vn-pa-sm vn-m-md">
<a v-bind:href="'https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from=' + startedTime + '&to=' + endedTime" <a
target="_blank"> v-bind:href="'https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from=' + startedTime + '&to=' + endedTime"
target="_blank"
>
https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from={{startedTime}}&to={{endedTime}} https://grafana.verdnatura.es/d/2kaHDi9Mk/osticket?orgId=1&from={{startedTime}}&to={{endedTime}}
</a> </a>
</div> </div>
@ -39,12 +41,8 @@
<tr> <tr>
<td>{{ticket.author}}</td> <td>{{ticket.author}}</td>
<td class="font light-gray"> <td class="font light-gray">
<div v-bind:title="$t('opened')"> <div v-bind:title="$t('opened')">&#128275; {{ticket.created | date('%d-%m-%Y %H:%M')}}</div>
&#128275; {{ticket.created | date('%d-%m-%Y %H:%M')}} <div v-bind:title="$t('closed')">&#128274; {{ticket.closed | date('%d-%m-%Y %H:%M')}}</div>
</div>
<div v-bind:title="$t('closed')">
&#128274; {{ticket.closed | date('%d-%m-%Y %H:%M')}}
</div>
</td> </td>
<td> <td>
<a v-bind:href="'https://cau.verdnatura.es/scp/tickets.php?id=' + ticket.ticket_id"> <a v-bind:href="'https://cau.verdnatura.es/scp/tickets.php?id=' + ticket.ticket_id">
@ -58,4 +56,4 @@
</table> </table>
</div> </div>
</div> </div>
</report-body> </email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1> <h1>{{ $t('title') }}</h1>
@ -25,4 +25,4 @@
<p>{{ $t('notifyAnError') }}</p> <p>{{ $t('notifyAnError') }}</p>
</div> </div>
</div> </div>
</report-body> </email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1> <h1>{{ $t('title') }}</h1>
@ -46,4 +46,4 @@
</attachment> </attachment>
</div> </div>
</div> </div>
</report-body> </email-body>

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1> <h1>{{ $t('title') }}</h1>
@ -9,9 +9,13 @@
</div> </div>
<div class="grid-row" v-if="isPreview"> <div class="grid-row" v-if="isPreview">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<attachment v-for="attachment in attachments" v-bind:key="attachment.filename" <attachment
v-bind:attachment="attachment" v-bind:args="$props"> v-for="attachment in attachments"
v-bind:key="attachment.filename"
v-bind:attachment="attachment"
v-bind:args="$props"
>
</attachment> </attachment>
</div> </div>
</div> </div>
</report-body> </email-body>

View File

@ -8,8 +8,7 @@ module.exports = {
return {attachments}; return {attachments};
}, },
components: { components: {
'email-body': emailBody.build(), 'email-body': emailBody.build()
'attachment': attachments.build()
}, },
props: { props: {
id: { id: {

View File

@ -1,4 +1,4 @@
<report-body v-bind="$props"> <email-body v-bind="$props">
<div class="grid-row"> <div class="grid-row">
<div class="grid-block vn-pa-ml"> <div class="grid-block vn-pa-ml">
<h1>{{ $t('title') }}</h1> <h1>{{ $t('title') }}</h1>
@ -6,4 +6,4 @@
<p v-html="$t('description', [minDate, maxDate])"></p> <p v-html="$t('description', [minDate, maxDate])"></p>
</div> </div>
</div> </div>
</report-body> </email-body>

View File

@ -1,6 +1,5 @@
const Component = require(`vn-print/core/component`); const Component = require(`vn-print/core/component`);
const reportBody = new Component('report-body'); const reportBody = new Component('report-body')
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
const rptCreditRequest = { const rptCreditRequest = {
@ -14,7 +13,6 @@ const rptCreditRequest = {
}, },
components: { components: {
'report-body': reportBody.build(), 'report-body': reportBody.build(),
'report-header': reportHeader.build(),
'report-footer': reportFooter.build() 'report-footer': reportFooter.build()
} }
}; };