fix(core.gbapp): #344 fix regarding SET FILTER keyword.
This commit is contained in:
parent
f2d6bbe47a
commit
db7ed36707
5 changed files with 66 additions and 39 deletions
|
@ -536,7 +536,7 @@ export class DialogKeywords {
|
||||||
this['id'] = new SystemKeywords().getRandomId();
|
this['id'] = new SystemKeywords().getRandomId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private isUserSystemParam(name: string): Boolean {
|
public static isUserSystemParam(name: string): Boolean {
|
||||||
const names = [
|
const names = [
|
||||||
'welcomed',
|
'welcomed',
|
||||||
'loaded',
|
'loaded',
|
||||||
|
@ -553,7 +553,7 @@ export class DialogKeywords {
|
||||||
return names.indexOf(name) > -1;
|
return names.indexOf(name) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setOption({ pid, name, value }) {
|
public static async setOption({ pid, name, value }) {
|
||||||
// if (this.isUserSystemParam(name)) {
|
// if (this.isUserSystemParam(name)) {
|
||||||
// throw new Error(`Not possible to define ${name} as it is a reserved system param name.`);
|
// throw new Error(`Not possible to define ${name} as it is a reserved system param name.`);
|
||||||
// }
|
// }
|
||||||
|
@ -564,7 +564,7 @@ export class DialogKeywords {
|
||||||
return { min, user, params };
|
return { min, user, params };
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getOption({ pid, name }) {
|
public static async getOption({ pid, name }) {
|
||||||
if (this.isUserSystemParam(name)) {
|
if (this.isUserSystemParam(name)) {
|
||||||
throw new Error(`Not possible to retrieve ${name} system param.`);
|
throw new Error(`Not possible to retrieve ${name} system param.`);
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ export class DialogKeywords {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async setMaxLines({ pid, count }) {
|
public async setMaxLines({ pid, count }) {
|
||||||
await this.setOption({ pid, name: 'maxLines', value: count });
|
await DialogKeywords.setOption({ pid, name: 'maxLines', value: count });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -590,7 +590,7 @@ export class DialogKeywords {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async setUserParam({ pid, name, value }) {
|
public async setUserParam({ pid, name, value }) {
|
||||||
await this.setOption({ pid, name, value });
|
await DialogKeywords.setOption({ pid, name, value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -600,7 +600,7 @@ export class DialogKeywords {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async getUserParam({ pid, name }) {
|
public async getUserParam({ pid, name }) {
|
||||||
await this.getOption({ pid, name });
|
await DialogKeywords.getOption({ pid, name });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -610,7 +610,18 @@ export class DialogKeywords {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async setMaxColumns({ pid, count }) {
|
public async setMaxColumns({ pid, count }) {
|
||||||
await this.setOption({ pid, name: 'setMaxColumns', value: count });
|
await DialogKeywords.setOption({ pid, name: 'setMaxColumns', value: count });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a custom user filter for SET calls.
|
||||||
|
*
|
||||||
|
* @example SET FILTER "ColumnName=33"
|
||||||
|
* SET "file.xlsx", "C", "200000"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public async setFilter({ pid, value }) {
|
||||||
|
await DialogKeywords.setOption({ pid, name: 'filter', value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -621,7 +632,7 @@ export class DialogKeywords {
|
||||||
*/
|
*/
|
||||||
public async setWholeWord({ pid, on }) {
|
public async setWholeWord({ pid, on }) {
|
||||||
const value = on.trim() === 'on';
|
const value = on.trim() === 'on';
|
||||||
await this.setOption({ pid, name: 'wholeWord', value: value });
|
await DialogKeywords.setOption({ pid, name: 'wholeWord', value: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -632,7 +643,7 @@ export class DialogKeywords {
|
||||||
*/
|
*/
|
||||||
public async setFilterTypes({ pid, types }) {
|
public async setFilterTypes({ pid, types }) {
|
||||||
const value = types;
|
const value = types;
|
||||||
await this.setOption({ pid, name: 'filterTypes', value: value });
|
await DialogKeywords.setOption({ pid, name: 'filterTypes', value: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -643,7 +654,7 @@ export class DialogKeywords {
|
||||||
*/
|
*/
|
||||||
public async setTheme({ pid, theme }) {
|
public async setTheme({ pid, theme }) {
|
||||||
const value = theme.trim();
|
const value = theme.trim();
|
||||||
await this.setOption({ pid, name: 'theme', value: value });
|
await DialogKeywords.setOption({ pid, name: 'theme', value: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -654,7 +665,7 @@ export class DialogKeywords {
|
||||||
*/
|
*/
|
||||||
public async setTranslatorOn({ pid, on }) {
|
public async setTranslatorOn({ pid, on }) {
|
||||||
const value = on.trim() === 'on';
|
const value = on.trim() === 'on';
|
||||||
await this.setOption({ pid, name: 'translatorOn', value: value });
|
await DialogKeywords.setOption({ pid, name: 'translatorOn', value: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1130,11 +1141,7 @@ export class DialogKeywords {
|
||||||
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName));
|
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(localName));
|
||||||
|
|
||||||
GBLog.info(`BASIC: WebAutomation: Sending the file ${url} to mobile ${mobile}.`);
|
GBLog.info(`BASIC: WebAutomation: Sending the file ${url} to mobile ${mobile}.`);
|
||||||
|
} else if (filename.url) {
|
||||||
}
|
|
||||||
|
|
||||||
else if (filename.url)
|
|
||||||
{
|
|
||||||
url = filename.url;
|
url = filename.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,7 +1185,6 @@ export class DialogKeywords {
|
||||||
await min.conversationalService['sendOnConversation'](min, user, reply);
|
await min.conversationalService['sendOnConversation'](min, user, reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Generates a new QRCode.
|
* Generates a new QRCode.
|
||||||
|
|
|
@ -268,6 +268,8 @@ export class GBVMService extends GBService {
|
||||||
let today = this.today;
|
let today = this.today;
|
||||||
let now = this.now;
|
let now = this.now;
|
||||||
|
|
||||||
|
// Transfers NLP auto variables into global object.
|
||||||
|
|
||||||
for(i in this.variables) {
|
for(i in this.variables) {
|
||||||
global[i] = this.variables[i];
|
global[i] = this.variables[i];
|
||||||
}
|
}
|
||||||
|
@ -286,10 +288,9 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
${code}
|
${code}
|
||||||
|
|
||||||
await wa.getCloseHandles({pid: pid});
|
await wa.closeHandles({pid: pid});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
`;
|
`;
|
||||||
Fs.writeFileSync(jsfile, code);
|
Fs.writeFileSync(jsfile, code);
|
||||||
GBLogEx.info(min, `[GBVMService] Finished loading of ${filename}, JavaScript from Word: \n ${code}`);
|
GBLogEx.info(min, `[GBVMService] Finished loading of ${filename}, JavaScript from Word: \n ${code}`);
|
||||||
|
|
|
@ -432,6 +432,13 @@ export class KeywordsExpressions {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
keywords[i++] = [
|
||||||
|
/^\s*(set filter)(\s*)(.*)/gim,
|
||||||
|
($0, $1, $2, $3) => {
|
||||||
|
return `await dk.setFilter ({pid: pid, ${$3}})`;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
keywords[i++] = [
|
keywords[i++] = [
|
||||||
/^\s*set param \s*(.*)\s*as\s*(.*)/gim,
|
/^\s*set param \s*(.*)\s*as\s*(.*)/gim,
|
||||||
($0, $1, $2) => {
|
($0, $1, $2) => {
|
||||||
|
|
|
@ -483,6 +483,16 @@ export class SystemKeywords {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add a semaphore between FILTER and SET.
|
||||||
|
|
||||||
|
// Processes FILTER option to ensure parallel SET calls.
|
||||||
|
|
||||||
|
const filter = await DialogKeywords.getOption({ pid, name });
|
||||||
|
if (filter) {
|
||||||
|
const row = this.find({ pid, handle: null, args: [filter] });
|
||||||
|
address += row['line'];
|
||||||
|
}
|
||||||
|
|
||||||
// Handles calls for BASIC persistence on sheet files.
|
// Handles calls for BASIC persistence on sheet files.
|
||||||
|
|
||||||
GBLog.info(`BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `);
|
GBLog.info(`BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `);
|
||||||
|
@ -589,7 +599,7 @@ export class SystemKeywords {
|
||||||
const address = `A2:${this.numberToLetters(args.length - 1)}2`;
|
const address = `A2:${this.numberToLetters(args.length - 1)}2`;
|
||||||
for (let index = 0; index < args.length; index++) {
|
for (let index = 0; index < args.length; index++) {
|
||||||
let value = args[index];
|
let value = args[index];
|
||||||
if (value && await this.isValidDate({pid, dt:value})) {
|
if (value && (await this.isValidDate({ pid, dt: value }))) {
|
||||||
value = `'${value}`;
|
value = `'${value}`;
|
||||||
}
|
}
|
||||||
body.values[0][index] = value;
|
body.values[0][index] = value;
|
||||||
|
@ -622,7 +632,8 @@ export class SystemKeywords {
|
||||||
} else {
|
} else {
|
||||||
GBLog.info(`BASIC: GET '${addressOrHeaders}' in '${file}'.`);
|
GBLog.info(`BASIC: GET '${addressOrHeaders}' in '${file}'.`);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const botId = min.instance.botId;''
|
const botId = min.instance.botId;
|
||||||
|
('');
|
||||||
const path = DialogKeywords.getGBAIPath(botId, 'gbdata');
|
const path = DialogKeywords.getGBAIPath(botId, 'gbdata');
|
||||||
|
|
||||||
let document = await this.internalGetDocument(client, baseUrl, path, file);
|
let document = await this.internalGetDocument(client, baseUrl, path, file);
|
||||||
|
@ -1103,7 +1114,6 @@ export class SystemKeywords {
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
let path = DialogKeywords.getGBAIPath(min.botId, `gbdrive`);
|
let path = DialogKeywords.getGBAIPath(min.botId, `gbdrive`);
|
||||||
|
|
||||||
|
|
||||||
// Extracts each part of path to call create folder to each
|
// Extracts each part of path to call create folder to each
|
||||||
// one of them.
|
// one of them.
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,11 @@ export class WebAutomationServices {
|
||||||
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
public async getCloseHandles({ pid }) {
|
public async closeHandles({ pid }) {
|
||||||
const { min, user } = await DialogKeywords.getProcessInfo(pid);
|
const { min, user } = await DialogKeywords.getProcessInfo(pid);
|
||||||
|
|
||||||
|
await DialogKeywords.setOption({ pid, name: "filter", value: null });
|
||||||
|
|
||||||
// Releases previous allocated OPEN semaphores.
|
// Releases previous allocated OPEN semaphores.
|
||||||
|
|
||||||
let keys = Object.keys(GBServer.globals.webSessions);
|
let keys = Object.keys(GBServer.globals.webSessions);
|
||||||
|
|
Loading…
Add table
Reference in a new issue