feat(getUrl): se añade el metodo getUrl refs #5979
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
9870a0e60a
commit
488181e1b6
|
@ -26,7 +26,7 @@ module.exports = Self => {
|
|||
|
||||
Self.getTickets = async(ctx, id, print, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const url = Self.app.models.Application.getUrl();
|
||||
const url = Self.app.models.Url.getUrl();
|
||||
const $t = ctx.req.__;
|
||||
const myOptions = {};
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getUrl', {
|
||||
Self.remoteMethod('getUrl', {
|
||||
description: 'Returns the colling app name',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'appName',
|
||||
arg: 'app',
|
||||
type: 'string',
|
||||
required: false
|
||||
}
|
||||
|
@ -18,13 +19,14 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
Self.getUrl = async(appName = 'salix') => {
|
||||
console.log('appName: ', appName);
|
||||
const {url} = await Self.app.models.Url.findOne({
|
||||
|
||||
where: {
|
||||
appName,
|
||||
enviroment: process.env.NODE_ENV || 'development'
|
||||
}
|
||||
});
|
||||
console.log('url: ', url);
|
||||
return url;
|
||||
};
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/url/getUrl')(Self);
|
||||
};
|
|
@ -89,7 +89,7 @@ module.exports = function(Self) {
|
|||
};
|
||||
|
||||
Self.on('resetPasswordRequest', async function(info) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const defaultHash = '/reset-password?access_token=$token$';
|
||||
const recoverHashes = {
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/application/status')(Self);
|
||||
require('../methods/application/post')(Self);
|
||||
require('../methods/application/getUrl')(Self);
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ module.exports = Self => {
|
|||
Self.claimPickupEmail = async ctx => {
|
||||
const models = Self.app.models;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
|
|
|
@ -94,7 +94,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = ticket.client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const message = $t('Created claim', {
|
||||
claimId: newClaim.id,
|
||||
|
|
|
@ -56,7 +56,7 @@ module.exports = Self => {
|
|||
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const nickname = address && address.nickname || destination.description;
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = $t('Sent units from ticket', {
|
||||
quantity: sale.quantity,
|
||||
concept: sale.concept,
|
||||
|
|
|
@ -4,7 +4,7 @@ const LoopBackContext = require('loopback-context');
|
|||
describe('Update Claim', () => {
|
||||
let url;
|
||||
beforeAll(async() => {
|
||||
url = await app.models.Application.getUrl();
|
||||
url = await app.models.Url.getUrl();
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
|
|
|
@ -114,7 +114,7 @@ module.exports = Self => {
|
|||
|
||||
async function notifyStateChange(ctx, workerId, claim, state) {
|
||||
const models = Self.app.models;
|
||||
const url = await models.Application.getUrl();
|
||||
const url = await models.Url.getUrl();
|
||||
const $t = ctx.req.__; // $translate
|
||||
|
||||
const message = $t(`Claim state has changed to ${state}`, {
|
||||
|
@ -128,7 +128,7 @@ module.exports = Self => {
|
|||
|
||||
async function notifyPickUp(ctx, workerId, claim) {
|
||||
const models = Self.app.models;
|
||||
const url = await models.Application.getUrl('lilium');
|
||||
const url = await models.Url.getUrl('lilium');
|
||||
const $t = ctx.req.__; // $translate
|
||||
|
||||
const message = $t('Claim will be picked', {
|
||||
|
|
|
@ -353,7 +353,7 @@ module.exports = Self => {
|
|||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http.req;
|
||||
const $t = httpRequest.__;
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const salesPersonId = instance.salesPersonFk;
|
||||
|
||||
|
@ -395,7 +395,7 @@ module.exports = Self => {
|
|||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http.req;
|
||||
const $t = httpRequest.__;
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const models = Self.app.models;
|
||||
|
||||
let previousWorker = {name: $t('None')};
|
||||
|
|
|
@ -57,7 +57,7 @@ module.exports = function(Self) {
|
|||
|
||||
const httpRequest = httpCtx.req.http.req;
|
||||
const $t = httpRequest.__;
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const fullPath = `${url}client/${client.id}/credit-insurance/index`;
|
||||
const message = $t('MESSAGE_INSURANCE_CHANGE', {
|
||||
clientId: client.id,
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = Self => {
|
|||
};
|
||||
await Self.invoiceEmail(ctx, ref);
|
||||
} catch (err) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = ctx.req.__('Mail not sent', {
|
||||
clientId: client.id,
|
||||
clientUrl: `${url}claim/${id}/summary`
|
||||
|
|
|
@ -68,7 +68,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = ticket.client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const message = $t('Deleted sales from ticket', {
|
||||
ticketId: ticketId,
|
||||
|
|
|
@ -85,7 +85,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = ticket.client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const message = $t('Changed sale reserved state', {
|
||||
ticketId: ticketId,
|
||||
|
|
|
@ -98,7 +98,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = $t('Changed sale price', {
|
||||
ticketId: sale.ticket().id,
|
||||
itemId: sale.itemFk,
|
||||
|
|
|
@ -80,7 +80,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = $t('Changed sale quantity', {
|
||||
ticketId: sale.ticket().id,
|
||||
itemId: sale.itemFk,
|
||||
|
|
|
@ -84,7 +84,7 @@ module.exports = Self => {
|
|||
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
||||
await Self.rawSql(query, [sale.id], myOptions);
|
||||
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const requesterId = request.requesterFk;
|
||||
|
||||
const message = $t('Bought units from buy request', {
|
||||
|
|
|
@ -50,7 +50,7 @@ module.exports = Self => {
|
|||
const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions);
|
||||
await request.updateAttributes(params, myOptions);
|
||||
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const requesterId = request.requesterFk;
|
||||
|
||||
const message = $t('Deny buy request', {
|
||||
|
|
|
@ -94,7 +94,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = ticket.client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
const message = $t('Added sale to ticket', {
|
||||
ticketId: id,
|
||||
|
|
|
@ -237,7 +237,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPersonId = originalTicket.client().salesPersonFk;
|
||||
if (salesPersonId) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
|
||||
let changesMade = '';
|
||||
for (let change in newProperties) {
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = Self => {
|
|||
Self.merge = async(ctx, tickets, options) => {
|
||||
const httpRequest = ctx.req;
|
||||
const $t = httpRequest.__;
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
|||
// Send notification to salesPerson
|
||||
const salesPersonId = ticket.client().salesPersonFk;
|
||||
if (salesPersonId) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = $t(`I have restored the ticket id`, {
|
||||
id: id,
|
||||
url: `${url}ticket/${id}/summary`
|
||||
|
|
|
@ -119,7 +119,7 @@ module.exports = Self => {
|
|||
// Send notification to salesPerson
|
||||
const salesPersonUser = ticket.client().salesPersonUser();
|
||||
if (salesPersonUser && sales.length) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = $t(`I have deleted the ticket id`, {
|
||||
id: id,
|
||||
url: `${url}ticket/${id}/summary`
|
||||
|
|
|
@ -165,7 +165,7 @@ module.exports = Self => {
|
|||
|
||||
const salesPerson = ticket.client().salesPersonUser();
|
||||
if (salesPerson) {
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const message = $t('Changed sale discount', {
|
||||
ticketId: id,
|
||||
ticketUrl: `${url}ticket/${id}/sale`,
|
||||
|
|
|
@ -109,7 +109,7 @@ module.exports = Self => {
|
|||
const absenceType = await models.AbsenceType.findById(args.absenceTypeId, null, myOptions);
|
||||
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||
const subordinated = await models.VnUser.findById(id, null, myOptions);
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const body = $t('Created absence', {
|
||||
author: account.nickname,
|
||||
employee: subordinated.nickname,
|
||||
|
|
|
@ -60,7 +60,7 @@ module.exports = Self => {
|
|||
const absenceType = await models.AbsenceType.findById(absence.dayOffTypeFk, null, myOptions);
|
||||
const account = await models.VnUser.findById(userId, null, myOptions);
|
||||
const subordinated = await models.VnUser.findById(labour.workerFk, null, myOptions);
|
||||
const url = await Self.app.models.Application.getUrl();
|
||||
const url = await Self.app.models.Url.getUrl();
|
||||
const body = $t('Deleted absence', {
|
||||
author: account.nickname,
|
||||
employee: subordinated.nickname,
|
||||
|
|
Loading…
Reference in New Issue