Fix filter by tag
This commit is contained in:
1 parent
ed0aa8ae7a
commit
559aa0fd36
4 files changed
+17
-21
No files matched your search
@@ -132,6 +132,11 @@ function queryMac(param, value): Expression {
|
||||
];
|
||||
}
|
||||
|
||||
function queryTag(tag: string): Expression {
|
||||
const t = tag.replace(/[^a-zA-Z0-9-]+/g, "_");
|
||||
return ["IS NOT NULL", ["PARAM", `Tags.${t}`]];
|
||||
}
|
||||
|
||||
export function getTip(resource, label): string {
|
||||
let tip;
|
||||
if (resources[resource] && resources[resource][label]) {
|
||||
@@ -156,6 +161,9 @@ export function getTip(resource, label): string {
|
||||
case "mac":
|
||||
tips.push("partial case insensitive MAC address");
|
||||
break;
|
||||
case "tag":
|
||||
tips.push("case sensitive string");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +198,11 @@ export function unpack(resource, label, value): Expression {
|
||||
if (q) res.push(q);
|
||||
}
|
||||
|
||||
if (type.includes("tag")) {
|
||||
const q = queryTag(value);
|
||||
if (q) res.push(q);
|
||||
}
|
||||
|
||||
if (res.length <= 1) return null;
|
||||
else if (res.length === 2) return res[1];
|
||||
else return res;
|
||||
|
||||
Reference in new issue
Block a user