Add filter by namespace #160 (#215)

This commit is contained in:
Tomek Święcicki
2019-03-08 19:44:28 +01:00
committed by Henning Jacobs
parent b3952a2d73
commit d257337a5a
2 changed files with 16 additions and 4 deletions

View File

@@ -74,11 +74,22 @@ export default class App {
return labels && labels[name] === value
}
namespaceMatches(pod, value) {
return pod.namespace === value
}
createMatchesFunctionForQuery(query) {
if (query.includes('=')) {
const labelAndValue = query.split('=', 2)
return pod => this.labelMatches(pod, labelAndValue[0], labelAndValue[1])
} else {
if (query.startsWith('namespace=')) {
// filter by namespace
const value = query.split('namespace=', 2)[1]
return pod => this.namespaceMatches(pod, value)
} else if (query.includes('=')) {
// filter by label
const [label, value] = query.split('=', 2)
return pod => this.labelMatches(pod, label, value)
}
else {
// filter by name
return pod => this.nameMatches(pod, query)
}
}

View File

@@ -35,6 +35,7 @@ You can filter by:
* name
* labels - when query includes ``=``, e.g. ``env=prod``
* namespace - when query starts with ``namespace``, e.g. ``namespace=default``
The pod filter is persisted in the location bar (``#q=..`` query parameter) which allows to conveniently send the filtered view to other users (e.g. for troubleshooting).