1878 - Implementar autenticación en servicio print
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
bc422e7f38
commit
1f714718bb
|
@ -108,7 +108,10 @@ function runFn(
|
|||
$filter,
|
||||
$interpolate,
|
||||
$window,
|
||||
vnApp) {
|
||||
vnApp,
|
||||
vnToken,
|
||||
vnConfig,
|
||||
aclService) {
|
||||
Object.assign(Component.prototype, {
|
||||
$translate,
|
||||
$q,
|
||||
|
@ -121,7 +124,10 @@ function runFn(
|
|||
$filter,
|
||||
$interpolate,
|
||||
$window,
|
||||
vnApp
|
||||
vnApp,
|
||||
vnToken,
|
||||
vnConfig,
|
||||
aclService
|
||||
});
|
||||
}
|
||||
runFn.$inject = [
|
||||
|
@ -136,7 +142,10 @@ runFn.$inject = [
|
|||
'$filter',
|
||||
'$interpolate',
|
||||
'$window',
|
||||
'vnApp'
|
||||
'vnApp',
|
||||
'vnToken',
|
||||
'vnConfig',
|
||||
'aclService'
|
||||
];
|
||||
|
||||
ngModule.run(runFn);
|
||||
|
|
|
@ -155,7 +155,6 @@ class Controller {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
onUpdateGreugeResponse(response) {
|
||||
if (response == 'accept') {
|
||||
const promises = [];
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import ngModule from '../module';
|
||||
import Component from 'core/lib/component';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $state, $http, $translate, vnApp, aclService, $httpParamSerializer) {
|
||||
this.$scope = $scope;
|
||||
this.$state = $state;
|
||||
this.$http = $http;
|
||||
this.$translate = $translate;
|
||||
this.vnApp = vnApp;
|
||||
this.aclService = aclService;
|
||||
class Controller extends Component {
|
||||
constructor($element, $scope, $httpParamSerializer) {
|
||||
super($element, $scope);
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
|
||||
this.moreOptions = [
|
||||
{callback: this.showPickupOrder, name: 'Show Pickup order'},
|
||||
{callback: this.confirmPickupOrder, name: 'Send Pickup order'},
|
||||
|
@ -22,7 +19,7 @@ class Controller {
|
|||
|
||||
return !hasAclProperty || (hasAclProperty && this.aclService.hasAny([option.acl]));
|
||||
});
|
||||
this.$scope.moreButton.data = options;
|
||||
this.$.moreButton.data = options;
|
||||
}
|
||||
|
||||
onMoreChange(callback) {
|
||||
|
@ -63,7 +60,8 @@ class Controller {
|
|||
showPickupOrder() {
|
||||
const params = {
|
||||
clientId: this.claim.clientFk,
|
||||
claimId: this.claim.id
|
||||
claimId: this.claim.id,
|
||||
authorization: this.vnToken.token
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
let url = `api/report/claim-pickup-order?${serializedParams}`;
|
||||
|
@ -71,7 +69,7 @@ class Controller {
|
|||
}
|
||||
|
||||
confirmPickupOrder() {
|
||||
this.$scope.confirmPickupOrder.show();
|
||||
this.$.confirmPickupOrder.show();
|
||||
}
|
||||
|
||||
sendPickupOrder(response) {
|
||||
|
@ -81,16 +79,14 @@ class Controller {
|
|||
clientId: this.claim.clientFk,
|
||||
claimId: this.claim.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
const url = `email/claim-pickup-order?${serializedParams}`;
|
||||
this.$http.get(url).then(
|
||||
this.$http.get(`email/claim-pickup-order`, {params}).then(
|
||||
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
confirmDeleteClaim() {
|
||||
this.$scope.confirmDeleteClaim.show();
|
||||
this.$.confirmDeleteClaim.show();
|
||||
}
|
||||
|
||||
deleteClaim(response) {
|
||||
|
@ -103,7 +99,7 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService', '$httpParamSerializer'];
|
||||
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnClaimDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -191,7 +191,6 @@ module.exports = Self => {
|
|||
if (socialNameChanged && !isAlpha(changes.socialName))
|
||||
throw new UserError('The socialName has an invalid format');
|
||||
|
||||
|
||||
if (changes.salesPerson === null) {
|
||||
changes.credit = 0;
|
||||
changes.discount = 0;
|
||||
|
@ -238,7 +237,9 @@ module.exports = Self => {
|
|||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http.req;
|
||||
const $t = httpRequest.__;
|
||||
const origin = httpRequest.headers.origin;
|
||||
const headers = httpRequest.headers;
|
||||
const origin = headers.origin;
|
||||
const authorization = headers.authorization;
|
||||
|
||||
const salesPersonId = instance.salesPersonFk;
|
||||
|
||||
|
@ -254,12 +255,14 @@ module.exports = Self => {
|
|||
|
||||
// Send email to client
|
||||
if (!instance.email) return;
|
||||
const serializedParams = httpParamSerializer({
|
||||
const params = {
|
||||
authorization: authorization,
|
||||
clientId: instance.id,
|
||||
recipient: instance.email
|
||||
};
|
||||
await request.get(`${origin}/api/email/payment-update`, {
|
||||
qs: params
|
||||
});
|
||||
const query = `${origin}/api/email/payment-update?${serializedParams}`;
|
||||
await request.get(query);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ class Controller extends Component {
|
|||
constructor($element, $, $httpParamSerializer) {
|
||||
super($element, $);
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
|
||||
this.moreOptions = [
|
||||
{name: 'Simple ticket', callback: this.newTicket},
|
||||
{name: 'Send SMS', callback: this.showSMSDialog},
|
||||
|
@ -72,8 +73,13 @@ class Controller extends Component {
|
|||
|
||||
sendConsumerReport(response) {
|
||||
if (response === 'accept') {
|
||||
const data = {from: this.from, to: this.to, clientId: this.client.id};
|
||||
const serializedParams = this.$httpParamSerializer(data);
|
||||
const params = {
|
||||
authorization: this.vnToken.token,
|
||||
clientId: this.client.id,
|
||||
from: this.from,
|
||||
to: this.to,
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
const url = `api/report/campaign-metrics?${serializedParams}`;
|
||||
window.open(url);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ import ngModule from '../module';
|
|||
import Component from 'core/lib/component';
|
||||
|
||||
class Controller extends Component {
|
||||
constructor($element, $, $httpParamSerializer, vnConfig) {
|
||||
constructor($element, $, $httpParamSerializer) {
|
||||
super($element, $);
|
||||
this.vnConfig = vnConfig;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
|
||||
this.moreOptions = [
|
||||
{name: 'Show entry report', callback: this.showEntryReport}
|
||||
];
|
||||
|
@ -59,6 +59,7 @@ class Controller extends Component {
|
|||
|
||||
showEntryReport() {
|
||||
const params = {
|
||||
authorization: this.vnToken.token,
|
||||
clientId: this.vnConfig.storage.currentUserWorkerId,
|
||||
entryId: this.entry.id
|
||||
};
|
||||
|
@ -68,7 +69,7 @@ class Controller extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig'];
|
||||
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnEntryDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import ngModule from '../module';
|
||||
import Component from 'core/lib/component';
|
||||
|
||||
class Controller extends Component {
|
||||
constructor($element, $scope, $httpParamSerializer) {
|
||||
super($element, $scope);
|
||||
|
||||
class Controller {
|
||||
constructor($, $http, vnApp, $translate, aclService, $httpParamSerializer) {
|
||||
this.$http = $http;
|
||||
this.vnApp = vnApp;
|
||||
this.$translate = $translate;
|
||||
this.$ = $;
|
||||
this.aclService = aclService;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
this.moreOptions = [
|
||||
{callback: this.showRouteReport, name: 'Show route report'},
|
||||
|
@ -39,6 +37,7 @@ class Controller {
|
|||
showRouteReport() {
|
||||
const user = this.route.worker.user;
|
||||
const params = {
|
||||
authorization: this.vnToken.token,
|
||||
clientId: user.id,
|
||||
routeId: this.route.id
|
||||
};
|
||||
|
@ -54,9 +53,7 @@ class Controller {
|
|||
clientId: user.id,
|
||||
routeId: this.route.id
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
const url = `email/driver-route?${serializedParams}`;
|
||||
this.$http.get(url).then(() => {
|
||||
this.$http.get(`email/driver-route`, {params}).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Report sent'));
|
||||
});
|
||||
}
|
||||
|
@ -76,7 +73,7 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer'];
|
||||
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnRouteDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -2,10 +2,10 @@ import ngModule from '../module';
|
|||
import Component from 'core/lib/component';
|
||||
|
||||
class Controller extends Component {
|
||||
constructor($element, $, aclService, $httpParamSerializer) {
|
||||
constructor($element, $, $httpParamSerializer) {
|
||||
super($element, $);
|
||||
this.aclService = aclService;
|
||||
this.$httpParamSerializer = $httpParamSerializer;
|
||||
|
||||
this.moreOptions = [
|
||||
{
|
||||
name: 'Add turn',
|
||||
|
@ -220,7 +220,8 @@ class Controller extends Component {
|
|||
showDeliveryNote() {
|
||||
const params = {
|
||||
clientId: this.ticket.client.id,
|
||||
ticketId: this.ticket.id
|
||||
ticketId: this.ticket.id,
|
||||
authorization: this.vnToken.token
|
||||
};
|
||||
const serializedParams = this.$httpParamSerializer(params);
|
||||
let url = `api/report/delivery-note?${serializedParams}`;
|
||||
|
@ -332,7 +333,7 @@ class Controller extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', 'aclService', '$httpParamSerializer'];
|
||||
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
||||
|
||||
ngModule.component('vnTicketDescriptor', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -3,3 +3,5 @@ require('./date');
|
|||
require('./uppercase');
|
||||
require('./currency');
|
||||
require('./percentage');
|
||||
require('./number');
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
const Vue = require('vue');
|
||||
const config = require('../config');
|
||||
const defaultLocale = config.i18n.locale;
|
||||
|
||||
Vue.filter('number', function(value, locale = defaultLocale) {
|
||||
if (!locale) locale = defaultLocale;
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'decimal'
|
||||
}).format(parseFloat(value));
|
||||
});
|
|
@ -21,7 +21,6 @@ module.exports = app => {
|
|||
const authorization = getToken(request);
|
||||
const query = `SELECT userId, ttl, created
|
||||
FROM salix.AccessToken WHERE id = ?`;
|
||||
console.log('auth');
|
||||
|
||||
try {
|
||||
const authToken = await db.findOne(query, [authorization]);
|
||||
|
@ -36,17 +35,25 @@ module.exports = app => {
|
|||
});
|
||||
|
||||
function getToken(request) {
|
||||
return request.headers.authorization || request.query.authorization;
|
||||
const headers = request.headers;
|
||||
const params = request.query;
|
||||
|
||||
if (headers.authorization)
|
||||
params.authorization = headers.authorization;
|
||||
|
||||
return headers.authorization || params.authorization;
|
||||
}
|
||||
|
||||
function isTokenExpired(created, ttl) {
|
||||
let date = new Date(created);
|
||||
let currentDate = new Date();
|
||||
const date = new Date(created);
|
||||
const currentDate = new Date();
|
||||
|
||||
date.setSeconds(date.getSeconds() + ttl);
|
||||
|
||||
if (currentDate > date)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mount methods
|
||||
|
|
|
@ -37,6 +37,9 @@ module.exports = {
|
|||
'attachment': attachment.build()
|
||||
},
|
||||
props: {
|
||||
authorization: {
|
||||
required: true
|
||||
},
|
||||
clientId: {
|
||||
required: true
|
||||
},
|
||||
|
|
|
@ -37,11 +37,14 @@ module.exports = {
|
|||
'attachment': attachment.build()
|
||||
},
|
||||
props: {
|
||||
authorization: {
|
||||
required: true
|
||||
},
|
||||
clientId: {
|
||||
required: true
|
||||
},
|
||||
companyId: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<th>{{$t('reference')}}</th>
|
||||
<th class="number">{{$t('quantity')}}</th>
|
||||
<th class="number">{{$t('claims')}}</th>
|
||||
<th>{{$t('concept')}}</th>
|
||||
<th width="50%">{{$t('concept')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-for="sale in sales" v-bind:key="sale.id">
|
||||
|
@ -69,7 +69,7 @@
|
|||
<td class="font gray">{{sale.id}}</td>
|
||||
<td class="number">{{sale.quantity}}</td>
|
||||
<td class="number">{{sale.claimQuantity}}</td>
|
||||
<td>{{sale.concept}}</td>
|
||||
<td width="50%">{{sale.concept}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -63,12 +63,12 @@
|
|||
<table class="column-oriented">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{{$t('boxes')}}</td>
|
||||
<td class="number">{{$t('boxes')}}</td>
|
||||
<td class="number">{{$t('packing')}}</td>
|
||||
<td width="50%">{{$t('concept')}}</td>
|
||||
<td class="number">{{$t('quantity')}}</td>
|
||||
<td class="number">{{$t('price')}}</td>
|
||||
<td class="number">{{$t('amount')}}</td>
|
||||
<td width="10%" class="number">{{$t('quantity')}}</td>
|
||||
<td width="15%" class="number">{{$t('price')}}</td>
|
||||
<td width="15%" class="number">{{$t('amount')}}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-for="buy in buys">
|
||||
|
@ -76,9 +76,9 @@
|
|||
<td class="number">{{buy.box}}</td>
|
||||
<td class="number">{{buy.packing}}</td>
|
||||
<td width="50%">{{buy.itemName}}</td>
|
||||
<td class="number">{{buy.quantity}}</td>
|
||||
<td class="number">{{buy.buyingValue | currency('EUR', locale)}}</td>
|
||||
<td class="number">{{buy.buyingValue * buy.quantity | currency('EUR', locale)}}</td>
|
||||
<td width="10%" class="number">{{buy.quantity | number}}</td>
|
||||
<td width="15%" class="number">{{buy.buyingValue | currency('EUR', locale)}}</td>
|
||||
<td width="15%" class="number">{{buy.buyingValue * buy.quantity | currency('EUR', locale)}}</td>
|
||||
</tr>
|
||||
<tr class="description">
|
||||
<td colspan="2">
|
||||
|
|
Loading…
Reference in New Issue