#55 persist search query in location.hash
This commit is contained in:
12
app.py
12
app.py
@@ -109,6 +109,16 @@ def hash_int(x: int):
|
|||||||
def generate_mock_cluster_data(index: int):
|
def generate_mock_cluster_data(index: int):
|
||||||
'''Generate deterministic (no randomness!) mock data'''
|
'''Generate deterministic (no randomness!) mock data'''
|
||||||
nodes = []
|
nodes = []
|
||||||
|
names = [
|
||||||
|
'agent-cooper',
|
||||||
|
'log-lady',
|
||||||
|
'sheriff-truman',
|
||||||
|
'laura-palmer',
|
||||||
|
'black-lodge',
|
||||||
|
'bob',
|
||||||
|
'leland-palmer',
|
||||||
|
'bobby-briggs'
|
||||||
|
]
|
||||||
pod_phases = ['Pending', 'Running', 'Running']
|
pod_phases = ['Pending', 'Running', 'Running']
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
labels = {}
|
labels = {}
|
||||||
@@ -126,7 +136,7 @@ def generate_mock_cluster_data(index: int):
|
|||||||
status['containerStatuses'] = [{'ready': False, 'state': {'waiting': {'reason': 'CrashLoopBackOff'}}}]
|
status['containerStatuses'] = [{'ready': False, 'state': {'waiting': {'reason': 'CrashLoopBackOff'}}}]
|
||||||
elif j % 7 == 0:
|
elif j % 7 == 0:
|
||||||
status['containerStatuses'] = [{'ready': True, 'state': {'running': {}}, 'restartCount': 3}]
|
status['containerStatuses'] = [{'ready': True, 'state': {'running': {}}, 'restartCount': 3}]
|
||||||
pods.append({'name': 'my-pod-{}'.format(j), 'namespace': 'kube-system' if j < 3 else 'default', 'labels': labels, 'status': status, 'containers': containers})
|
pods.append({'name': '{}-{}'.format(names[hash_int((i + 1) * (j + 1)) % len(names)], j), 'namespace': 'kube-system' if j < 3 else 'default', 'labels': labels, 'status': status, 'containers': containers})
|
||||||
nodes.append({'name': 'node-{}'.format(i), 'labels': labels, 'status': {'capacity': {'cpu': '4', 'memory': '32Gi', 'pods': '110'}}, 'pods': pods})
|
nodes.append({'name': 'node-{}'.format(i), 'labels': labels, 'status': {'capacity': {'cpu': '4', 'memory': '32Gi', 'pods': '110'}}, 'pods': pods})
|
||||||
unassigned_pods = []
|
unassigned_pods = []
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,13 +7,23 @@ const PIXI = require('pixi.js')
|
|||||||
export default class App {
|
export default class App {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.filterString = ''
|
const hash = document.location.hash
|
||||||
|
if (hash.startsWith('#q=')) {
|
||||||
|
this.filterString = hash.substring(3)
|
||||||
|
} else {
|
||||||
|
this.filterString = ''
|
||||||
|
}
|
||||||
this.seenPods = {}
|
this.seenPods = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
filter() {
|
filter() {
|
||||||
const searchString = this.filterString
|
const searchString = this.filterString
|
||||||
this.searchText.text = searchString
|
this.searchText.text = searchString
|
||||||
|
if (searchString) {
|
||||||
|
document.location.hash = '#q=' + searchString
|
||||||
|
} else {
|
||||||
|
document.location.hash = ''
|
||||||
|
}
|
||||||
const filter = new PIXI.filters.ColorMatrixFilter()
|
const filter = new PIXI.filters.ColorMatrixFilter()
|
||||||
filter.desaturate()
|
filter.desaturate()
|
||||||
for (const cluster of this.viewContainer.children) {
|
for (const cluster of this.viewContainer.children) {
|
||||||
|
|||||||
Reference in New Issue
Block a user