alchemy-chimera 1.3.0-alpha.4 → 1.3.0
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/CHANGELOG.md +10 -0
- package/CLAUDE.md +297 -0
- package/assets/stylesheets/chimera/chimera.scss +277 -0
- package/config/routes.js +38 -0
- package/controller/00-chimera_controller.js +36 -6
- package/controller/chimera_editor_controller.js +52 -7
- package/controller/chimera_settings_controller.js +1 -0
- package/controller/chimera_static_controller.js +163 -2
- package/controller/system_task_controller.js +224 -0
- package/element/chimera_dashboard_button.js +100 -0
- package/element/chimera_run_task_button.js +93 -0
- package/element/chimera_task_monitor.js +672 -0
- package/lib/chimera_config.js +94 -0
- package/lib/toolbar_buttons.js +78 -0
- package/model/00_chimera_model.js +11 -0
- package/model/chimera_dashboard_config_model.js +44 -0
- package/package.json +4 -4
- package/view/chimera/dashboard.hwk +4 -3
- package/view/chimera/editor/task_monitor.hwk +32 -0
- package/view/chimera/toolbar/customize_dashboard_button.hwk +26 -0
- package/view/chimera/toolbar/monitor_button.hwk +8 -0
- package/view/chimera/toolbar/reset_dashboard_button.hwk +26 -0
- package/view/chimera/toolbar/run_task_button.hwk +25 -0
- package/view/elements/chimera_task_monitor.hwk +80 -0
- package/view/layouts/chimera_body.hwk +46 -4
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chimera-run-task-button element
|
|
3
|
+
* A button that triggers the SystemTask#run API to run a task manually
|
|
4
|
+
*
|
|
5
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
6
|
+
* @since 1.3.0
|
|
7
|
+
* @version 1.3.0
|
|
8
|
+
*/
|
|
9
|
+
const RunTaskButton = Function.inherits('Alchemy.Element.Form.Button', 'Alchemy.Element.Chimera', 'RunTaskButton');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Set the custom element prefix to 'chimera'
|
|
13
|
+
*
|
|
14
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
15
|
+
* @since 1.3.0
|
|
16
|
+
* @version 1.3.0
|
|
17
|
+
*/
|
|
18
|
+
RunTaskButton.setStatic('custom_element_prefix', 'chimera');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The task ID to run
|
|
22
|
+
*
|
|
23
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
24
|
+
* @since 1.3.0
|
|
25
|
+
* @version 1.3.0
|
|
26
|
+
*/
|
|
27
|
+
RunTaskButton.setAttribute('task-id');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The element has been added to the dom for the first time
|
|
31
|
+
*
|
|
32
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
33
|
+
* @since 1.3.0
|
|
34
|
+
* @version 1.3.0
|
|
35
|
+
*/
|
|
36
|
+
RunTaskButton.setMethod(function introduced() {
|
|
37
|
+
|
|
38
|
+
// Call parent introduced first (sets up click/keyup listeners)
|
|
39
|
+
introduced.super.call(this);
|
|
40
|
+
|
|
41
|
+
// Listen to the activate event (emitted by parent Button class on click)
|
|
42
|
+
this.addEventListener('activate', async e => {
|
|
43
|
+
await this.runTask();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Run the task via API
|
|
49
|
+
*
|
|
50
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
51
|
+
* @since 1.3.0
|
|
52
|
+
* @version 1.3.0
|
|
53
|
+
*/
|
|
54
|
+
RunTaskButton.setMethod(async function runTask() {
|
|
55
|
+
|
|
56
|
+
let task_id = this.task_id;
|
|
57
|
+
|
|
58
|
+
if (!task_id) {
|
|
59
|
+
console.error('No task ID provided');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.setState('busy');
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
let result = await this.hawkejs_helpers.Alchemy.getResource({
|
|
67
|
+
name : 'Chimera.SystemTask#run',
|
|
68
|
+
method : 'post',
|
|
69
|
+
}, {
|
|
70
|
+
_id: task_id,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
this.setState('done');
|
|
74
|
+
|
|
75
|
+
// Redirect to the task monitor page if we have a task history ID
|
|
76
|
+
if (result && result.task_history_id) {
|
|
77
|
+
// Construct the URL for the task monitor page
|
|
78
|
+
let monitor_url = alchemy.routeUrl('Chimera.Editor#taskMonitor', {
|
|
79
|
+
task_history_id: result.task_history_id
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Navigate to the monitor page
|
|
83
|
+
if (Blast.isBrowser && typeof hawkejs !== 'undefined' && hawkejs.scene) {
|
|
84
|
+
hawkejs.scene.openUrl(monitor_url);
|
|
85
|
+
} else {
|
|
86
|
+
window.location.href = monitor_url;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error('Failed to run task:', err);
|
|
91
|
+
this.setState('error', 3000, 'default');
|
|
92
|
+
}
|
|
93
|
+
});
|