-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtokenTimer.ts
53 lines (40 loc) · 1.41 KB
/
tokenTimer.ts
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
50
51
52
53
/*
* Copyright 2020. F5 Networks, Inc. See End User License Agreement ("EULA") for
* license terms. Notwithstanding anything to the contrary in the EULA, Licensee
* may copy and modify this software product for its internal business purposes.
* Further, Licensee may upload, publish and distribute the modified version of
* the software product on devcentral.f5.com or github.com/f5devcentral.
*/
'use strict';
import {
window,
StatusBarItem,
StatusBarAlignment
} from 'vscode';
import { ext } from './extensionVariables';
import { logger } from './logger';
export function tokenTimer(hide?: boolean) {
const tokenTimerBar: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 50);
tokenTimerBar.tooltip = 'F5 AuthToken Timer';
if (hide) {
tokenTimerBar.hide();
}
ext.eventEmitterGlobal
.on('token-timer-start', msg => {
tokenTimerBar.show();
logger.info(msg);
})
.on('token-timer-expired', msg => {
tokenTimerBar.hide();
logger.info(msg);
})
.on('token-timer-count', second => {
if (second <= 30) {
// turn text color reddish/pink to indicate expiring token
tokenTimerBar.color = '#ED5A75';
} else {
tokenTimerBar.color = 'silver';
}
tokenTimerBar.text = `${second}`;
});
}