zrb 1.0.0a17__py3-none-any.whl → 1.0.0a19__py3-none-any.whl
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.
- zrb/__init__.py +2 -0
- zrb/builtin/project/add/fastapp/fastapp_task.py +25 -39
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/.flake8 +3 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/column/create_column_task.py +14 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_task.py +128 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +213 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/any_client_method.template.py → my_app_name/_zrb/entity/template/any_client_method.py} +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/module_template → my_app_name/_zrb/entity/template/app_template/module/my_module}/service/my_entity/my_entity_usecase.py +4 -5
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/repository/factory.py +13 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/module_template → my_app_name/_zrb/entity/template/app_template/module/my_module}/service/my_entity/repository/my_entity_db_repository.py +4 -4
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/module_template → my_app_name/_zrb/entity/template/app_template/module/my_module}/service/my_entity/repository/my_entity_repository.py +1 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/format_task.py +17 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/input.py +1 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_task.py +85 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +154 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/api_client.py +6 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/direct_client.py +6 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/factory.py +9 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/env.py +2 -4
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/script.py.mako +1 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/route.py +3 -3
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/task.py +12 -14
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/util.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/venv_task.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/app.py +2 -2
- zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/base_db_repository.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/db_engine.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/main.py +7 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/migrate.py +3 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/client/any_client.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/api_client.py +7 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/direct_client.py +6 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/factory.py +9 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/env.py +2 -4
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/script.py.mako +1 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration_metadata.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/route.py +4 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/factory.py +13 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/repository/user_db_repository.py +4 -4
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/repository/user_repository.py +1 -2
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/user_usecase.py +4 -5
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration/env.py +2 -4
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration/script.py.mako +1 -0
- zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/route.py +5 -5
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/subroute/auth.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/fastapp_util.py +29 -5
- zrb/builtin/python.py +4 -1
- zrb/builtin/todo.py +35 -14
- zrb/callback/callback.py +0 -1
- zrb/config.py +1 -0
- zrb/content_transformer/content_transformer.py +5 -3
- zrb/context/any_context.py +6 -6
- zrb/group/group.py +0 -1
- zrb/input/any_input.py +4 -0
- zrb/input/base_input.py +4 -4
- zrb/input/bool_input.py +1 -1
- zrb/input/float_input.py +2 -2
- zrb/input/int_input.py +1 -1
- zrb/input/option_input.py +2 -2
- zrb/input/password_input.py +2 -2
- zrb/input/text_input.py +2 -2
- zrb/runner/cli.py +2 -31
- zrb/runner/common_util.py +31 -0
- zrb/runner/web_app.py +25 -6
- zrb/runner/web_controller/static/pico.min.css +1 -1
- zrb/runner/web_controller/static/task-ui/common-util.js +63 -0
- zrb/runner/web_controller/static/task-ui/current-session.js +164 -0
- zrb/runner/web_controller/static/task-ui/event.js +120 -0
- zrb/runner/web_controller/static/task-ui/past-session.js +138 -0
- zrb/runner/web_controller/task_ui/controller.py +20 -19
- zrb/runner/web_controller/task_ui/view.html +12 -15
- zrb/session_state_logger/any_session_state_logger.py +0 -1
- zrb/session_state_logger/file_session_state_logger.py +0 -1
- zrb/task/base_trigger.py +0 -1
- zrb/task/llm_task.py +0 -1
- zrb/task/make_task.py +0 -1
- zrb/task/scaffolder.py +6 -4
- zrb/task/scheduler.py +0 -1
- zrb/util/cmd/command.py +0 -1
- zrb/util/codemod/append_code_to_class.py +4 -4
- zrb/util/codemod/append_code_to_function.py +2 -2
- zrb/util/codemod/append_code_to_method.py +2 -2
- zrb/util/codemod/prepend_code_to_module.py +2 -2
- zrb/util/file.py +1 -1
- zrb/util/todo.py +100 -17
- zrb/xcom/xcom.py +0 -1
- {zrb-1.0.0a17.dist-info → zrb-1.0.0a19.dist-info}/METADATA +1 -1
- zrb-1.0.0a19.dist-info/RECORD +241 -0
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/column/create_column_task.py +0 -11
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/entity/module_template/service/my_entity/repository/factory.py +0 -13
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/entity/task.py +0 -260
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/task.py +0 -143
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/template/module_template/client/api_client.py +0 -6
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/template/module_template/client/direct_client.py +0 -6
- zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/template/module_template/client/factory.py +0 -9
- zrb/builtin/project/add/fastapp/fastapp_template/main.py +0 -7
- zrb/builtin/project/add/fastapp/fastapp_template/migrate.py +0 -3
- zrb/builtin/project/add/fastapp/fastapp_template/module/auth/client/api_client.py +0 -7
- zrb/builtin/project/add/fastapp/fastapp_template/module/auth/client/direct_client.py +0 -6
- zrb/builtin/project/add/fastapp/fastapp_template/module/auth/client/factory.py +0 -9
- zrb/builtin/project/add/fastapp/fastapp_template/module/auth/service/user/repository/factory.py +0 -13
- zrb/runner/web_controller/task_ui/partial/common-util.js +0 -37
- zrb/runner/web_controller/task_ui/partial/main.js +0 -195
- zrb/runner/web_controller/task_ui/partial/show-existing-session.js +0 -97
- zrb/runner/web_controller/task_ui/partial/visualize-history.js +0 -104
- zrb-1.0.0a17.dist-info/RECORD +0 -234
- /zrb/builtin/project/add/fastapp/fastapp_template/{.gitignore → my_app_name/.gitignore} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{README.md → my_app_name/README.md} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{__init__.py → my_app_name/__init__.py} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/config.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/schema.template.py → my_app_name/_zrb/entity/template/app_template/schema/my_entity.py} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/group.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template/migration/versions/.gitkeep → my_app_name/_zrb/module/template/app_template/module/gateway/subroute/my_module.py} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/alembic.ini +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/client/any_client.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/README +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module/gateway → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/versions/.gitkeep +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration_metadata.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/service/__init__.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/task_definition.py → my_app_name/_zrb/module/template/module_task_definition.py} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/__init__.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/base_usecase.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/error.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/schema.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{config.py → my_app_name/config.py} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/__init__.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/alembic.ini +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/README +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/versions/3093c7336477_add_user_table.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/__init__.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/__init__.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/repository/__init__.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/alembic.ini +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration/README +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{schema/__init__.py → my_app_name/module/gateway/migration/versions/.gitkeep} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration_metadata.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{requirements.txt → my_app_name/requirements.txt} +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{schema → my_app_name/schema}/permission.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{schema → my_app_name/schema}/role.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{schema → my_app_name/schema}/user.py +0 -0
- /zrb/builtin/project/add/fastapp/fastapp_template/{template.env → my_app_name/template.env} +0 -0
- {zrb-1.0.0a17.dist-info → zrb-1.0.0a19.dist-info}/WHEEL +0 -0
- {zrb-1.0.0a17.dist-info → zrb-1.0.0a19.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
window.addEventListener("load", async function () {
|
2
|
+
// Get current session
|
3
|
+
if (cfg.SESSION_NAME != "") {
|
4
|
+
CURRENT_SESSION.pollCurrentSession();
|
5
|
+
}
|
6
|
+
// set maxStartDate to today
|
7
|
+
const tomorrow = new Date();
|
8
|
+
tomorrow.setDate(tomorrow.getDate() + 1); // Move to the next day
|
9
|
+
tomorrow.setHours(0, 0, 0, 0);
|
10
|
+
const formattedTomorrow = UTIL.toLocalDateInputValue(tomorrow);
|
11
|
+
const maxStartAtInput = document.getElementById("max-start-at-input");
|
12
|
+
maxStartAtInput.value = formattedTomorrow;
|
13
|
+
// set minStartDate to yesterday
|
14
|
+
const today = new Date();
|
15
|
+
today.setHours(0, 0, 0, 0); // Set time to 00:00:00
|
16
|
+
const formattedToday = UTIL.toLocalDateInputValue(today);
|
17
|
+
const minStartAtInput = document.getElementById("min-start-at-input");
|
18
|
+
minStartAtInput.value = formattedToday;
|
19
|
+
// Update session
|
20
|
+
PAST_SESSION.pollPastSession();
|
21
|
+
});
|
22
|
+
|
23
|
+
|
24
|
+
const submitTaskForm = document.getElementById("submit-task-form");
|
25
|
+
submitTaskForm.addEventListener("input", async function(event) {
|
26
|
+
const currentInput = event.target;
|
27
|
+
const inputs = Array.from(submitTaskForm.querySelectorAll("input[name]"));
|
28
|
+
const inputMap = {};
|
29
|
+
const fixedInputNames = [];
|
30
|
+
for (const input of inputs) {
|
31
|
+
fixedInputNames.push(input.name);
|
32
|
+
if (input === currentInput) {
|
33
|
+
inputMap[input.name] = currentInput.value;
|
34
|
+
break;
|
35
|
+
} else {
|
36
|
+
inputMap[input.name] = input.value;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
const queryString = new URLSearchParams(
|
40
|
+
{query: JSON.stringify(inputMap)}
|
41
|
+
).toString();
|
42
|
+
try {
|
43
|
+
// Send the AJAX request
|
44
|
+
const response = await fetch(`${cfg.INPUT_API_URL}?${queryString}`, {
|
45
|
+
method: "GET",
|
46
|
+
headers: {
|
47
|
+
"Content-Type": "application/json"
|
48
|
+
},
|
49
|
+
});
|
50
|
+
if (response.ok) {
|
51
|
+
const data = await response.json();
|
52
|
+
// Update the values of all subsequent inputs based on the response
|
53
|
+
Object.entries(data).forEach(([key, value]) => {
|
54
|
+
if (fixedInputNames.includes(key)) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
const input = submitTaskForm.querySelector(`[name="${key}"]`);
|
58
|
+
input.value = value;
|
59
|
+
});
|
60
|
+
} else {
|
61
|
+
console.error("Failed to fetch updated values:", response.statusText);
|
62
|
+
}
|
63
|
+
} catch (error) {
|
64
|
+
console.error("Error during fetch:", error);
|
65
|
+
}
|
66
|
+
})
|
67
|
+
|
68
|
+
|
69
|
+
function openPastSessionDialog(event) {
|
70
|
+
event.preventDefault();
|
71
|
+
const dialog = document.getElementById("past-session-dialog")
|
72
|
+
dialog.showModal();
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
function closePastSessionDialog(event) {
|
77
|
+
event.preventDefault();
|
78
|
+
const dialog = document.getElementById("past-session-dialog")
|
79
|
+
dialog.close();
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
async function submitNewSessionForm(event) {
|
84
|
+
// Prevent the form from submitting the traditional way
|
85
|
+
event.preventDefault();
|
86
|
+
// Select the form
|
87
|
+
const form = document.getElementById("submit-task-form");
|
88
|
+
// Initialize an empty object to hold form data
|
89
|
+
const formData = {};
|
90
|
+
// Iterate through each input in the form
|
91
|
+
Array.from(form.elements).forEach(element => {
|
92
|
+
// Only include inputs with a name attribute and ignore buttons
|
93
|
+
if (element.name && (element.type !== "button" && element.type !== "submit")) {
|
94
|
+
formData[element.name] = element.value;
|
95
|
+
}
|
96
|
+
});
|
97
|
+
// Convert formData to JSON
|
98
|
+
const jsonData = JSON.stringify(formData);
|
99
|
+
try {
|
100
|
+
// Send the AJAX request
|
101
|
+
const response = await fetch(cfg.SESSION_API_URL, {
|
102
|
+
method: "POST",
|
103
|
+
headers: {
|
104
|
+
"Content-Type": "application/json"
|
105
|
+
},
|
106
|
+
body: jsonData
|
107
|
+
});
|
108
|
+
if (response.ok) {
|
109
|
+
const data = await response.json();
|
110
|
+
cfg.SESSION_NAME = data.session_name;
|
111
|
+
history.pushState(null, "", `${cfg.CURRENT_URL}${cfg.SESSION_NAME}`);
|
112
|
+
await PAST_SESSION.getAndRenderPastSession(0);
|
113
|
+
await CURRENT_SESSION.pollCurrentSession();
|
114
|
+
} else {
|
115
|
+
console.error("Error:", response);
|
116
|
+
}
|
117
|
+
} catch (error) {
|
118
|
+
console.error("Error:", error);
|
119
|
+
}
|
120
|
+
}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
const PAST_SESSION = {
|
2
|
+
|
3
|
+
async pollPastSession() {
|
4
|
+
while (true) {
|
5
|
+
await this.getAndRenderPastSession(cfg.PAGE);
|
6
|
+
await UTIL.delay(5000);
|
7
|
+
}
|
8
|
+
},
|
9
|
+
|
10
|
+
async getAndRenderPastSession(page) {
|
11
|
+
cfg.PAGE=page
|
12
|
+
const minStartAtInput = document.getElementById("min-start-at-input");
|
13
|
+
const minStartAt = UTIL.formatDate(minStartAtInput.value);
|
14
|
+
const maxStartAtInput = document.getElementById("max-start-at-input");
|
15
|
+
const maxStartAt = UTIL.formatDate(maxStartAtInput.value);
|
16
|
+
const queryString = new URLSearchParams({
|
17
|
+
page: page,
|
18
|
+
from: minStartAt,
|
19
|
+
to: maxStartAt,
|
20
|
+
}).toString();
|
21
|
+
try {
|
22
|
+
// Send the AJAX request
|
23
|
+
const response = await fetch(`${cfg.SESSION_API_URL}list?${queryString}`, {
|
24
|
+
method: "GET",
|
25
|
+
headers: {
|
26
|
+
"Content-Type": "application/json"
|
27
|
+
},
|
28
|
+
});
|
29
|
+
if (response.ok) {
|
30
|
+
const {total, data} = await response.json();
|
31
|
+
this.showPastSession(page, total, data);
|
32
|
+
} else {
|
33
|
+
console.error("Error:", response);
|
34
|
+
}
|
35
|
+
} catch (error) {
|
36
|
+
console.error("Error:", error);
|
37
|
+
}
|
38
|
+
},
|
39
|
+
|
40
|
+
showPastSession(page, total, data) {
|
41
|
+
const ul = document.getElementById("past-session-ul");
|
42
|
+
ul.innerHTML = ''; // Clear existing content
|
43
|
+
data.forEach(item => {
|
44
|
+
const taskStatus = item.task_status[item.main_task_name];
|
45
|
+
const finalStatus = UTIL.getFinalTaskStatus(taskStatus);
|
46
|
+
const finalColor = UTIL.getFinalColor(finalStatus);
|
47
|
+
const taskHistories = taskStatus.history;
|
48
|
+
const taskStartTime = taskHistories.length > 0 ? taskHistories[0].time : ""
|
49
|
+
const li = document.createElement('li');
|
50
|
+
const a = document.createElement('a');
|
51
|
+
const dateSpan = document.createElement('span');
|
52
|
+
const statusSpan = document.createElement('span');
|
53
|
+
a.textContent = item.name;
|
54
|
+
a.target = '_blank';
|
55
|
+
a.href = `${cfg.UI_URL}${item.name}`;
|
56
|
+
li.appendChild(a);
|
57
|
+
statusSpan.style.marginLeft = "10px";
|
58
|
+
statusSpan.style.display = 'inline-block';
|
59
|
+
statusSpan.style.width = '15px';
|
60
|
+
statusSpan.style.height = '15px';
|
61
|
+
statusSpan.style.borderRadius = '50%';
|
62
|
+
statusSpan.style.border = '2px solid black';
|
63
|
+
statusSpan.style.backgroundColor = finalColor;
|
64
|
+
li.appendChild(statusSpan);
|
65
|
+
dateSpan.style.marginLeft = "10px";
|
66
|
+
dateSpan.textContent = taskStartTime;
|
67
|
+
li.appendChild(dateSpan);
|
68
|
+
ul.appendChild(li);
|
69
|
+
});
|
70
|
+
const paginationUl = document.getElementById("past-session-pagination-ul");
|
71
|
+
paginationUl.innerHTML = ''; // Clear previous pagination
|
72
|
+
|
73
|
+
const totalPages = Math.ceil(total / 10); // Calculate total pages based on page size
|
74
|
+
const maxPagesToShow = 5; // Number of pages to display around the current page
|
75
|
+
const halfMaxPages = Math.floor(maxPagesToShow / 2);
|
76
|
+
|
77
|
+
// Add first page and previous controls
|
78
|
+
if (page > 0) {
|
79
|
+
paginationUl.appendChild(this.createPageLink("⟪", 0)); // Go to first page
|
80
|
+
paginationUl.appendChild(this.createPageLink("⟨", page - 1)); // Go to previous page
|
81
|
+
}
|
82
|
+
|
83
|
+
let startPage = Math.max(0, page - halfMaxPages);
|
84
|
+
let endPage = Math.min(totalPages - 1, page + halfMaxPages);
|
85
|
+
|
86
|
+
if (page <= halfMaxPages) {
|
87
|
+
endPage = Math.min(totalPages - 1, maxPagesToShow - 1);
|
88
|
+
} else if (page + halfMaxPages >= totalPages) {
|
89
|
+
startPage = Math.max(0, totalPages - maxPagesToShow);
|
90
|
+
}
|
91
|
+
|
92
|
+
if (startPage > 1) {
|
93
|
+
paginationUl.appendChild(this.createEllipsis());
|
94
|
+
}
|
95
|
+
|
96
|
+
// Add page links within the calculated range
|
97
|
+
for (let i = startPage; i <= endPage; i++) {
|
98
|
+
if (i === page) {
|
99
|
+
const pageLi = document.createElement('li');
|
100
|
+
pageLi.textContent = i + 1;
|
101
|
+
paginationUl.append(pageLi)
|
102
|
+
} else {
|
103
|
+
paginationUl.appendChild(this.createPageLink(i + 1, i))
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
// Add ellipsis after the end page if needed
|
108
|
+
if (endPage < totalPages - 2) {
|
109
|
+
paginationUl.appendChild(this.createEllipsis());
|
110
|
+
}
|
111
|
+
|
112
|
+
// Add next and last page controls
|
113
|
+
if (page < totalPages - 1) {
|
114
|
+
paginationUl.appendChild(this.createPageLink("⟩", page + 1)); // Go to next page
|
115
|
+
paginationUl.appendChild(this.createPageLink("⟫", totalPages - 1)); // Go to last page
|
116
|
+
}
|
117
|
+
},
|
118
|
+
|
119
|
+
createPageLink(text, page) {
|
120
|
+
const li = document.createElement('li');
|
121
|
+
const link = document.createElement('a');
|
122
|
+
link.textContent = text;
|
123
|
+
link.href = '#';
|
124
|
+
link.onclick = (e) => {
|
125
|
+
e.preventDefault();
|
126
|
+
this.getAndRenderPastSession(page);
|
127
|
+
};
|
128
|
+
li.appendChild(link);
|
129
|
+
return li;
|
130
|
+
},
|
131
|
+
|
132
|
+
createEllipsis() {
|
133
|
+
const li = document.createElement('li');
|
134
|
+
li.textContent = '...';
|
135
|
+
return li;
|
136
|
+
},
|
137
|
+
|
138
|
+
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import json
|
1
2
|
import os
|
2
3
|
|
3
4
|
from zrb.group.any_group import AnyGroup
|
@@ -10,14 +11,6 @@ _DIR = os.path.dirname(__file__)
|
|
10
11
|
|
11
12
|
_VIEW_TEMPLATE = read_file(os.path.join(_DIR, "view.html"))
|
12
13
|
_TASK_INPUT_TEMPLATE = read_file(os.path.join(_DIR, "partial", "input.html"))
|
13
|
-
_MAIN_SCRIPT = read_file(os.path.join(_DIR, "partial", "main.js"))
|
14
|
-
_SHOW_EXISTING_SESSION_SCRIPT = read_file(
|
15
|
-
os.path.join(_DIR, "partial", "show-existing-session.js")
|
16
|
-
)
|
17
|
-
_VISUALIZE_HISTORY_SCRIPT = read_file(
|
18
|
-
os.path.join(_DIR, "partial", "visualize-history.js")
|
19
|
-
)
|
20
|
-
_COMMON_UTIL_SCRIPT = read_file(os.path.join(_DIR, "partial", "common-util.js"))
|
21
14
|
|
22
15
|
|
23
16
|
def handle_task_ui(
|
@@ -31,12 +24,16 @@ def handle_task_ui(
|
|
31
24
|
# Assemble parent url
|
32
25
|
parent_url_parts = url_parts[:-2] + [""]
|
33
26
|
parent_url = "/".join(parent_url_parts)
|
34
|
-
# Assemble api url
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
# Assemble session api url
|
28
|
+
session_url_parts = list(url_parts)
|
29
|
+
session_url_parts[1] = "api/sessions"
|
30
|
+
session_api_url = "/".join(session_url_parts)
|
31
|
+
# Assemble input api url
|
32
|
+
input_url_parts = list(url_parts)
|
33
|
+
input_url_parts[1] = "api/inputs"
|
34
|
+
input_api_url = "/".join(input_url_parts)
|
38
35
|
# Assemble ui url
|
39
|
-
ui_url_parts = list(
|
36
|
+
ui_url_parts = list(url_parts)
|
40
37
|
ui_url_parts[1] = "ui"
|
41
38
|
ui_url = "/".join(ui_url_parts)
|
42
39
|
# Assemble task inputs
|
@@ -58,13 +55,17 @@ def handle_task_ui(
|
|
58
55
|
"url": url,
|
59
56
|
"parent_url": parent_url,
|
60
57
|
"task_inputs": "\n".join(input_html_list),
|
61
|
-
"api_url": api_url,
|
62
58
|
"ui_url": ui_url,
|
63
|
-
"
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
"json_cfg": json.dumps(
|
60
|
+
{
|
61
|
+
"CURRENT_URL": url,
|
62
|
+
"SESSION_API_URL": session_api_url,
|
63
|
+
"INPUT_API_URL": input_api_url,
|
64
|
+
"UI_URL": ui_url,
|
65
|
+
"SESSION_NAME": session_name,
|
66
|
+
"PAGE": 0,
|
67
|
+
}
|
68
|
+
),
|
68
69
|
},
|
69
70
|
)
|
70
71
|
)
|
@@ -19,16 +19,16 @@
|
|
19
19
|
<li><a href="/">🏠 Home</a></li>
|
20
20
|
<li><a href="{parent_url}">🔙 Parent</a></li>
|
21
21
|
<li><a href="{ui_url}">🆕 New Session</a></li>
|
22
|
-
<li><a href="#" onclick="
|
22
|
+
<li><a href="#" onclick="openPastSessionDialog(event)">📂 Existing Session</a></li>
|
23
23
|
</ul>
|
24
24
|
</nav>
|
25
25
|
</hgroup>
|
26
26
|
</header>
|
27
27
|
|
28
|
-
<dialog id="session-
|
28
|
+
<dialog id="past-session-dialog">
|
29
29
|
<article>
|
30
30
|
<header>
|
31
|
-
<button aria-label="Close" rel="prev" onclick="
|
31
|
+
<button aria-label="Close" rel="prev" onclick="closePastSessionDialog(event)"></button>
|
32
32
|
<p>
|
33
33
|
<strong>📂 Existing Session</strong>
|
34
34
|
</p>
|
@@ -40,11 +40,11 @@
|
|
40
40
|
<input type="datetime-local" id="max-start-at-input" placeholder="Maximum Start Time" aria-label="Maximum Start Time" />
|
41
41
|
</fieldset>
|
42
42
|
</form>
|
43
|
-
<ul id="session-
|
43
|
+
<ul id="past-session-ul" style="font-family:monospace;"></ul>
|
44
44
|
</main>
|
45
45
|
<footer>
|
46
46
|
<nav>
|
47
|
-
<ul id="session-
|
47
|
+
<ul id="past-session-pagination-ul"></ul>
|
48
48
|
</nav>
|
49
49
|
</footer>
|
50
50
|
</article>
|
@@ -55,7 +55,7 @@
|
|
55
55
|
<p>{description}</p>
|
56
56
|
<canvas id="history-canvas" height="0" width="1000" style="width: 100%;"></canvas>
|
57
57
|
<hr />
|
58
|
-
<form id="submit-task-form" onsubmit="
|
58
|
+
<form id="submit-task-form" onsubmit="submitNewSessionForm(event)">
|
59
59
|
{task_inputs}
|
60
60
|
<button>🚀 Run</button>
|
61
61
|
</form>
|
@@ -74,14 +74,11 @@
|
|
74
74
|
|
75
75
|
</body>
|
76
76
|
<script>
|
77
|
-
const
|
78
|
-
const API_URL = '{api_url}';
|
79
|
-
const UI_URL = `{ui_url}`;
|
80
|
-
let SESSION_NAME = '{session_name}';
|
81
|
-
let PAGE = 0;
|
82
|
-
{main_script}
|
83
|
-
{common_util_script}
|
84
|
-
{show_existing_session_script}
|
85
|
-
{visualize_history_script}
|
77
|
+
const cfg = {json_cfg};
|
86
78
|
</script>
|
79
|
+
<script src="/static/task-ui/common-util.js"></script>
|
80
|
+
<script src="/static/task-ui/past-session.js"></script>
|
81
|
+
<script src="/static/task-ui/current-session.js"></script>
|
82
|
+
<script src="/static/task-ui/event.js"></script>
|
83
|
+
|
87
84
|
</html>
|
zrb/task/base_trigger.py
CHANGED
zrb/task/llm_task.py
CHANGED
zrb/task/make_task.py
CHANGED
zrb/task/scaffolder.py
CHANGED
@@ -84,11 +84,13 @@ class Scaffolder(BaseTask):
|
|
84
84
|
|
85
85
|
def _get_content_transformers(self) -> list[AnyContentTransformer]:
|
86
86
|
if callable(self._content_transformers):
|
87
|
-
return [
|
87
|
+
return [
|
88
|
+
ContentTransformer(match=".*", transform=self._content_transformers)
|
89
|
+
]
|
88
90
|
if isinstance(self._content_transformers, dict):
|
89
91
|
return [
|
90
92
|
ContentTransformer(
|
91
|
-
match="
|
93
|
+
match=".*",
|
92
94
|
transform=self._content_transformers,
|
93
95
|
auto_render=self._render_content_transformers,
|
94
96
|
)
|
@@ -127,11 +129,11 @@ class Scaffolder(BaseTask):
|
|
127
129
|
dest_file = os.path.join(
|
128
130
|
dest_dir, self._transform_path(ctx, file_name)
|
129
131
|
)
|
132
|
+
ctx.log_info(f"Copying {src_file} to {dest_file}")
|
130
133
|
shutil.copy2(src_file, dest_file)
|
131
|
-
ctx.log_info(f"Copied {src_file} to {dest_file}")
|
132
134
|
else:
|
135
|
+
ctx.log_info(f"Copying {source_path} to {destination_path}")
|
133
136
|
shutil.copy2(source_path, destination_path)
|
134
|
-
ctx.log_info(f"Copied {source_path} to {destination_path}")
|
135
137
|
|
136
138
|
def _transform_path(self, ctx: AnyContext, file_path: str):
|
137
139
|
if callable(self._path_transformer):
|
zrb/task/scheduler.py
CHANGED
zrb/util/cmd/command.py
CHANGED
@@ -4,7 +4,7 @@ import libcst as cst
|
|
4
4
|
class ClassCodeAdder(cst.CSTTransformer):
|
5
5
|
def __init__(self, class_name: str, new_code: str):
|
6
6
|
self.class_name = class_name
|
7
|
-
self.new_code = cst.
|
7
|
+
self.new_code = cst.parse_module(new_code).body
|
8
8
|
self.class_found = False
|
9
9
|
|
10
10
|
def leave_ClassDef(
|
@@ -15,17 +15,17 @@ class ClassCodeAdder(cst.CSTTransformer):
|
|
15
15
|
self.class_found = True
|
16
16
|
# Add the method to the class body
|
17
17
|
new_body = updated_node.body.with_changes(
|
18
|
-
body=updated_node.body.body + (self.new_code
|
18
|
+
body=updated_node.body.body + tuple(self.new_code)
|
19
19
|
)
|
20
20
|
return updated_node.with_changes(body=new_body)
|
21
21
|
return updated_node
|
22
22
|
|
23
23
|
|
24
|
-
def append_code_to_class(original_code: str, class_name: str,
|
24
|
+
def append_code_to_class(original_code: str, class_name: str, new_code: str) -> str:
|
25
25
|
# Parse the original code into a module
|
26
26
|
module = cst.parse_module(original_code)
|
27
27
|
# Initialize transformer with the class name and method code
|
28
|
-
transformer = ClassCodeAdder(class_name,
|
28
|
+
transformer = ClassCodeAdder(class_name, new_code)
|
29
29
|
# Apply the transformation
|
30
30
|
modified_module = module.visit(transformer)
|
31
31
|
# Check if the class was found
|
@@ -5,7 +5,7 @@ class FunctionCodeAdder(cst.CSTTransformer):
|
|
5
5
|
def __init__(self, function_name: str, new_code: str):
|
6
6
|
self.function_name = function_name
|
7
7
|
# Use parse_module to handle multiple statements
|
8
|
-
self.new_code = cst.
|
8
|
+
self.new_code = cst.parse_module(new_code).body
|
9
9
|
self.function_found = False
|
10
10
|
|
11
11
|
def leave_FunctionDef(
|
@@ -16,7 +16,7 @@ class FunctionCodeAdder(cst.CSTTransformer):
|
|
16
16
|
self.function_found = True
|
17
17
|
# Add the method to the class body
|
18
18
|
new_body = updated_node.body.with_changes(
|
19
|
-
body=updated_node.body.body + (self.new_code
|
19
|
+
body=updated_node.body.body + tuple(self.new_code)
|
20
20
|
)
|
21
21
|
return updated_node.with_changes(body=new_body)
|
22
22
|
return updated_node
|
@@ -6,7 +6,7 @@ class MethodCodeAdder(cst.CSTTransformer):
|
|
6
6
|
self.class_name = class_name
|
7
7
|
self.method_name = method_name
|
8
8
|
# Use parse_module to handle multiple statements
|
9
|
-
self.new_code = cst.
|
9
|
+
self.new_code = cst.parse_module(new_code).body
|
10
10
|
self.class_found = False
|
11
11
|
self.method_found = False
|
12
12
|
|
@@ -27,7 +27,7 @@ class MethodCodeAdder(cst.CSTTransformer):
|
|
27
27
|
):
|
28
28
|
# Modify the target function by adding the new code
|
29
29
|
body_with_new_code = item.body.with_changes(
|
30
|
-
body=item.body.body + (self.new_code
|
30
|
+
body=item.body.body + tuple(self.new_code) # Add the new code
|
31
31
|
)
|
32
32
|
new_body.append(item.with_changes(body=body_with_new_code))
|
33
33
|
self.method_found = True
|
@@ -1,5 +1,5 @@
|
|
1
|
-
def prepend_code_to_module(
|
2
|
-
lines =
|
1
|
+
def prepend_code_to_module(original_code: str, new_code: str) -> str:
|
2
|
+
lines = original_code.splitlines()
|
3
3
|
last_import_index = -1
|
4
4
|
for i, line in enumerate(lines):
|
5
5
|
stripped_line = line.strip()
|
zrb/util/file.py
CHANGED