ultravisor 1.0.3 → 1.0.4

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.
Files changed (109) hide show
  1. package/.claude/launch.json +11 -0
  2. package/.claude/ultravisor-dev-config.json +3 -0
  3. package/.ultravisor.json +426 -0
  4. package/package.json +7 -6
  5. package/source/Ultravisor.cjs +22 -3
  6. package/source/cli/Ultravisor-CLIProgram.cjs +35 -23
  7. package/source/cli/commands/Ultravisor-Command-SingleOperation.cjs +29 -18
  8. package/source/cli/commands/Ultravisor-Command-SingleTask.cjs +62 -19
  9. package/source/cli/commands/Ultravisor-Command-UpdateTask.cjs +27 -15
  10. package/source/config/Ultravisor-Default-Command-Configuration.cjs +5 -3
  11. package/source/services/Ultravisor-ExecutionEngine.cjs +1039 -0
  12. package/source/services/Ultravisor-ExecutionManifest.cjs +399 -0
  13. package/source/services/Ultravisor-Hypervisor-State.cjs +270 -97
  14. package/source/services/Ultravisor-Hypervisor.cjs +38 -83
  15. package/source/services/Ultravisor-StateManager.cjs +241 -0
  16. package/source/services/Ultravisor-TaskTypeRegistry.cjs +143 -0
  17. package/source/services/tasks/Ultravisor-TaskType-Base.cjs +105 -0
  18. package/source/services/tasks/control/Ultravisor-TaskType-IfConditional.cjs +148 -0
  19. package/source/services/tasks/control/Ultravisor-TaskType-LaunchOperation.cjs +187 -0
  20. package/source/services/tasks/control/Ultravisor-TaskType-SplitExecute.cjs +184 -0
  21. package/source/services/tasks/data/Ultravisor-TaskType-ReplaceString.cjs +82 -0
  22. package/source/services/tasks/data/Ultravisor-TaskType-SetValues.cjs +81 -0
  23. package/source/services/tasks/data/Ultravisor-TaskType-StringAppender.cjs +101 -0
  24. package/source/services/tasks/file-io/Ultravisor-TaskType-ReadFile.cjs +103 -0
  25. package/source/services/tasks/file-io/Ultravisor-TaskType-WriteFile.cjs +117 -0
  26. package/source/services/tasks/interaction/Ultravisor-TaskType-ErrorMessage.cjs +54 -0
  27. package/source/services/tasks/interaction/Ultravisor-TaskType-ValueInput.cjs +62 -0
  28. package/source/web_server/Ultravisor-API-Server.cjs +237 -124
  29. package/test/Ultravisor_browser_tests.js +2226 -0
  30. package/test/Ultravisor_tests.js +1143 -5830
  31. package/webinterface/css/ultravisor.css +23 -0
  32. package/webinterface/package.json +6 -3
  33. package/webinterface/source/Pict-Application-Ultravisor.js +93 -73
  34. package/webinterface/source/cards/FlowCard-CSVTransform.js +43 -0
  35. package/webinterface/source/cards/FlowCard-Command.js +86 -0
  36. package/webinterface/source/cards/FlowCard-ComprehensionIntersect.js +40 -0
  37. package/webinterface/source/cards/FlowCard-Conditional.js +87 -0
  38. package/webinterface/source/cards/FlowCard-CopyFile.js +55 -0
  39. package/webinterface/source/cards/FlowCard-End.js +29 -0
  40. package/webinterface/source/cards/FlowCard-GetJSON.js +55 -0
  41. package/webinterface/source/cards/FlowCard-GetText.js +54 -0
  42. package/webinterface/source/cards/FlowCard-Histogram.js +176 -0
  43. package/webinterface/source/cards/FlowCard-LaunchOperation.js +82 -0
  44. package/webinterface/source/cards/FlowCard-ListFiles.js +55 -0
  45. package/webinterface/source/cards/FlowCard-MeadowCount.js +44 -0
  46. package/webinterface/source/cards/FlowCard-MeadowCreate.js +44 -0
  47. package/webinterface/source/cards/FlowCard-MeadowDelete.js +45 -0
  48. package/webinterface/source/cards/FlowCard-MeadowRead.js +46 -0
  49. package/webinterface/source/cards/FlowCard-MeadowReads.js +46 -0
  50. package/webinterface/source/cards/FlowCard-MeadowUpdate.js +44 -0
  51. package/webinterface/source/cards/FlowCard-ParseCSV.js +85 -0
  52. package/webinterface/source/cards/FlowCard-ReadJSON.js +54 -0
  53. package/webinterface/source/cards/FlowCard-ReadText.js +54 -0
  54. package/webinterface/source/cards/FlowCard-RestRequest.js +59 -0
  55. package/webinterface/source/cards/FlowCard-SendJSON.js +57 -0
  56. package/webinterface/source/cards/FlowCard-Solver.js +77 -0
  57. package/webinterface/source/cards/FlowCard-Start.js +29 -0
  58. package/webinterface/source/cards/FlowCard-TemplateString.js +77 -0
  59. package/webinterface/source/cards/FlowCard-WriteJSON.js +54 -0
  60. package/webinterface/source/cards/FlowCard-WriteText.js +54 -0
  61. package/webinterface/source/data/ExampleFlow-CSVPipeline.js +231 -0
  62. package/webinterface/source/data/ExampleFlow-FileProcessor.js +315 -0
  63. package/webinterface/source/data/ExampleFlow-MeadowPipeline.js +328 -0
  64. package/webinterface/source/providers/PictRouter-Ultravisor-Configuration.json +8 -8
  65. package/webinterface/source/views/PictView-Ultravisor-Dashboard.js +6 -6
  66. package/webinterface/source/views/PictView-Ultravisor-FlowEditor.js +436 -0
  67. package/webinterface/source/views/PictView-Ultravisor-ManifestList.js +45 -43
  68. package/webinterface/source/views/PictView-Ultravisor-OperationEdit.js +34 -89
  69. package/webinterface/source/views/PictView-Ultravisor-OperationList.js +128 -13
  70. package/webinterface/source/views/PictView-Ultravisor-PendingInput.js +314 -0
  71. package/webinterface/source/views/PictView-Ultravisor-Schedule.js +18 -53
  72. package/webinterface/source/views/PictView-Ultravisor-TimingView.js +27 -14
  73. package/webinterface/source/views/PictView-Ultravisor-TopBar.js +2 -1
  74. package/debug/Harness.js +0 -6
  75. package/source/services/Ultravisor-Operation-Manifest.cjs +0 -160
  76. package/source/services/Ultravisor-Operation.cjs +0 -200
  77. package/source/services/Ultravisor-Task.cjs +0 -349
  78. package/source/services/events/Ultravisor-Hypervisor-Event-Solver.cjs +0 -11
  79. package/source/services/tasks/Ultravisor-Task-Base.cjs +0 -264
  80. package/source/services/tasks/Ultravisor-Task-CollectValues.cjs +0 -188
  81. package/source/services/tasks/Ultravisor-Task-Command.cjs +0 -65
  82. package/source/services/tasks/Ultravisor-Task-CommandEach.cjs +0 -190
  83. package/source/services/tasks/Ultravisor-Task-Conditional.cjs +0 -104
  84. package/source/services/tasks/Ultravisor-Task-DateWindow.cjs +0 -72
  85. package/source/services/tasks/Ultravisor-Task-GeneratePagedOperation.cjs +0 -336
  86. package/source/services/tasks/Ultravisor-Task-LaunchOperation.cjs +0 -143
  87. package/source/services/tasks/Ultravisor-Task-LaunchTask.cjs +0 -146
  88. package/source/services/tasks/Ultravisor-Task-LineMatch.cjs +0 -158
  89. package/source/services/tasks/Ultravisor-Task-Request.cjs +0 -56
  90. package/source/services/tasks/Ultravisor-Task-Solver.cjs +0 -89
  91. package/source/services/tasks/Ultravisor-Task-TemplateString.cjs +0 -93
  92. package/source/services/tasks/rest/Ultravisor-Task-GetBinary.cjs +0 -127
  93. package/source/services/tasks/rest/Ultravisor-Task-GetJSON.cjs +0 -119
  94. package/source/services/tasks/rest/Ultravisor-Task-GetText.cjs +0 -109
  95. package/source/services/tasks/rest/Ultravisor-Task-GetXML.cjs +0 -112
  96. package/source/services/tasks/rest/Ultravisor-Task-RestRequest.cjs +0 -499
  97. package/source/services/tasks/rest/Ultravisor-Task-SendJSON.cjs +0 -150
  98. package/source/services/tasks/stagingfiles/Ultravisor-Task-CopyFile.cjs +0 -110
  99. package/source/services/tasks/stagingfiles/Ultravisor-Task-ListFiles.cjs +0 -89
  100. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadBinary.cjs +0 -87
  101. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadJSON.cjs +0 -67
  102. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadText.cjs +0 -66
  103. package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadXML.cjs +0 -69
  104. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteBinary.cjs +0 -95
  105. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteJSON.cjs +0 -96
  106. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteText.cjs +0 -99
  107. package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteXML.cjs +0 -102
  108. package/webinterface/source/views/PictView-Ultravisor-TaskEdit.js +0 -220
  109. package/webinterface/source/views/PictView-Ultravisor-TaskList.js +0 -248
