refs #4550 Added URL params
This commit is contained in:
parent
1a379e8091
commit
2552049afb
|
@ -43,12 +43,12 @@ class PrintServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getToken() {
|
async getToken() {
|
||||||
const salix = this.conf.salix
|
const salix = this.conf.salix;
|
||||||
let response = await axios.post(`${salix.url}/api/Accounts/login`, {
|
let response = await axios.post(`${salix.url}/api/Accounts/login`, {
|
||||||
user: salix.user,
|
user: salix.user,
|
||||||
password: salix.password
|
password: salix.password
|
||||||
});
|
});
|
||||||
this.token = response.data.token
|
this.token = response.data.token;
|
||||||
}
|
}
|
||||||
async onDbError(err) {
|
async onDbError(err) {
|
||||||
switch(err.code) {
|
switch(err.code) {
|
||||||
|
@ -107,21 +107,35 @@ class PrintServer {
|
||||||
for (const row of res[0])
|
for (const row of res[0])
|
||||||
args[row.name] = row.value;
|
args[row.name] = row.value;
|
||||||
try {
|
try {
|
||||||
|
// Path params
|
||||||
|
const usedParams = new Set();
|
||||||
let methodPath = this.method.replace(/{\w+}/g, function(match) {
|
let methodPath = this.method.replace(/{\w+}/g, function(match) {
|
||||||
const key = match.substr(1, match.length - 2);
|
const key = match.substr(1, match.length - 2);
|
||||||
const value = args[key];
|
const value = args[key];
|
||||||
|
usedParams.add(key);
|
||||||
return value !== undefined ? value : match;
|
return value !== undefined ? value : match;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// URL params
|
||||||
|
let params = {
|
||||||
|
access_token: this.token,
|
||||||
|
userFk: printJob.userFk
|
||||||
|
};
|
||||||
|
for (const key in args) {
|
||||||
|
if (!usedParams.has(key))
|
||||||
|
params[key] = args[key];
|
||||||
|
}
|
||||||
|
const urlParams = new URLSearchParams(params);
|
||||||
|
|
||||||
|
// Request
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `${conf.salix.url}/api/${methodPath}?access_token=${this.token}`,
|
url: `${conf.salix.url}/api/${methodPath}?${urlParams.toString()}`,
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Accept': 'application/pdf'
|
'Accept': 'application/pdf'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.pdfData = response.data
|
this.pdfData = response.data
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
|
@ -3,7 +3,8 @@ SELECT pq.id,
|
||||||
p.name printer,
|
p.name printer,
|
||||||
pqa.name arg,
|
pqa.name arg,
|
||||||
pqa.value,
|
pqa.value,
|
||||||
r.method
|
r.method,
|
||||||
|
pq.workerFk userFk
|
||||||
FROM printQueue pq
|
FROM printQueue pq
|
||||||
JOIN report r ON r.id = pq.reportFk
|
JOIN report r ON r.id = pq.reportFk
|
||||||
JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id
|
JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id
|
||||||
|
|
Loading…
Reference in New Issue