/
script.js
63 lines (53 loc) · 1.29 KB
/
script.js
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
import template from './template.html';
function webHookControls(
$state,
$window,
api
) {
return {
restrict: 'E',
scope: {
computer: '=computer'
},
template: template,
link: link
};
function link(scope) {
scope.disable = disable;
scope.renew = renew;
Object.defineProperty(scope, 'script', {
get: calculateScript
});
function calculateScript() {
if (!scope.computer || !scope.computer.accessKey || !scope.computer.encryptionKey) {
return;
}
return '<WebHook.Connect ComputerName="' + scope.computer.name + '" CommunicationURL="' + $window.location.origin + '/communicator/" AccessKey="' + scope.computer.accessKey + '" EncryptionKey="' + scope.computer.encryptionKey + '" />';
}
function disable() {
api({
repository: 'computer',
action: 'disableWebHook',
parameters: {
id: scope.computer.id,
}
})
.then(function () {
$state.reload();
});
}
function renew() {
api({
repository: 'computer',
action: 'renewWebHookKeys',
parameters: {
id: scope.computer.id,
}
})
.then(function () {
$state.reload();
});
}
}
}
export default webHookControls;