-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbigiqCore.ts
130 lines (89 loc) · 4.53 KB
/
bigiqCore.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* 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 {
commands,
ExtensionContext,
window
} from "vscode";
import { ext } from "./extensionVariables";
import { BigiqTreeProvider } from "./treeViewsProviders/bigiqTreeProvider";
import { getText } from "./utils/utils";
import { logger } from './logger';
export class BigiqCore {
constructor(context: ExtensionContext) {
const iqProvider = new BigiqTreeProvider(context);
const iqTreeView = window.createTreeView('iqView', {
treeDataProvider: iqProvider,
showCollapseAll: true,
canSelectMany: false
});
context.subscriptions.push(commands.registerCommand('f5.iqViewShow', async (el) => {
ext.telemetry.capture({ command: 'f5.iqViewShow' });
if (el.selfLink && el.type === 'app') {
// overwrite the id with the full app details from response
el = await iqProvider.getApp(el.selfLink)
.catch(err => logger.error('f5.iqViewShow:', err));
} else if (el.script) {
iqProvider.render([], el);
} else {
iqProvider.render(el);
}
}));
context.subscriptions.push(commands.registerCommand('f5.iqPostTemplate', async () => {
ext.telemetry.capture({ command: 'f5.iqPostTemplate' });
await getText()
.then(async text => {
await iqProvider.postTemplate(text);
})
.catch(err => logger.error('f5.iqPostTemplate failed with', err));
}));
context.subscriptions.push(commands.registerCommand('f5.iqTemplatePublish', async (item) => {
ext.telemetry.capture({ command: 'f5.iqTemplatePublish' });
await iqProvider.publishTemplate(item)
.catch(err => logger.error('f5.iqTemplatePublish failed with', err));
}));
context.subscriptions.push(commands.registerCommand('f5.iqTemplateDelete', async (item) => {
ext.telemetry.capture({ command: 'f5.iqTemplateDelete' });
await iqProvider.deleteTemplate(item)
.catch(err => logger.error('f5.iqTemplateDelete failed with', err));
}));
context.subscriptions.push(commands.registerCommand('f5.iqAppMoveApp', async (item) => {
ext.telemetry.capture({ command: 'f5.iqAppMoveApp' });
await iqProvider.moveApp(item)
.catch(err => logger.error('f5.iqAppMoveApp failed with', err));
}));
context.subscriptions.push(commands.registerCommand('f5.iqAppDelete', async (item) => {
ext.telemetry.capture({ command: 'f5.iqAppDelete' });
await iqProvider.deleteApp(item)
.catch(err => logger.error('f5.iqAppDelete failed with', err));
}));
context.subscriptions.push(commands.registerCommand('f5.iqViewRefresh', async () => {
iqProvider.refresh();
}));
context.subscriptions.push(commands.registerCommand('f5.iqScriptDelete', async (item) => {
ext.telemetry.capture({ command: 'f5.iqScriptDelete' });
await iqProvider.deleteScript(item)
.catch(err => logger.error('f5.iqScriptDelete failed with', err));
}));
context.subscriptions.push(commands.registerCommand('f5.iqScriptPost', async (item) => {
ext.telemetry.capture({ command: 'f5.iqScriptPost' });
getText().then(async text => {
await iqProvider.postScript(text)
.catch(err => logger.error('f5.iqScriptPost failed with', err));
});
}));
context.subscriptions.push(commands.registerCommand('f5.iqScriptExecute', async (item) => {
ext.telemetry.capture({ command: 'f5.iqScriptExecute' });
await iqProvider.executeScript(item)
.catch(err => {
logger.error('f5.iqScriptExecute failed with', err);
});
}));
}
}