#108 add renderer UI option to disable WebGL

This commit is contained in:
Henning Jacobs
2017-01-24 16:45:30 +01:00
parent b37aa6a59a
commit 650d2c58d2
2 changed files with 13 additions and 13 deletions

View File

@@ -5,23 +5,20 @@ import SelectBox from './selectbox'
import { Theme, ALL_THEMES} from './themes.js' import { Theme, ALL_THEMES} from './themes.js'
import { DESATURATION_FILTER } from './filters.js' import { DESATURATION_FILTER } from './filters.js'
import { JSON_delta } from './vendor/json_delta.js' import { JSON_delta } from './vendor/json_delta.js'
import Config from './config.js'
const PIXI = require('pixi.js') const PIXI = require('pixi.js')
const addWheelListener = require('./vendor/addWheelListener') const addWheelListener = require('./vendor/addWheelListener')
const TRUTHY_VALUES = new Set(['1', 'true'])
export default class App { export default class App {
constructor() { constructor() {
const params = this.parseLocationHash() const params = this.parseLocationHash()
this.dashboardMode = TRUTHY_VALUES.has(params.get('dashboard')) this.config = Config.fromParams(params)
this.reloadIntervalSeconds = parseInt(params.get('reload')) || 0
this.filterString = params.get('q') || '' this.filterString = params.get('q') || ''
this.selectedClusters = new Set((params.get('clusters') || '').split(',').filter(x => x)) this.selectedClusters = new Set((params.get('clusters') || '').split(',').filter(x => x))
this.initialScale = parseFloat(params.get('scale')) || 1.0
this.seenPods = new Set() this.seenPods = new Set()
this.sorterFn = '' this.sorterFn = ''
this.theme = Theme.get(localStorage.getItem('theme')) this.theme = Theme.get(localStorage.getItem('theme'))
@@ -104,8 +101,9 @@ export default class App {
initialize() { initialize() {
App.current = this App.current = this
//Create the renderer // create the renderer
const renderer = PIXI.autoDetectRenderer(256, 256, {resolution: 2}) const noWebGL = this.config.renderer === 'canvas'
const renderer = PIXI.autoDetectRenderer(256, 256, {resolution: 2}, noWebGL)
renderer.view.style.display = 'block' renderer.view.style.display = 'block'
renderer.autoResize = true renderer.autoResize = true
renderer.resize(window.innerWidth, window.innerHeight) renderer.resize(window.innerWidth, window.innerHeight)
@@ -124,8 +122,8 @@ export default class App {
this.registerEventListeners() this.registerEventListeners()
setInterval(this.pruneUnavailableClusters.bind(this), 5 * 1000) setInterval(this.pruneUnavailableClusters.bind(this), 5 * 1000)
if (this.reloadIntervalSeconds) { if (this.config.reloadIntervalSeconds) {
setTimeout(function() { location.reload(false) }, this.reloadIntervalSeconds * 1000) setTimeout(function() { location.reload(false) }, this.config.reloadIntervalSeconds * 1000)
} }
} }
@@ -152,7 +150,7 @@ export default class App {
} }
else if (event.key == 'Home') { else if (event.key == 'Home') {
this.viewContainerTargetPosition.x = 20 this.viewContainerTargetPosition.x = 20
this.viewContainerTargetPosition.y = this.dashboardMode ? 20 : 40 this.viewContainerTargetPosition.y = this.config.dashboardMode ? 20 : 40
} }
else if (event.key && event.key.length == 1 && !event.ctrlKey && !event.metaKey) { else if (event.key && event.key.length == 1 && !event.ctrlKey && !event.metaKey) {
this.filterString += event.key this.filterString += event.key
@@ -334,14 +332,14 @@ export default class App {
this.theme.apply(this.stage) this.theme.apply(this.stage)
const viewContainer = new PIXI.Container() const viewContainer = new PIXI.Container()
viewContainer.scale.set(this.initialScale) viewContainer.scale.set(this.config.initialScale)
viewContainer.x = 20 viewContainer.x = 20
viewContainer.y = this.dashboardMode ? 20 : 40 viewContainer.y = this.config.dashboardMode ? 20 : 40
this.viewContainerTargetPosition.x = viewContainer.x this.viewContainerTargetPosition.x = viewContainer.x
this.viewContainerTargetPosition.y = viewContainer.y this.viewContainerTargetPosition.y = viewContainer.y
this.stage.addChild(viewContainer) this.stage.addChild(viewContainer)
if (!this.dashboardMode) { if (!this.config.dashboardMode) {
this.drawMenuBar() this.drawMenuBar()
} }

View File

@@ -14,5 +14,7 @@ Example URL: ``https://kube-ops-view.example.org/#dashboard=true;reload=600``
Enable dashboard mode which hides the menu bar. Enable dashboard mode which hides the menu bar.
``reload`` ``reload``
Reload the whole page after X seconds. This is useful for unattended TV screens running 24x7 to mitigate JavaScript memory leaks and browser crashes. Reload the whole page after X seconds. This is useful for unattended TV screens running 24x7 to mitigate JavaScript memory leaks and browser crashes.
``renderer``
Forces the fallback canvas renderer (instead of WebGL) when set to "canvas".
``scale`` ``scale``
Set the initial view scale (``1.0`` is 100%). Set the initial view scale (``1.0`` is 100%).