File size: 1,468 Bytes
71174bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { goldenLayout } from "@/UI/Layout/GoldenLayout/GoldenLayoutCommon";

/**
 * Switches to a specified tab in the golden layout.
 * 
 * @param  {string} componentTitle The title of the component to switch to.
 */
export function switchToGoldenLayoutPanel(componentTitle: string) {
    // See https://github.com/golden-layout/golden-layout/issues/430

    let contentItem: any;
    const gl = goldenLayout as any;
    for (let i = 0; i < gl.getAllContentItems().length; i++) {
        if (gl.getAllContentItems()[i].title === componentTitle) {
            contentItem = gl.getAllContentItems()[i];
            contentItem.parent.setActiveContentItem(contentItem);
            break;
        }
    }

    if (contentItem === undefined) {
        // Not found.
        return;
    }

    // Now flash that panel to get the user's attention.
    let val = 10;
    const updateColor = () => {
        const bgColor = `rgb(${val}, ${val}, ${val}, 0.05)`;
        // console.log(bgColor);
        contentItem.element.style.backgroundColor = bgColor;
        val *= 1.25;
        val = Math.round(val);
        if (val < 245) {
            setTimeout(() => {
                // console.log("moo", val);
                updateColor();
            }, 25);
        } else {
            contentItem.element.style.backgroundColor = "";
        }
    }
    updateColor();

    // setTimeout(() => {
    //     contentItem.element.style.backgroundColor = "";
    // }, 1000);
}