-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
101 lines (97 loc) · 2.95 KB
/
index.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
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
/**
* Enables submit on ready
*/
$(document).ready(function () {
enableSubmit();
});
/**
* Enable submit button if required fields have been provided
*/
function enableSubmit() {
if (
$('#txtPIWebAPIUrl').val() &&
($('#selAuthType option:selected').text() === 'Kerberos' ||
($('#txtPIWebAPIUser').val() && $('#txtPIWebAPIPassword').val())) &&
$('#txtAssetServer').val() &&
$('#txtPIServer').val()
) {
$('#btnRunCode').attr('disabled', false);
} else {
$('#btnRunCode').attr('disabled', true);
}
}
/**
* Execute the code for the selected option
*/
function RunSelected() {
if (!/^(http|https)?:\/\/[a-zA-Z0-9-.]/.test($('#txtPIWebAPIUrl').val())) {
alert('Please enter a valid PI Web API URL');
return;
}
var PIWebAPIUrl = $('#txtPIWebAPIUrl').val();
var AssetServer = $('#txtAssetServer').val();
var PIServer = $('#txtPIServer').val();
var Name = $('#txtPIWebAPIUser').val();
var Password = $('#txtPIWebAPIPassword').val();
var AuthType = $('#selAuthType option:selected').text();
switch ($('#selAction option:selected').text()) {
case 'Write Single Value':
writeSingleValue(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Write Set of Values':
writeDataSet(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Update Attribute Value':
updateAttributeValue(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Get Single Value':
readAttributeSnapshot(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Get Set of Values':
readAttributeStream(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Reduce Payload with Selected Fields':
readAttributeSelectedFields(
PIWebAPIUrl,
AssetServer,
Name,
Password,
AuthType
);
break;
case 'Batch Writes and Reads':
doBatchCall(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Create Database':
createDatabase(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Create Template':
createTemplate(
PIWebAPIUrl,
AssetServer,
PIServer,
Name,
Password,
AuthType
);
break;
case 'Create Category':
createCategory(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Create Element':
createElement(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Delete Element':
deleteElement(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Delete Template':
deleteTemplate(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Delete Category':
deleteCategory(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
case 'Delete Database':
deleteDatabase(PIWebAPIUrl, AssetServer, Name, Password, AuthType);
break;
}
}