2024-09-19 01:40:27 +02:00
|
|
|
|
2024-09-12 00:02:12 +02:00
|
|
|
/**
|
|
|
|
*/
|
2024-09-19 01:40:27 +02:00
|
|
|
namespace _zeitbild.frontend_web
|
2024-09-12 00:02:12 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
export async function main(
|
|
|
|
) : Promise<void>
|
|
|
|
{
|
|
|
|
// conf
|
2024-09-19 10:17:43 +02:00
|
|
|
await _zeitbild.frontend_web.conf.init("conf.json");
|
2024-09-12 00:02:12 +02:00
|
|
|
|
2024-09-19 10:17:43 +02:00
|
|
|
// init
|
|
|
|
await _zeitbild.frontend_web.backend.init();
|
|
|
|
lib_plankton.zoo_page.init(
|
|
|
|
document.querySelector("main"),
|
|
|
|
{
|
|
|
|
"pool": {
|
|
|
|
"login": async (parameters, target_element) => {
|
|
|
|
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
|
|
|
|
"login",
|
|
|
|
{
|
|
|
|
"form": "",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
const form : lib_plankton.zoo_form.class_form<
|
|
|
|
{name : string; password : string;},
|
|
|
|
{name : string; password : string;}
|
|
|
|
> = new lib_plankton.zoo_form.class_form<
|
|
|
|
{name : string; password : string;},
|
|
|
|
{name : string; password : string;}
|
|
|
|
>(
|
|
|
|
x => x,
|
|
|
|
x => x,
|
|
|
|
new lib_plankton.zoo_input.class_input_group<
|
|
|
|
{name : string; password : string;}
|
|
|
|
>(
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "name",
|
|
|
|
"input": new lib_plankton.zoo_input.class_input_text(),
|
|
|
|
"label": "Name", // TODO: translate
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "password",
|
|
|
|
"input": new lib_plankton.zoo_input.class_input_password(),
|
|
|
|
"label": "Kennwort", // TODO: translate
|
|
|
|
},
|
|
|
|
]
|
|
|
|
),
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"label": "Anmelden", // TODO: translate
|
|
|
|
"target": "submit",
|
|
|
|
"procedure": async (get_value, get_representation) => {
|
|
|
|
const value : any = await get_value();
|
|
|
|
try {
|
|
|
|
await _zeitbild.frontend_web.backend.session_begin(
|
|
|
|
value.name,
|
|
|
|
value.password
|
|
|
|
);
|
|
|
|
lib_plankton.zoo_page.set(
|
|
|
|
{
|
|
|
|
"name": "events",
|
|
|
|
"parameters": {}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
lib_plankton.zoo_page.set(
|
|
|
|
{
|
|
|
|
"name": "login",
|
|
|
|
"parameters": {
|
|
|
|
"name": value.name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
);
|
|
|
|
await form.setup(document.querySelector("#login"));
|
|
|
|
await form.input_write(
|
|
|
|
{
|
|
|
|
"name": (parameters.name ?? ""),
|
|
|
|
"password": "",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
"logout": async (parameters, target_element) => {
|
|
|
|
await _zeitbild.frontend_web.backend.session_end(
|
|
|
|
);
|
|
|
|
lib_plankton.zoo_page.set(
|
|
|
|
{
|
|
|
|
"name": "login",
|
|
|
|
"parameters": {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
"events": async (parameters, target_element) => {
|
|
|
|
const content = await _zeitbild.frontend_web.view.calendar_view_table_html(
|
|
|
|
{
|
|
|
|
"calendar_ids": null,
|
|
|
|
"from": {
|
|
|
|
"year": 2024,
|
|
|
|
"week": 37
|
|
|
|
},
|
|
|
|
"to": {
|
|
|
|
"year": 2024,
|
|
|
|
"week": 43
|
|
|
|
},
|
|
|
|
"timezone_shift": /*conf.timezone_shift*/0,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
target_element.innerHTML = content;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"fallback": {
|
|
|
|
"name": "login",
|
|
|
|
"parameters": {}
|
|
|
|
}
|
|
|
|
}
|
2024-09-12 00:02:12 +02:00
|
|
|
);
|
2024-09-19 10:17:43 +02:00
|
|
|
lib_plankton.zoo_page.add_nav_entry({"name": "login", "parameters": {}});
|
|
|
|
lib_plankton.zoo_page.add_nav_entry({"name": "events", "parameters": {}});
|
|
|
|
lib_plankton.zoo_page.add_nav_entry({"name": "logout", "parameters": {}});
|
2024-09-12 00:02:12 +02:00
|
|
|
|
|
|
|
// exec
|
2024-09-19 10:17:43 +02:00
|
|
|
lib_plankton.zoo_page.start();
|
2024-09-12 00:02:12 +02:00
|
|
|
|
|
|
|
return Promise.resolve<void>(undefined);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|