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