Skip to content

Commit 9feb3c8

Browse files
authored
Revert: Grafana screen resolution determination (#623)
* Revert: Grafana screen resolution determination * Fix: lint errors * Fix: lint
1 parent 3c03179 commit 9feb3c8

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

edge-apps/grafana/src/main.test.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ if (!globalThis.window) {
1818
})
1919
}
2020
Object.assign(globalThis.window, {
21-
screen: {
22-
width: 1234,
23-
height: 567,
24-
},
25-
devicePixelRatio: 1,
21+
innerWidth: 1234,
22+
innerHeight: 567,
2623
})
2724

2825
describe('Grafana App', () => {
@@ -31,18 +28,18 @@ describe('Grafana App', () => {
3128
let originalScreenHeight: number
3229

3330
beforeEach(() => {
34-
originalScreenWidth = globalThis.window.screen.width
35-
originalScreenHeight = globalThis.window.screen.height
31+
originalScreenWidth = globalThis.window.innerWidth
32+
originalScreenHeight = globalThis.window.innerHeight
3633
})
3734

3835
afterEach(() => {
39-
globalThis.window.screen.width = originalScreenWidth
40-
globalThis.window.screen.height = originalScreenHeight
36+
globalThis.window.innerWidth = originalScreenWidth
37+
globalThis.window.innerHeight = originalScreenHeight
4138
})
4239

4340
test('should construct URL with correct parameters', () => {
44-
globalThis.window.screen.width = 1234
45-
globalThis.window.screen.height = 567
41+
globalThis.window.innerWidth = 1234
42+
globalThis.window.innerHeight = 567
4643

4744
const url = getRenderUrl('https://grafana.example.com', 'abc123')
4845

@@ -55,8 +52,8 @@ describe('Grafana App', () => {
5552
})
5653

5754
test('should use dynamic window dimensions', () => {
58-
globalThis.window.screen.width = 3840
59-
globalThis.window.screen.height = 2160
55+
globalThis.window.innerWidth = 3840
56+
globalThis.window.innerHeight = 2160
6057

6158
const url = getRenderUrl('grafana.example.com', 'xyz789')
6259

edge-apps/grafana/src/render.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
export function getRenderUrl(domain: string, dashboardId: string): string {
22
const renderUrl = `${screenly.cors_proxy_url}/${domain}/render/d/${dashboardId}`
3-
const width = window.screen.width || 1920
4-
const height = window.screen.height || 1080
3+
const width = window.innerWidth || 1920
4+
const height = window.innerHeight || 1080
55
const params = new URLSearchParams({
66
width: width.toString(),
77
height: height.toString(),
88
kiosk: 'true',
9-
scale: window.devicePixelRatio || 1,
109
})
1110

1211
return `${renderUrl}?${params.toString()}`

0 commit comments

Comments
 (0)