Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Commit 650d2c5

Browse files
committed
#108 add renderer UI option to disable WebGL
1 parent b37aa6a commit 650d2c5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

app/src/app.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@ import SelectBox from './selectbox'
55
import { Theme, ALL_THEMES} from './themes.js'
66
import { DESATURATION_FILTER } from './filters.js'
77
import { JSON_delta } from './vendor/json_delta.js'
8+
import Config from './config.js'
89

910
const PIXI = require('pixi.js')
1011

1112
const addWheelListener = require('./vendor/addWheelListener')
1213

13-
const TRUTHY_VALUES = new Set(['1', 'true'])
14-
1514

1615
export default class App {
1716

1817
constructor() {
1918
const params = this.parseLocationHash()
20-
this.dashboardMode = TRUTHY_VALUES.has(params.get('dashboard'))
21-
this.reloadIntervalSeconds = parseInt(params.get('reload')) || 0
19+
this.config = Config.fromParams(params)
2220
this.filterString = params.get('q') || ''
2321
this.selectedClusters = new Set((params.get('clusters') || '').split(',').filter(x => x))
24-
this.initialScale = parseFloat(params.get('scale')) || 1.0
2522
this.seenPods = new Set()
2623
this.sorterFn = ''
2724
this.theme = Theme.get(localStorage.getItem('theme'))
@@ -104,8 +101,9 @@ export default class App {
104101
initialize() {
105102
App.current = this
106103

107-
//Create the renderer
108-
const renderer = PIXI.autoDetectRenderer(256, 256, {resolution: 2})
104+
// create the renderer
105+
const noWebGL = this.config.renderer === 'canvas'
106+
const renderer = PIXI.autoDetectRenderer(256, 256, {resolution: 2}, noWebGL)
109107
renderer.view.style.display = 'block'
110108
renderer.autoResize = true
111109
renderer.resize(window.innerWidth, window.innerHeight)
@@ -124,8 +122,8 @@ export default class App {
124122
this.registerEventListeners()
125123
setInterval(this.pruneUnavailableClusters.bind(this), 5 * 1000)
126124

127-
if (this.reloadIntervalSeconds) {
128-
setTimeout(function() { location.reload(false) }, this.reloadIntervalSeconds * 1000)
125+
if (this.config.reloadIntervalSeconds) {
126+
setTimeout(function() { location.reload(false) }, this.config.reloadIntervalSeconds * 1000)
129127
}
130128
}
131129

@@ -152,7 +150,7 @@ export default class App {
152150
}
153151
else if (event.key == 'Home') {
154152
this.viewContainerTargetPosition.x = 20
155-
this.viewContainerTargetPosition.y = this.dashboardMode ? 20 : 40
153+
this.viewContainerTargetPosition.y = this.config.dashboardMode ? 20 : 40
156154
}
157155
else if (event.key && event.key.length == 1 && !event.ctrlKey && !event.metaKey) {
158156
this.filterString += event.key
@@ -334,14 +332,14 @@ export default class App {
334332
this.theme.apply(this.stage)
335333

336334
const viewContainer = new PIXI.Container()
337-
viewContainer.scale.set(this.initialScale)
335+
viewContainer.scale.set(this.config.initialScale)
338336
viewContainer.x = 20
339-
viewContainer.y = this.dashboardMode ? 20 : 40
337+
viewContainer.y = this.config.dashboardMode ? 20 : 40
340338
this.viewContainerTargetPosition.x = viewContainer.x
341339
this.viewContainerTargetPosition.y = viewContainer.y
342340
this.stage.addChild(viewContainer)
343341

344-
if (!this.dashboardMode) {
342+
if (!this.config.dashboardMode) {
345343
this.drawMenuBar()
346344
}
347345

docs/ui-options.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ Example URL: ``https://kube-ops-view.example.org/#dashboard=true;reload=600``
1414
Enable dashboard mode which hides the menu bar.
1515
``reload``
1616
Reload the whole page after X seconds. This is useful for unattended TV screens running 24x7 to mitigate JavaScript memory leaks and browser crashes.
17+
``renderer``
18+
Forces the fallback canvas renderer (instead of WebGL) when set to "canvas".
1719
``scale``
1820
Set the initial view scale (``1.0`` is 100%).

0 commit comments

Comments
 (0)