ultravisor 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +6 -0
- package/.browserslistrc +1 -0
- package/.browserslistrc-BACKUP +1 -0
- package/.gulpfile-quackage-config.json +7 -0
- package/.gulpfile-quackage.js +2 -0
- package/CONTRIBUTING.md +50 -0
- package/README.md +34 -0
- package/debug/Harness.js +2 -1
- package/docs/.nojekyll +0 -0
- package/docs/_sidebar.md +18 -0
- package/docs/_topbar.md +7 -0
- package/docs/architecture.md +103 -0
- package/docs/cover.md +15 -0
- package/docs/features/api.md +230 -0
- package/docs/features/cli.md +182 -0
- package/docs/features/configuration.md +245 -0
- package/docs/features/manifests.md +177 -0
- package/docs/features/operations.md +292 -0
- package/docs/features/scheduling.md +179 -0
- package/docs/features/tasks.md +1857 -0
- package/docs/index.html +39 -0
- package/docs/overview.md +75 -0
- package/docs/quickstart.md +167 -0
- package/docs/retold-catalog.json +24 -0
- package/docs/retold-keyword-index.json +19 -0
- package/package.json +5 -2
- package/source/Ultravisor.cjs +2 -2
- package/source/cli/Ultravisor-CLIProgram.cjs +38 -0
- package/source/cli/commands/Ultravisor-Command-ScheduleOperation.cjs +26 -2
- package/source/cli/commands/Ultravisor-Command-ScheduleTask.cjs +26 -2
- package/source/cli/commands/Ultravisor-Command-ScheduleView.cjs +22 -0
- package/source/cli/commands/Ultravisor-Command-SingleOperation.cjs +49 -1
- package/source/cli/commands/Ultravisor-Command-SingleTask.cjs +51 -1
- package/source/cli/commands/Ultravisor-Command-Stop.cjs +4 -0
- package/source/cli/commands/Ultravisor-Command-UpdateTask.cjs +91 -0
- package/source/config/Ultravisor-Default-Command-Configuration.cjs +6 -1
- package/source/services/Ultravisor-Hypervisor-Event-Base.cjs +18 -1
- package/source/services/Ultravisor-Hypervisor-State.cjs +213 -0
- package/source/services/Ultravisor-Hypervisor.cjs +225 -1
- package/source/services/Ultravisor-Operation-Manifest.cjs +150 -1
- package/source/services/Ultravisor-Operation.cjs +190 -1
- package/source/services/Ultravisor-Task.cjs +339 -1
- package/source/services/events/Ultravisor-Hypervisor-Event-Cron.cjs +71 -1
- package/source/services/tasks/Ultravisor-Task-Base.cjs +264 -0
- package/source/services/tasks/Ultravisor-Task-CollectValues.cjs +188 -0
- package/source/services/tasks/Ultravisor-Task-Command.cjs +65 -0
- package/source/services/tasks/Ultravisor-Task-CommandEach.cjs +190 -0
- package/source/services/tasks/Ultravisor-Task-Conditional.cjs +104 -0
- package/source/services/tasks/Ultravisor-Task-DateWindow.cjs +72 -0
- package/source/services/tasks/Ultravisor-Task-GeneratePagedOperation.cjs +336 -0
- package/source/services/tasks/Ultravisor-Task-LaunchOperation.cjs +143 -0
- package/source/services/tasks/Ultravisor-Task-LaunchTask.cjs +146 -0
- package/source/services/tasks/Ultravisor-Task-LineMatch.cjs +158 -0
- package/source/services/tasks/Ultravisor-Task-Request.cjs +56 -0
- package/source/services/tasks/Ultravisor-Task-Solver.cjs +89 -0
- package/source/services/tasks/Ultravisor-Task-TemplateString.cjs +93 -0
- package/source/services/tasks/rest/Ultravisor-Task-GetBinary.cjs +127 -0
- package/source/services/tasks/rest/Ultravisor-Task-GetJSON.cjs +119 -0
- package/source/services/tasks/rest/Ultravisor-Task-GetText.cjs +109 -0
- package/source/services/tasks/rest/Ultravisor-Task-GetXML.cjs +112 -0
- package/source/services/tasks/rest/Ultravisor-Task-RestRequest.cjs +499 -0
- package/source/services/tasks/rest/Ultravisor-Task-SendJSON.cjs +150 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-CopyFile.cjs +110 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ListFiles.cjs +89 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadBinary.cjs +87 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadJSON.cjs +67 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadText.cjs +66 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadXML.cjs +69 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteBinary.cjs +95 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteJSON.cjs +96 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteText.cjs +99 -0
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteXML.cjs +102 -0
- package/source/web_server/Ultravisor-API-Server.cjs +463 -3
- package/test/Ultravisor_tests.js +6097 -1
- package/webinterface/.babelrc +6 -0
- package/webinterface/.browserslistrc +1 -0
- package/webinterface/.browserslistrc-BACKUP +1 -0
- package/webinterface/.gulpfile-quackage-config.json +7 -0
- package/webinterface/.gulpfile-quackage.js +2 -0
- package/webinterface/css/ultravisor.css +121 -0
- package/webinterface/html/index.html +32 -0
- package/webinterface/package.json +39 -0
- package/webinterface/source/Pict-Application-Ultravisor-Configuration.json +15 -0
- package/webinterface/source/Pict-Application-Ultravisor.js +414 -0
- package/webinterface/source/providers/PictRouter-Ultravisor-Configuration.json +42 -0
- package/webinterface/source/views/PictView-Ultravisor-BottomBar.js +65 -0
- package/webinterface/source/views/PictView-Ultravisor-Dashboard.js +236 -0
- package/webinterface/source/views/PictView-Ultravisor-Layout.js +83 -0
- package/webinterface/source/views/PictView-Ultravisor-ManifestList.js +273 -0
- package/webinterface/source/views/PictView-Ultravisor-OperationEdit.js +243 -0
- package/webinterface/source/views/PictView-Ultravisor-OperationList.js +141 -0
- package/webinterface/source/views/PictView-Ultravisor-Schedule.js +280 -0
- package/webinterface/source/views/PictView-Ultravisor-TaskEdit.js +220 -0
- package/webinterface/source/views/PictView-Ultravisor-TaskList.js +248 -0
- package/webinterface/source/views/PictView-Ultravisor-TimingView.js +420 -0
- package/webinterface/source/views/PictView-Ultravisor-TopBar.js +147 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
const libPictView = require('pict-view');
|
|
2
|
+
|
|
3
|
+
const _ViewConfiguration =
|
|
4
|
+
{
|
|
5
|
+
ViewIdentifier: "Ultravisor-TaskEdit",
|
|
6
|
+
|
|
7
|
+
DefaultRenderable: "Ultravisor-TaskEdit-Content",
|
|
8
|
+
DefaultDestinationAddress: "#Ultravisor-Content-Container",
|
|
9
|
+
|
|
10
|
+
AutoRender: false,
|
|
11
|
+
|
|
12
|
+
CSS: /*css*/`
|
|
13
|
+
.ultravisor-taskedit {
|
|
14
|
+
padding: 2em;
|
|
15
|
+
max-width: 800px;
|
|
16
|
+
margin: 0 auto;
|
|
17
|
+
}
|
|
18
|
+
.ultravisor-taskedit-header {
|
|
19
|
+
margin-bottom: 1.5em;
|
|
20
|
+
padding-bottom: 1em;
|
|
21
|
+
border-bottom: 1px solid #2a2a4a;
|
|
22
|
+
}
|
|
23
|
+
.ultravisor-taskedit-header h1 {
|
|
24
|
+
margin: 0;
|
|
25
|
+
font-size: 2em;
|
|
26
|
+
font-weight: 300;
|
|
27
|
+
color: #e0e0e0;
|
|
28
|
+
}
|
|
29
|
+
.ultravisor-form-group {
|
|
30
|
+
margin-bottom: 1.25em;
|
|
31
|
+
}
|
|
32
|
+
.ultravisor-form-group label {
|
|
33
|
+
display: block;
|
|
34
|
+
margin-bottom: 0.35em;
|
|
35
|
+
font-size: 0.85em;
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
color: #b0bec5;
|
|
38
|
+
text-transform: uppercase;
|
|
39
|
+
letter-spacing: 0.03em;
|
|
40
|
+
}
|
|
41
|
+
.ultravisor-form-group input,
|
|
42
|
+
.ultravisor-form-group select,
|
|
43
|
+
.ultravisor-form-group textarea {
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
.ultravisor-form-group textarea {
|
|
47
|
+
min-height: 80px;
|
|
48
|
+
}
|
|
49
|
+
.ultravisor-form-row {
|
|
50
|
+
display: grid;
|
|
51
|
+
grid-template-columns: 1fr 1fr;
|
|
52
|
+
gap: 1em;
|
|
53
|
+
}
|
|
54
|
+
.ultravisor-form-actions {
|
|
55
|
+
display: flex;
|
|
56
|
+
gap: 0.75em;
|
|
57
|
+
margin-top: 2em;
|
|
58
|
+
padding-top: 1.5em;
|
|
59
|
+
border-top: 1px solid #2a2a4a;
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
|
|
63
|
+
Templates:
|
|
64
|
+
[
|
|
65
|
+
{
|
|
66
|
+
Hash: "Ultravisor-TaskEdit-Template",
|
|
67
|
+
Template: /*html*/`
|
|
68
|
+
<div class="ultravisor-taskedit">
|
|
69
|
+
<div class="ultravisor-taskedit-header">
|
|
70
|
+
<h1 id="Ultravisor-TaskEdit-Title">New Task</h1>
|
|
71
|
+
</div>
|
|
72
|
+
<div id="Ultravisor-TaskEdit-Form"></div>
|
|
73
|
+
</div>
|
|
74
|
+
`
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
|
|
78
|
+
Renderables:
|
|
79
|
+
[
|
|
80
|
+
{
|
|
81
|
+
RenderableHash: "Ultravisor-TaskEdit-Content",
|
|
82
|
+
TemplateHash: "Ultravisor-TaskEdit-Template",
|
|
83
|
+
DestinationAddress: "#Ultravisor-Content-Container",
|
|
84
|
+
RenderMethod: "replace"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
class UltravisorTaskEditView extends libPictView
|
|
90
|
+
{
|
|
91
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
92
|
+
{
|
|
93
|
+
super(pFable, pOptions, pServiceHash);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent)
|
|
97
|
+
{
|
|
98
|
+
let tmpTask = this.pict.AppData.Ultravisor.CurrentEditTask;
|
|
99
|
+
if (!tmpTask)
|
|
100
|
+
{
|
|
101
|
+
tmpTask =
|
|
102
|
+
{
|
|
103
|
+
GUIDTask: '', Code: '', Name: '', Type: 'Command',
|
|
104
|
+
Command: '', URL: '', Method: 'GET', Parameters: '', Description: ''
|
|
105
|
+
};
|
|
106
|
+
this.pict.AppData.Ultravisor.CurrentEditTask = tmpTask;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let tmpIsNew = !tmpTask.GUIDTask;
|
|
110
|
+
let tmpTitleEl = document.getElementById('Ultravisor-TaskEdit-Title');
|
|
111
|
+
if (tmpTitleEl)
|
|
112
|
+
{
|
|
113
|
+
tmpTitleEl.textContent = tmpIsNew ? 'New Task' : ('Edit Task: ' + (tmpTask.Name || tmpTask.GUIDTask));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let tmpGlobalRef = '_Pict';
|
|
117
|
+
let tmpTaskTypes = ['Command', 'Request', 'ListFiles', 'WriteJSON', 'ReadJSON', 'GetJSON', 'WriteText', 'ReadText', 'Manual'];
|
|
118
|
+
|
|
119
|
+
let tmpHTML = '';
|
|
120
|
+
tmpHTML += '<div class="ultravisor-form-row">';
|
|
121
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>GUID Task</label>';
|
|
122
|
+
tmpHTML += '<input type="text" id="Ultravisor-TaskEdit-GUIDTask" value="' + this.escapeAttr(tmpTask.GUIDTask) + '" ' + (tmpIsNew ? '' : 'readonly') + '></div>';
|
|
123
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Code</label>';
|
|
124
|
+
tmpHTML += '<input type="text" id="Ultravisor-TaskEdit-Code" value="' + this.escapeAttr(tmpTask.Code || '') + '"></div>';
|
|
125
|
+
tmpHTML += '</div>';
|
|
126
|
+
|
|
127
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Name</label>';
|
|
128
|
+
tmpHTML += '<input type="text" id="Ultravisor-TaskEdit-Name" value="' + this.escapeAttr(tmpTask.Name || '') + '"></div>';
|
|
129
|
+
|
|
130
|
+
tmpHTML += '<div class="ultravisor-form-row">';
|
|
131
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Type</label>';
|
|
132
|
+
tmpHTML += '<select id="Ultravisor-TaskEdit-Type">';
|
|
133
|
+
for (let i = 0; i < tmpTaskTypes.length; i++)
|
|
134
|
+
{
|
|
135
|
+
let tmpSel = (tmpTask.Type === tmpTaskTypes[i]) ? ' selected' : '';
|
|
136
|
+
tmpHTML += '<option value="' + tmpTaskTypes[i] + '"' + tmpSel + '>' + tmpTaskTypes[i] + '</option>';
|
|
137
|
+
}
|
|
138
|
+
tmpHTML += '</select></div>';
|
|
139
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Method (for Request)</label>';
|
|
140
|
+
tmpHTML += '<select id="Ultravisor-TaskEdit-Method">';
|
|
141
|
+
let tmpMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
|
|
142
|
+
for (let i = 0; i < tmpMethods.length; i++)
|
|
143
|
+
{
|
|
144
|
+
let tmpSel = (tmpTask.Method === tmpMethods[i]) ? ' selected' : '';
|
|
145
|
+
tmpHTML += '<option value="' + tmpMethods[i] + '"' + tmpSel + '>' + tmpMethods[i] + '</option>';
|
|
146
|
+
}
|
|
147
|
+
tmpHTML += '</select></div>';
|
|
148
|
+
tmpHTML += '</div>';
|
|
149
|
+
|
|
150
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Command</label>';
|
|
151
|
+
tmpHTML += '<input type="text" id="Ultravisor-TaskEdit-Command" value="' + this.escapeAttr(tmpTask.Command || '') + '"></div>';
|
|
152
|
+
|
|
153
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>URL (for Request)</label>';
|
|
154
|
+
tmpHTML += '<input type="text" id="Ultravisor-TaskEdit-URL" value="' + this.escapeAttr(tmpTask.URL || '') + '"></div>';
|
|
155
|
+
|
|
156
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Parameters</label>';
|
|
157
|
+
tmpHTML += '<input type="text" id="Ultravisor-TaskEdit-Parameters" value="' + this.escapeAttr(tmpTask.Parameters || '') + '"></div>';
|
|
158
|
+
|
|
159
|
+
tmpHTML += '<div class="ultravisor-form-group"><label>Description</label>';
|
|
160
|
+
tmpHTML += '<textarea id="Ultravisor-TaskEdit-Description">' + this.escapeHTML(tmpTask.Description || '') + '</textarea></div>';
|
|
161
|
+
|
|
162
|
+
tmpHTML += '<div class="ultravisor-form-actions">';
|
|
163
|
+
tmpHTML += '<button class="ultravisor-btn ultravisor-btn-primary" onclick="' + tmpGlobalRef + '.views[\'Ultravisor-TaskEdit\'].saveTask()">Save Task</button>';
|
|
164
|
+
tmpHTML += '<button class="ultravisor-btn ultravisor-btn-secondary" onclick="' + tmpGlobalRef + '.PictApplication.navigateTo(\'/Tasks\')">Cancel</button>';
|
|
165
|
+
tmpHTML += '</div>';
|
|
166
|
+
|
|
167
|
+
this.pict.ContentAssignment.assignContent('#Ultravisor-TaskEdit-Form', tmpHTML);
|
|
168
|
+
|
|
169
|
+
return super.onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
escapeAttr(pValue)
|
|
173
|
+
{
|
|
174
|
+
if (!pValue) return '';
|
|
175
|
+
return String(pValue).replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
escapeHTML(pValue)
|
|
179
|
+
{
|
|
180
|
+
if (!pValue) return '';
|
|
181
|
+
return String(pValue).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
saveTask()
|
|
185
|
+
{
|
|
186
|
+
let tmpTaskData =
|
|
187
|
+
{
|
|
188
|
+
GUIDTask: document.getElementById('Ultravisor-TaskEdit-GUIDTask').value.trim(),
|
|
189
|
+
Code: document.getElementById('Ultravisor-TaskEdit-Code').value.trim(),
|
|
190
|
+
Name: document.getElementById('Ultravisor-TaskEdit-Name').value.trim(),
|
|
191
|
+
Type: document.getElementById('Ultravisor-TaskEdit-Type').value,
|
|
192
|
+
Command: document.getElementById('Ultravisor-TaskEdit-Command').value.trim(),
|
|
193
|
+
URL: document.getElementById('Ultravisor-TaskEdit-URL').value.trim(),
|
|
194
|
+
Method: document.getElementById('Ultravisor-TaskEdit-Method').value,
|
|
195
|
+
Parameters: document.getElementById('Ultravisor-TaskEdit-Parameters').value.trim(),
|
|
196
|
+
Description: document.getElementById('Ultravisor-TaskEdit-Description').value.trim()
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
if (!tmpTaskData.GUIDTask)
|
|
200
|
+
{
|
|
201
|
+
alert('GUID Task is required.');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.pict.PictApplication.saveTask(tmpTaskData,
|
|
206
|
+
function (pError)
|
|
207
|
+
{
|
|
208
|
+
if (pError)
|
|
209
|
+
{
|
|
210
|
+
alert('Error saving task: ' + pError.message);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this.pict.PictApplication.navigateTo('/Tasks');
|
|
214
|
+
}.bind(this));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
module.exports = UltravisorTaskEditView;
|
|
219
|
+
|
|
220
|
+
module.exports.default_configuration = _ViewConfiguration;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
const libPictView = require('pict-view');
|
|
2
|
+
|
|
3
|
+
const _ViewConfiguration =
|
|
4
|
+
{
|
|
5
|
+
ViewIdentifier: "Ultravisor-TaskList",
|
|
6
|
+
|
|
7
|
+
DefaultRenderable: "Ultravisor-TaskList-Content",
|
|
8
|
+
DefaultDestinationAddress: "#Ultravisor-Content-Container",
|
|
9
|
+
|
|
10
|
+
AutoRender: false,
|
|
11
|
+
|
|
12
|
+
CSS: /*css*/`
|
|
13
|
+
.ultravisor-tasklist {
|
|
14
|
+
padding: 2em;
|
|
15
|
+
max-width: 1200px;
|
|
16
|
+
margin: 0 auto;
|
|
17
|
+
}
|
|
18
|
+
.ultravisor-tasklist-header {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
align-items: center;
|
|
22
|
+
margin-bottom: 1.5em;
|
|
23
|
+
padding-bottom: 1em;
|
|
24
|
+
border-bottom: 1px solid #2a2a4a;
|
|
25
|
+
}
|
|
26
|
+
.ultravisor-tasklist-header h1 {
|
|
27
|
+
margin: 0;
|
|
28
|
+
font-size: 2em;
|
|
29
|
+
font-weight: 300;
|
|
30
|
+
color: #e0e0e0;
|
|
31
|
+
}
|
|
32
|
+
.ultravisor-task-table {
|
|
33
|
+
width: 100%;
|
|
34
|
+
border-collapse: collapse;
|
|
35
|
+
}
|
|
36
|
+
.ultravisor-task-table th {
|
|
37
|
+
background-color: #16213e;
|
|
38
|
+
}
|
|
39
|
+
.ultravisor-task-table tr:hover td {
|
|
40
|
+
background-color: #1a2744;
|
|
41
|
+
}
|
|
42
|
+
.ultravisor-task-type-badge {
|
|
43
|
+
display: inline-block;
|
|
44
|
+
padding: 0.15em 0.5em;
|
|
45
|
+
border-radius: 3px;
|
|
46
|
+
font-size: 0.8em;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
background-color: #1a4a7a;
|
|
49
|
+
color: #4fc3f7;
|
|
50
|
+
}
|
|
51
|
+
.ultravisor-task-actions {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 0.4em;
|
|
54
|
+
}
|
|
55
|
+
.ultravisor-btn-sm {
|
|
56
|
+
padding: 0.3em 0.6em;
|
|
57
|
+
border-radius: 3px;
|
|
58
|
+
font-size: 0.8em;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
border: none;
|
|
61
|
+
}
|
|
62
|
+
.ultravisor-btn-execute {
|
|
63
|
+
background-color: #66bb6a;
|
|
64
|
+
color: #1a1a2e;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
}
|
|
67
|
+
.ultravisor-btn-execute:hover {
|
|
68
|
+
background-color: #81c784;
|
|
69
|
+
}
|
|
70
|
+
.ultravisor-btn-edit {
|
|
71
|
+
background-color: #42a5f5;
|
|
72
|
+
color: #fff;
|
|
73
|
+
}
|
|
74
|
+
.ultravisor-btn-edit:hover {
|
|
75
|
+
background-color: #64b5f6;
|
|
76
|
+
}
|
|
77
|
+
.ultravisor-btn-delete {
|
|
78
|
+
background-color: #ef5350;
|
|
79
|
+
color: #fff;
|
|
80
|
+
}
|
|
81
|
+
.ultravisor-btn-delete:hover {
|
|
82
|
+
background-color: #e53935;
|
|
83
|
+
}
|
|
84
|
+
.ultravisor-empty-message {
|
|
85
|
+
text-align: center;
|
|
86
|
+
padding: 3em;
|
|
87
|
+
color: #607d8b;
|
|
88
|
+
font-size: 1.1em;
|
|
89
|
+
}
|
|
90
|
+
.ultravisor-task-result-panel {
|
|
91
|
+
background: #16213e;
|
|
92
|
+
border: 1px solid #2a2a4a;
|
|
93
|
+
border-radius: 8px;
|
|
94
|
+
padding: 1.5em;
|
|
95
|
+
margin-top: 1em;
|
|
96
|
+
}
|
|
97
|
+
.ultravisor-task-result-panel h3 {
|
|
98
|
+
margin: 0 0 0.75em 0;
|
|
99
|
+
color: #b0bec5;
|
|
100
|
+
}
|
|
101
|
+
.ultravisor-task-result-output {
|
|
102
|
+
background: #0d1117;
|
|
103
|
+
color: #c9d1d9;
|
|
104
|
+
border-radius: 4px;
|
|
105
|
+
padding: 0.75em;
|
|
106
|
+
font-family: monospace;
|
|
107
|
+
font-size: 0.85em;
|
|
108
|
+
white-space: pre-wrap;
|
|
109
|
+
word-break: break-all;
|
|
110
|
+
max-height: 300px;
|
|
111
|
+
overflow-y: auto;
|
|
112
|
+
margin-top: 0.5em;
|
|
113
|
+
}
|
|
114
|
+
`,
|
|
115
|
+
|
|
116
|
+
Templates:
|
|
117
|
+
[
|
|
118
|
+
{
|
|
119
|
+
Hash: "Ultravisor-TaskList-Template",
|
|
120
|
+
Template: /*html*/`
|
|
121
|
+
<div class="ultravisor-tasklist">
|
|
122
|
+
<div class="ultravisor-tasklist-header">
|
|
123
|
+
<h1>Tasks</h1>
|
|
124
|
+
<button class="ultravisor-btn ultravisor-btn-primary" onclick="{~P~}.PictApplication.editTask()">New Task</button>
|
|
125
|
+
</div>
|
|
126
|
+
<div id="Ultravisor-TaskList-Body"></div>
|
|
127
|
+
<div id="Ultravisor-TaskList-Result"></div>
|
|
128
|
+
</div>
|
|
129
|
+
`
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
|
|
133
|
+
Renderables:
|
|
134
|
+
[
|
|
135
|
+
{
|
|
136
|
+
RenderableHash: "Ultravisor-TaskList-Content",
|
|
137
|
+
TemplateHash: "Ultravisor-TaskList-Template",
|
|
138
|
+
DestinationAddress: "#Ultravisor-Content-Container",
|
|
139
|
+
RenderMethod: "replace"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
class UltravisorTaskListView extends libPictView
|
|
145
|
+
{
|
|
146
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
147
|
+
{
|
|
148
|
+
super(pFable, pOptions, pServiceHash);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent)
|
|
152
|
+
{
|
|
153
|
+
this.pict.PictApplication.loadTasks(
|
|
154
|
+
function ()
|
|
155
|
+
{
|
|
156
|
+
this.renderTaskTable();
|
|
157
|
+
}.bind(this));
|
|
158
|
+
|
|
159
|
+
return super.onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
renderTaskTable()
|
|
163
|
+
{
|
|
164
|
+
let tmpTaskList = this.pict.AppData.Ultravisor.TaskList;
|
|
165
|
+
|
|
166
|
+
if (!tmpTaskList || tmpTaskList.length === 0)
|
|
167
|
+
{
|
|
168
|
+
this.pict.ContentAssignment.assignContent('#Ultravisor-TaskList-Body',
|
|
169
|
+
'<div class="ultravisor-empty-message">No tasks defined. Click "New Task" to create one.</div>');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let tmpHTML = '<table class="ultravisor-task-table">';
|
|
174
|
+
tmpHTML += '<thead><tr><th>GUID</th><th>Name</th><th>Type</th><th>Actions</th></tr></thead>';
|
|
175
|
+
tmpHTML += '<tbody>';
|
|
176
|
+
|
|
177
|
+
for (let i = 0; i < tmpTaskList.length; i++)
|
|
178
|
+
{
|
|
179
|
+
let tmpTask = tmpTaskList[i];
|
|
180
|
+
let tmpGUID = tmpTask.GUIDTask || '';
|
|
181
|
+
let tmpName = tmpTask.Name || tmpGUID;
|
|
182
|
+
let tmpType = tmpTask.Type || 'Unknown';
|
|
183
|
+
let tmpEscGUID = tmpGUID.replace(/'/g, "\\'");
|
|
184
|
+
|
|
185
|
+
tmpHTML += '<tr>';
|
|
186
|
+
tmpHTML += '<td><code>' + tmpGUID + '</code></td>';
|
|
187
|
+
tmpHTML += '<td>' + tmpName + '</td>';
|
|
188
|
+
tmpHTML += '<td><span class="ultravisor-task-type-badge">' + tmpType + '</span></td>';
|
|
189
|
+
tmpHTML += '<td><div class="ultravisor-task-actions">';
|
|
190
|
+
tmpHTML += '<button class="ultravisor-btn-sm ultravisor-btn-execute" onclick="' + '_Pict' + '.views[\'Ultravisor-TaskList\'].runTask(\'' + tmpEscGUID + '\')">Run</button>';
|
|
191
|
+
tmpHTML += '<button class="ultravisor-btn-sm ultravisor-btn-edit" onclick="' + '_Pict' + '.PictApplication.editTask(\'' + tmpEscGUID + '\')">Edit</button>';
|
|
192
|
+
tmpHTML += '<button class="ultravisor-btn-sm ultravisor-btn-delete" onclick="if(confirm(\'Delete task ' + tmpEscGUID + '?\')){ ' + '_Pict' + '.PictApplication.deleteTask(\'' + tmpEscGUID + '\', function(){ ' + '_Pict' + '.PictApplication.showView(\'Ultravisor-TaskList\'); }); }">Delete</button>';
|
|
193
|
+
tmpHTML += '</div></td>';
|
|
194
|
+
tmpHTML += '</tr>';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
tmpHTML += '</tbody></table>';
|
|
198
|
+
this.pict.ContentAssignment.assignContent('#Ultravisor-TaskList-Body', tmpHTML);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
runTask(pGUIDTask)
|
|
202
|
+
{
|
|
203
|
+
this.pict.ContentAssignment.assignContent('#Ultravisor-TaskList-Result',
|
|
204
|
+
'<div class="ultravisor-task-result-panel"><h3>Running task ' + pGUIDTask + '...</h3></div>');
|
|
205
|
+
|
|
206
|
+
this.pict.PictApplication.executeTask(pGUIDTask,
|
|
207
|
+
function (pError, pData)
|
|
208
|
+
{
|
|
209
|
+
if (pError)
|
|
210
|
+
{
|
|
211
|
+
this.pict.ContentAssignment.assignContent('#Ultravisor-TaskList-Result',
|
|
212
|
+
'<div class="ultravisor-task-result-panel"><h3>Error</h3><p style="color:#ef5350;">' + this.escapeHTML(pError.message) + '</p></div>');
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let tmpHTML = '<div class="ultravisor-task-result-panel">';
|
|
217
|
+
tmpHTML += '<h3>Task Result: ' + this.escapeHTML(pData.Name || pData.GUIDTask || '') + '</h3>';
|
|
218
|
+
tmpHTML += '<p><strong>Status:</strong> <span class="ultravisor-manifest-status ' + (pData.Status || '').toLowerCase() + '">' + this.escapeHTML(pData.Status || '') + '</span>';
|
|
219
|
+
tmpHTML += ' · <strong>Success:</strong> ' + (pData.Success ? '<span style="color:#66bb6a;">Yes</span>' : '<span style="color:#ef5350;">No</span>') + '</p>';
|
|
220
|
+
tmpHTML += '<p><strong>Start:</strong> ' + this.escapeHTML(pData.StartTime || '') + ' · <strong>Stop:</strong> ' + this.escapeHTML(pData.StopTime || '') + '</p>';
|
|
221
|
+
|
|
222
|
+
if (pData.Output)
|
|
223
|
+
{
|
|
224
|
+
tmpHTML += '<h4 style="color:#b0bec5; margin:0.75em 0 0.25em 0;">Output</h4>';
|
|
225
|
+
tmpHTML += '<div class="ultravisor-task-result-output">' + this.escapeHTML(String(pData.Output)) + '</div>';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (pData.Log && pData.Log.length > 0)
|
|
229
|
+
{
|
|
230
|
+
tmpHTML += '<h4 style="color:#b0bec5; margin:0.75em 0 0.25em 0;">Log</h4>';
|
|
231
|
+
tmpHTML += '<div class="ultravisor-task-result-output">' + this.escapeHTML(pData.Log.join('\n')) + '</div>';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
tmpHTML += '</div>';
|
|
235
|
+
this.pict.ContentAssignment.assignContent('#Ultravisor-TaskList-Result', tmpHTML);
|
|
236
|
+
}.bind(this));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
escapeHTML(pValue)
|
|
240
|
+
{
|
|
241
|
+
if (!pValue) return '';
|
|
242
|
+
return String(pValue).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
module.exports = UltravisorTaskListView;
|
|
247
|
+
|
|
248
|
+
module.exports.default_configuration = _ViewConfiguration;
|