@@ -1,99 +0,0 @@
1
- const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
2
-
3
- const libFS = require('fs');
4
- const libPath = require('path');
5
-
6
- class UltravisorTaskWriteText extends libUltravisorTaskBase
7
- {
8
- constructor(pFable)
9
- {
10
- super(pFable);
11
- }
12
-
13
- /**
14
- * Write text content to a file in the staging folder.
15
- *
16
- * Task definition fields:
17
- * - File: relative file path inside the staging folder
18
- * - Address (optional): dot-notation path into GlobalState to
19
- * resolve the data to write (used instead of Data)
20
- * - Data: the string to write
21
- *
22
- * Either Address or Data must be provided. When Address is set,
23
- * the data is resolved from pContext.GlobalState (or NodeState).
24
- */
25
- execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
26
- {
27
- let tmpStagingPath = this.resolveStagingPath(pContext);
28
- let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
29
-
30
- if (!tmpFilePath)
31
- {
32
- pManifestEntry.StopTime = new Date().toISOString();
33
- pManifestEntry.Status = 'Error';
34
- pManifestEntry.Log.push(`WriteText: missing or invalid File field.`);
35
- return fCallback(null, pManifestEntry);
36
- }
37
-
38
- // Resolve data from Address or Data
39
- let tmpData;
40
-
41
- if (pTaskDefinition.Address && typeof(pTaskDefinition.Address) === 'string')
42
- {
43
- tmpData = this.resolveAddress(pTaskDefinition.Address, pContext);
44
- pManifestEntry.Log.push(`WriteText: resolved data from Address "${pTaskDefinition.Address}".`);
45
- }
46
- else if (pTaskDefinition.hasOwnProperty('Data'))
47
- {
48
- tmpData = pTaskDefinition.Data;
49
- }
50
- else
51
- {
52
- pManifestEntry.StopTime = new Date().toISOString();
53
- pManifestEntry.Status = 'Error';
54
- pManifestEntry.Log.push(`WriteText: missing Data or Address field.`);
55
- return fCallback(null, pManifestEntry);
56
- }
57
-
58
- if (tmpData === undefined)
59
- {
60
- pManifestEntry.StopTime = new Date().toISOString();
61
- pManifestEntry.Status = 'Error';
62
- pManifestEntry.Log.push(`WriteText: resolved data is undefined.`);
63
- return fCallback(null, pManifestEntry);
64
- }
65
-
66
- let tmpContent = (typeof(tmpData) === 'string')
67
- ? tmpData
68
- : String(tmpData);
69
-
70
- pManifestEntry.Log.push(`WriteText: writing to ${tmpFilePath}`);
71
-
72
- try
73
- {
74
- let tmpDir = libPath.dirname(tmpFilePath);
75
- if (!libFS.existsSync(tmpDir))
76
- {
77
- libFS.mkdirSync(tmpDir, { recursive: true });
78
- }
79
-
80
- libFS.writeFileSync(tmpFilePath, tmpContent, 'utf8');
81
-
82
- pManifestEntry.StopTime = new Date().toISOString();
83
- pManifestEntry.Status = 'Complete';
84
- pManifestEntry.Success = true;
85
- pManifestEntry.Output = `${tmpContent.length} bytes written`;
86
- pManifestEntry.Log.push(`WriteText: wrote ${tmpContent.length} bytes.`);
87
- }
88
- catch (pError)
89
- {
90
- pManifestEntry.StopTime = new Date().toISOString();
91
- pManifestEntry.Status = 'Error';
92
- pManifestEntry.Log.push(`WriteText: ${pError.message}`);
93
- }
94
-
95
- return fCallback(null, pManifestEntry);
96
- }
97
- }
98
-
99
- module.exports = UltravisorTaskWriteText;
@@ -1,102 +0,0 @@
1
- const libUltravisorTaskBase = require('../Ultravisor-Task-Base.cjs');
2
-
3
- const libFS = require('fs');
4
- const libPath = require('path');
5
-
6
- class UltravisorTaskWriteXML extends libUltravisorTaskBase
7
- {
8
- constructor(pFable)
9
- {
10
- super(pFable);
11
- }
12
-
13
- /**
14
- * Write XML content to a file in the staging folder.
15
- *
16
- * The Data field should be a string containing well-formed XML.
17
- * Creates intermediate directories automatically.
18
- *
19
- * Task definition fields:
20
- * - File: relative file path inside the staging folder
21
- * - Address (optional): dot-notation path into GlobalState to
22
- * resolve the data to write (used instead of Data)
23
- * - Data: XML string to write
24
- *
25
- * Either Address or Data must be provided. When Address is set,
26
- * the data is resolved from pContext.GlobalState (or NodeState).
27
- */
28
- execute(pTaskDefinition, pContext, pManifestEntry, fCallback)
29
- {
30
- let tmpStagingPath = this.resolveStagingPath(pContext);
31
- let tmpFilePath = this.resolveStagingFilePath(tmpStagingPath, pTaskDefinition.File);
32
-
33
- if (!tmpFilePath)
34
- {
35
- pManifestEntry.StopTime = new Date().toISOString();
36
- pManifestEntry.Status = 'Error';
37
- pManifestEntry.Log.push(`WriteXML: missing or invalid File field.`);
38
- return fCallback(null, pManifestEntry);
39
- }
40
-
41
- // Resolve data from Address or Data
42
- let tmpData;
43
-
44
- if (pTaskDefinition.Address && typeof(pTaskDefinition.Address) === 'string')
45
- {
46
- tmpData = this.resolveAddress(pTaskDefinition.Address, pContext);
47
- pManifestEntry.Log.push(`WriteXML: resolved data from Address "${pTaskDefinition.Address}".`);
48
- }
49
- else if (pTaskDefinition.hasOwnProperty('Data'))
50
- {
51
- tmpData = pTaskDefinition.Data;
52
- }
53
- else
54
- {
55
- pManifestEntry.StopTime = new Date().toISOString();
56
- pManifestEntry.Status = 'Error';
57
- pManifestEntry.Log.push(`WriteXML: missing Data or Address field.`);
58
- return fCallback(null, pManifestEntry);
59
- }
60
-
61
- if (tmpData === undefined)
62
- {
63
- pManifestEntry.StopTime = new Date().toISOString();
64
- pManifestEntry.Status = 'Error';
65
- pManifestEntry.Log.push(`WriteXML: resolved data is undefined.`);
66
- return fCallback(null, pManifestEntry);
67
- }
68
-
69
- let tmpContent = (typeof(tmpData) === 'string')
70
- ? tmpData
71
- : String(tmpData);
72
-
73
- pManifestEntry.Log.push(`WriteXML: writing to ${tmpFilePath}`);
74
-
75
- try
76
- {
77
- let tmpDir = libPath.dirname(tmpFilePath);
78
- if (!libFS.existsSync(tmpDir))
79
- {
80
- libFS.mkdirSync(tmpDir, { recursive: true });
81
- }
82
-
83
- libFS.writeFileSync(tmpFilePath, tmpContent, 'utf8');
84
-
85
- pManifestEntry.StopTime = new Date().toISOString();
86
- pManifestEntry.Status = 'Complete';
87
- pManifestEntry.Success = true;
88
- pManifestEntry.Output = `${tmpContent.length} bytes written`;
89
- pManifestEntry.Log.push(`WriteXML: wrote ${tmpContent.length} bytes.`);
90
- }
91
- catch (pError)
92
- {
93
- pManifestEntry.StopTime = new Date().toISOString();
94
- pManifestEntry.Status = 'Error';
95
- pManifestEntry.Log.push(`WriteXML: ${pError.message}`);
96
- }
97
-
98
- return fCallback(null, pManifestEntry);
99
- }
100
- }
101
-
102
- module.exports = UltravisorTaskWriteXML;
@@ -1,220 +0,0 @@
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, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
176
- }
177
-
178
- escapeHTML(pValue)
179
- {
180
- if (!pValue) return '';
181
- return String(pValue).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
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;
@@ -1,248 +0,0 @@
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 += ' &middot; <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 || '') + ' &middot; <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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
243
- }
244
- }
245
-
246
- module.exports = UltravisorTaskListView;
247
-
248
- module.exports.default_configuration = _ViewConfiguration;