This commit is contained in:
Fenris Wolf 2024-09-19 01:40:27 +02:00
parent c7b299b406
commit 03f29fae11
13 changed files with 2805 additions and 6181 deletions

View file

@ -1,4 +1,3 @@
{
"view_mode": "table",
"timezone_shift": 0
"version": 1
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
document.addEventListener(
"DOMContentLoaded",
() => {
_zeitbild.frontend.main()
_zeitbild.frontend_web.main()
.then(
() => {}
)

View file

@ -1,106 +1,122 @@
/**
*/
namespace _zeitbild.frontend.resources.backend
namespace _zeitbild.frontend_web.backend
{
/**
*/
var _data : _zeitbild.frontend.type_datamodel;
var _session_key : (null | string) = null;
/**
*/
export async function init(
async function call(
method : lib_plankton.http.enum_method,
action : string,
input : (null | any)
) : Promise<any>
{
const with_body : boolean = (
[
lib_plankton.http.enum_method.post,
lib_plankton.http.enum_method.put,
lib_plankton.http.enum_method.patch,
].includes(method)
);
const http_request : lib_plankton.http.type_request = {
"version": "HTTP/2",
"scheme": (
(_zeitbild.frontend_web.conf.get()["backend"]["scheme"] === "http")
?
"http"
:
"https"
),
"host": lib_plankton.string.coin(
"{{host}}:{{port}}",
{
"host": _zeitbild.frontend_web.conf.get()["backend"]["host"],
"port": _zeitbild.frontend_web.conf.get()["backend"]["port"].toFixed(0),
}
),
"path": lib_plankton.string.coin(
"{{base}}{{action}}",
{
"base": _zeitbild.frontend_web.conf.get()["backend"]["path"],
"action": action,
}
),
"method": method,
"query": (
(with_body || (input === null))
?
null
:
("?" + lib_plankton.www_form.encode(input))
),
"headers": Object.assign(
{},
(
(! with_body)
?
{}
:
{"Content-Type": "application/json"}
),
(
(_session_key === null)
?
{}
:
{"X-Session-Key": _session_key}
)
),
"body": (
((! with_body) || (input === null))
?
null
:
/*Buffer.from*/(lib_plankton.json.encode(input))
),
};
const http_response : lib_plankton.http.type_response = await lib_plankton.http.call(http_request);
const output : any = lib_plankton.json.decode(http_response.body.toString());
return Promise.resolve<any>(output);
}
/**
*/
export async function session_begin(
name : string,
password : string
) : Promise<void>
{
const path : string = "data.json";
if (_data === undefined) {
_data = lib_plankton.call.convey(
await lib_plankton.file.read(path),
[
lib_plankton.json.decode,
(data_raw : any) => (
({
"users": data_raw["users"],
"calendars": (
data_raw["calendars"]
.map(
(calendar_entry_raw : any) => ({
"id": calendar_entry_raw["id"],
"object": (
((calendar_object_raw) => {
switch (calendar_object_raw["kind"]) {
default: {
return calendar_object_raw;
break;
}
case "concrete": {
return {
"kind": "concrete",
"data": {
"name": calendar_object_raw["data"]["name"],
"private": (
calendar_object_raw["data"]["private"]
??
false
),
"users": calendar_object_raw["data"]["users"],
"events": (
calendar_object_raw["data"]["events"]
.map(
(event_raw : any) => ({
"name": event_raw["name"],
"begin": event_raw["begin"],
"end": (
(
(
event_raw["end"]
??
null
)
===
null
)
?
null
:
event_raw["end"]
),
"location": (
event_raw["location"]
??
null
),
"description": (
event_raw["description"]
??
null
),
})
)
),
},
};
break;
}
}
}) (calendar_entry_raw["object"])
),
})
)
),
}) as type_datamodel
),
]
);
}
else {
// do nothing
}
_session_key = await call(
lib_plankton.http.enum_method.post,
"/session/begin",
{
"name": name,
"password": password,
}
);
return Promise.resolve<void>(undefined);
}
/**
*/
export async function session_end(
) : Promise<void>
{
return call(
lib_plankton.http.enum_method.delete,
"/session/end",
null
);
}
/**
*/
export async function calendar_list(
@ -115,65 +131,23 @@ namespace _zeitbild.frontend.resources.backend
>
>
{
await init();
return Promise.resolve(
_data.calendars
.map(
(calendar_entry) => {
switch (calendar_entry.object.kind) {
case "concrete": {
return {
"key": calendar_entry.id,
"preview": {
"name": calendar_entry.object.data.name,
}
};
break;
}
case "caldav": {
return {
"key": calendar_entry.id,
"preview": {
"name": "(imported)",
}
};
}
}
}
)
return call(
lib_plankton.http.enum_method.get,
"/calendars",
null
);
}
/**
*/
export async function calendar_read(
calendar_id : type_calendar_id
) : Promise<type_calendar_object>
{
await init();
const hits = (
_data.calendars
.filter(
(calendar_entry) => (calendar_entry.id === calendar_id)
)
);
if (hits.length <= 0) {
return Promise.reject<type_calendar_object>(new Error("not found"));
}
else {
return Promise.resolve<type_calendar_object>(hits[0].object);
}
}
/**
* @todo prevent loops
*/
export async function calendar_gather_events(
calendar_ids : Array<type_calendar_id>,
from_pit : _zeitbild.frontend.helpers.type_pit,
to_pit : _zeitbild.frontend.helpers.type_pit
export async function events(
from_pit : _zeitbild.frontend_web.helpers.type_pit,
to_pit : _zeitbild.frontend_web.helpers.type_pit,
options : {
calendar_ids ?: (null | Array<type_calendar_id>);
} = {}
) : Promise<
Array<
{
@ -184,150 +158,30 @@ namespace _zeitbild.frontend.resources.backend
>
>
{
lib_plankton.log.info(
"calendar_gather_events",
options = Object.assign(
{
"calendar_ids": calendar_ids,
}
"calendar_ids": null,
},
options
);
return call(
lib_plankton.http.enum_method.get,
"/events",
Object.assign(
{
"from": from_pit,
"to": to_pit,
},
(
(options.calendar_ids === null)
?
{}
:
{"calendar_ids": options.calendar_ids.join(",")}
)
)
);
await init();
let result : Array<
{
calendar_id : type_calendar_id;
calendar_name : string;
event : type_event;
}
> = [];
for await (const calendar_id of calendar_ids) {
const calendar_object : type_calendar_object = await calendar_read(
calendar_id
);
if (calendar_object.data.private) {
lib_plankton.log.info(
"calendar_gather_events_private_calendar_blocked",
{
"calendar_id": calendar_id,
}
);
}
else {
switch (calendar_object.kind) {
case "concrete": {
result = (
result
.concat(
calendar_object.data.events
.filter(
(event) => _zeitbild.frontend.helpers.pit_is_between(
_zeitbild.frontend.helpers.pit_from_datetime(event.begin),
from_pit,
to_pit
)
)
.map(
(event) => ({
"calendar_id": calendar_id,
"calendar_name": calendar_object.data.name,
"event": event
})
)
)
);
break;
}
case "caldav": {
const url : lib_plankton.url.type_url = lib_plankton.url.decode(
calendar_object.data.source_url
);
const http_request : lib_plankton.http.type_request = {
"version": "HTTP/2",
"scheme": ((url.scheme === "https") ? "https" : "http"),
"host": url.host,
"path": (url.path ?? "/"),
"query": url.query,
"method": lib_plankton.http.enum_method.get,
"headers": {},
"body": null,
};
// TODO: cache?
const http_response : lib_plankton.http.type_response = await lib_plankton.http.call(
http_request,
{
}
);
const vcalendar : lib_plankton.ical.type_vcalendar = lib_plankton.ical.ics_decode(
http_response.body.toString(),
{
}
);
result = (
result
.concat(
vcalendar.vevents
.map(
(vevent : lib_plankton.ical.type_vevent) => (
(vevent.dtstart !== undefined)
?
{
"name": (
(vevent.summary !== undefined)
?
vevent.summary
:
"???"
),
"begin": _zeitbild.frontend.helpers.ical_dt_to_own_datetime(vevent.dtstart),
"end": (
(vevent.dtend !== undefined)
?
_zeitbild.frontend.helpers.ical_dt_to_own_datetime(vevent.dtend)
:
null
),
"location": (
(vevent.location !== undefined)
?
vevent.location
:
null
),
"description": (
(vevent.description !== undefined)
?
vevent.description
:
null
),
}
:
null
)
)
.filter(
(event) => (event !== null)
)
.filter(
(event) => _zeitbild.frontend.helpers.pit_is_between(
_zeitbild.frontend.helpers.pit_from_datetime(event.begin),
from_pit,
to_pit
)
)
.map(
(event) => ({
"calendar_id": calendar_id,
"calendar_name": calendar_object.data.name,
"event": event,
})
)
)
);
break;
}
}
}
}
return Promise.resolve(result);
}
}

95
source/logic/conf.ts Normal file
View file

@ -0,0 +1,95 @@
namespace _zeitbild.frontend_web.conf
{
/**
*/
const _schema : lib_plankton.conf.type_schema = {
"nullable": false,
"type": "object",
"properties": {
"version": {
"nullable": false,
"type": "integer",
"enum": [1]
},
"backend": {
"nullable": false,
"type": "object",
"properties": {
"scheme": {
"nullable": false,
"type": "string",
"default": "http"
},
"host": {
"nullable": false,
"type": "string",
"default": "localhost"
},
"port": {
"nullable": false,
"type": "integer",
"default": 7845
},
"path": {
"nullable": false,
"type": "string",
"default": ""
}
},
"required": [
],
"additionalProperties": false,
"default": {}
}
},
"required": [
"version",
],
"additionalProperties": false
};
/**
*/
var _data : (null | any) = null;
/**
*/
export function schema(
) : lib_plankton.conf.type_schema
{
return _schema;
}
/**
*/
export function get(
) : any
{
if (_data === null) {
throw (new Error("conf not loaded yet"));
}
else {
return _data;
}
}
/**
*/
export async function init(
path : string
) : Promise<void>
{
_data = await lib_plankton.conf.load(
_schema,
path
);
return Promise.resolve<void>(undefined);
}
}

View file

@ -1,7 +1,7 @@
/**
*/
namespace _zeitbild.frontend.helpers
namespace _zeitbild.frontend_web.helpers
{
/**
@ -532,59 +532,5 @@ namespace _zeitbild.frontend.helpers
]
);
}
/**
* @todo timezone
*/
function ical_datetime_to_own_datetime(
ical_datetime : lib_plankton.ical.type_datetime
) : type_datetime
{
return {
"timezone_shift": 0,
"date": {
"year": ical_datetime.date.year,
"month": ical_datetime.date.month,
"day": ical_datetime.date.day,
},
"time": (
(ical_datetime.time === null)
?
null
:
{
"hour": ical_datetime.time.hour,
"minute": ical_datetime.time.minute,
"second": ical_datetime.time.second,
}
)
};
}
/**
* @todo timezone
*/
export function ical_dt_to_own_datetime(
ical_dt: lib_plankton.ical.type_dt
) : type_datetime
{
return {
"timezone_shift": 0,
"date": ical_dt.value.date,
"time": (
(ical_dt.value.time === null)
?
null
:
{
"hour": ical_dt.value.time.hour,
"minute": ical_dt.value.time.minute,
"second": ical_dt.value.time.second,
}
)
};
}
}

View file

@ -1,6 +1,7 @@
/**
*/
namespace _zeitbild.frontend
namespace _zeitbild.frontend_web
{
/**
@ -15,30 +16,28 @@ namespace _zeitbild.frontend
/**
*/
async function render(
conf : type_conf,
calendar_ids : Array<type_calendar_id>
) : Promise<void>
{
calendar_ids.sort();
const target : HTMLElement = (document.querySelector("body") as HTMLBodyElement);
switch (conf.view_mode) {
const view_type : string = "table";
switch (view_type) {
default: {
throw (new Error("invalid view mode"));
break;
}
case "table": {
const content : string = await _zeitbild.frontend.view.calendar_view_table_html(
calendar_ids,
const content : string = await _zeitbild.frontend_web.view.calendar_view_table_html(
{
"calendar_ids": null,
"from": {
"year": 2024,
"week": 35
"week": 37
},
"to": {
"year": 2024,
"week": 43
},
"timezone_shift": conf.timezone_shift,
"timezone_shift": /*conf.timezone_shift*/0,
}
);
target.innerHTML = content;
@ -74,10 +73,10 @@ namespace _zeitbild.frontend
break;
}
case "list": {
const content : string = await _zeitbild.frontend.view.calendar_view_list_html(
calendar_ids,
const content : string = await _zeitbild.frontend_web.view.calendar_view_list_html(
null,
{
"timezone_shift": conf.timezone_shift,
"timezone_shift": /*conf.timezone_shift*/0,
}
);
target.innerHTML = content;
@ -101,10 +100,16 @@ namespace _zeitbild.frontend
);
// conf
const conf : type_conf = lib_plankton.json.decode(await lib_plankton.file.read("conf.json"));
await _zeitbild.frontend_web.conf.init(("conf.json"));
// setup
await _zeitbild.frontend_web.backend.session_begin(
"alice",
"alice"
);
// args
/*
const url : URL = new URL(window.location.toString());
const calendar_ids : Array<type_calendar_id> = (
(url.searchParams.get("ids") !== null)
@ -117,14 +122,12 @@ namespace _zeitbild.frontend
]
)
:
(await _zeitbild.frontend.resources.backend.calendar_list()).map(x => x.key)
(await _zeitbild.frontend_web.backend.calendar_list()).map(x => x.key)
);
*/
// exec
await render(
conf,
calendar_ids
);
await render();
return Promise.resolve<void>(undefined);
}

View file

@ -1,7 +1,7 @@
/**
*/
namespace _zeitbild.frontend
namespace _zeitbild.frontend_web
{
/**
@ -29,11 +29,11 @@ namespace _zeitbild.frontend
*/
export type type_event = {
name : string;
begin : _zeitbild.frontend.helpers.type_datetime;
begin : _zeitbild.frontend_web.helpers.type_datetime;
end : (
null
|
_zeitbild.frontend.helpers.type_datetime
_zeitbild.frontend_web.helpers.type_datetime
);
location : (
null

View file

@ -1,7 +1,7 @@
/**
*/
namespace _zeitbild.frontend.view
namespace _zeitbild.frontend_web.view
{
/**
@ -134,21 +134,23 @@ namespace _zeitbild.frontend.view
* @todo kein "while"
*/
async function calendar_view_table_data(
calendar_ids : Array<type_calendar_id>,
options : {
from ?: {
year : int;
week : int;
},
to ?: {
year : int;
week : int;
},
timezone_shift ?: int;
} = {}
calendar_ids : (
null
|
Array<type_calendar_id>
),
from : {
year : int;
week : int;
},
to : {
year : int;
week : int;
},
timezone_shift : int,
) : Promise<
{
sources : lib_plankton.structures.type_hashmap<
sources : lib_plankton.map.type_map<
type_calendar_id,
{
name : string;
@ -159,7 +161,7 @@ namespace _zeitbild.frontend.view
week : int;
data : Array<
{
pit : _zeitbild.frontend.helpers.type_pit;
pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array<
{
calendar_id : type_calendar_id;
@ -174,53 +176,25 @@ namespace _zeitbild.frontend.view
}
>
{
const now_pit : _zeitbild.frontend.helpers.type_pit = _zeitbild.frontend.helpers.pit_now();
options = Object.assign(
{
"from": lib_plankton.call.convey(
now_pit,
[
(x : _zeitbild.frontend.helpers.type_pit) => _zeitbild.frontend.helpers.pit_shift_week(x, -1),
_zeitbild.frontend.helpers.pit_to_date_object,
(x : Date) => ({
"year": x.getFullYear(),
"week": _zeitbild.frontend.helpers.date_object_get_week_of_year(x),
})
]
),
"to": lib_plankton.call.convey(
now_pit,
[
(x : _zeitbild.frontend.helpers.type_pit) => _zeitbild.frontend.helpers.pit_shift_week(x, +4),
_zeitbild.frontend.helpers.pit_to_date_object,
(x : Date) => ({
"year": x.getFullYear(),
"week": _zeitbild.frontend.helpers.date_object_get_week_of_year(x),
})
]
),
"timezone_shift": 0,
},
options
);
const now_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_now();
/*
const calendar_object : type_calendar_object = calendar_read(
data,
calendar_id
);
*/
const from_pit : _zeitbild.frontend.helpers.type_pit = _zeitbild.frontend.helpers.pit_from_year_and_week(
(options.from as {year : int; week : int}).year,
(options.from as {year : int; week : int}).week,
const from_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_from_year_and_week(
(from as {year : int; week : int}).year,
(from as {year : int; week : int}).week,
{
"timezone_shift": (options.timezone_shift as int),
"timezone_shift": (timezone_shift as int),
}
);
const to_pit : _zeitbild.frontend.helpers.type_pit = _zeitbild.frontend.helpers.pit_from_year_and_week(
(options.to as {year : int; week : int}).year,
(options.to as {year : int; week : int}).week,
const to_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_from_year_and_week(
(to as {year : int; week : int}).year,
(to as {year : int; week : int}).week,
{
"timezone_shift": (options.timezone_shift as int),
"timezone_shift": (timezone_shift as int),
}
);
@ -231,13 +205,15 @@ namespace _zeitbild.frontend.view
calendar_name : string;
event : type_event;
}
> = await _zeitbild.frontend.resources.backend.calendar_gather_events(
calendar_ids,
> = await _zeitbild.frontend_web.backend.events(
from_pit,
to_pit
to_pit,
{
"calendar_ids": calendar_ids,
}
);
let result : {
sources : lib_plankton.structures.type_hashmap<
sources : lib_plankton.map.type_map<
type_calendar_id,
{
name : string;
@ -248,7 +224,7 @@ namespace _zeitbild.frontend.view
week : int;
data : Array<
{
pit : _zeitbild.frontend.helpers.type_pit;
pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array<
{
calendar_id : type_calendar_id;
@ -261,27 +237,31 @@ namespace _zeitbild.frontend.view
}
>;
} = {
"sources": lib_plankton.structures.hashmap_construct(
x => x.toFixed(0),
(
entries
.map(
(entry) => (
{
"key": entry.calendar_id,
"value": {
"name": entry.calendar_name,
}
}
"sources": lib_plankton.map.hashmap.implementation_map(
lib_plankton.map.hashmap.make(
x => x.toFixed(0),
{
"pairs": (
entries
.map(
(entry) => (
{
"key": entry.calendar_id,
"value": {
"name": entry.calendar_name,
}
}
)
)
)
)
}
)
),
"rows": [],
};
let row : Array<
{
pit : _zeitbild.frontend.helpers.type_pit;
pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array<
{
calendar_id : type_calendar_id;
@ -293,12 +273,12 @@ namespace _zeitbild.frontend.view
> = [];
let day : int = 0;
while (true) {
const pit_current : _zeitbild.frontend.helpers.type_pit = _zeitbild.frontend.helpers.pit_shift_day(
const pit_current : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_shift_day(
from_pit,
day
);
if (
_zeitbild.frontend.helpers.pit_is_before(
_zeitbild.frontend_web.helpers.pit_is_before(
pit_current,
to_pit
)
@ -315,7 +295,7 @@ namespace _zeitbild.frontend.view
result.rows.push(
{
"week": (
(options.from as {year : int; week : int}).week
(from as {year : int; week : int}).week
+
Math.floor(day / 7)
-
@ -343,7 +323,7 @@ namespace _zeitbild.frontend.view
.forEach(
(entry) => {
const distance_seconds : int = (
_zeitbild.frontend.helpers.pit_from_datetime(entry.event.begin)
_zeitbild.frontend_web.helpers.pit_from_datetime(entry.event.begin)
-
from_pit
);
@ -389,8 +369,12 @@ namespace _zeitbild.frontend.view
/**
*/
export async function calendar_view_table_html(
calendar_ids : Array<type_calendar_id>,
options : {
calendar_ids ?: (
null
|
Array<type_calendar_id>
);
from ?: {
year : int;
week : int;
@ -403,8 +387,38 @@ namespace _zeitbild.frontend.view
} = {}
) : Promise<string>
{
const now_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_now();
options = Object.assign(
{
"calendar_ids": null,
"from": lib_plankton.call.convey(
now_pit,
[
(x : _zeitbild.frontend_web.helpers.type_pit) => _zeitbild.frontend_web.helpers.pit_shift_week(x, -1),
_zeitbild.frontend_web.helpers.pit_to_date_object,
(x : Date) => ({
"year": x.getFullYear(),
"week": _zeitbild.frontend_web.helpers.date_object_get_week_of_year(x),
})
]
),
"to": lib_plankton.call.convey(
now_pit,
[
(x : _zeitbild.frontend_web.helpers.type_pit) => _zeitbild.frontend_web.helpers.pit_shift_week(x, +4),
_zeitbild.frontend_web.helpers.pit_to_date_object,
(x : Date) => ({
"year": x.getFullYear(),
"week": _zeitbild.frontend_web.helpers.date_object_get_week_of_year(x),
})
]
),
"timezone_shift": 0,
},
options
);
const stuff : {
sources : lib_plankton.structures.type_hashmap<
sources : lib_plankton.map.type_map<
type_calendar_id,
{
name : string;
@ -415,7 +429,7 @@ namespace _zeitbild.frontend.view
week : int;
data : Array<
{
pit : _zeitbild.frontend.helpers.type_pit;
pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array<
{
calendar_id : type_calendar_id;
@ -428,44 +442,52 @@ namespace _zeitbild.frontend.view
}
>;
} = await calendar_view_table_data(
calendar_ids,
options
options.calendar_ids,
options.from,
options.to,
options.timezone_shift
);
const sources : lib_plankton.structures.type_hashmap<
const sources : lib_plankton.map.type_map<
type_calendar_id,
{
name : string;
color : lib_plankton.color.type_color;
}
> = lib_plankton.structures.hashmap_construct(
(x => x.toFixed(0)),
lib_plankton.structures.hashmap_dump(
stuff.sources
)
.map(
(pair) => ({
"key": pair.key,
"value": {
"name": pair.value.name,
"color": lib_plankton.color.give_generic(
(pair.key - 1),
{
"saturation": 0.375,
"value": 0.375,
}
),
}
})
> = lib_plankton.map.hashmap.implementation_map(
lib_plankton.map.hashmap.make(
(x => x.toFixed(0)),
{
"pairs": (
lib_plankton.map.dump(
stuff.sources
)
.map(
(pair) => ({
"key": pair.key,
"value": {
"name": pair.value.name,
"color": lib_plankton.color.give_generic(
(pair.key - 1),
{
"saturation": 0.375,
"value": 0.375,
}
),
}
})
)
)
}
)
);
return _zeitbild.frontend.helpers.template_coin(
return _zeitbild.frontend_web.helpers.template_coin(
"tableview",
{
"sources": (
await _zeitbild.frontend.helpers.promise_row<string>(
lib_plankton.structures.hashmap_dump(sources)
await _zeitbild.frontend_web.helpers.promise_row<string>(
lib_plankton.map.dump(sources)
.map(
({"key": calendar_id, "value": data}) => async () => _zeitbild.frontend.helpers.template_coin(
({"key": calendar_id, "value": data}) => async () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-sources-entry",
{
"name": data.name,
@ -477,18 +499,18 @@ namespace _zeitbild.frontend.view
)
).join(""),
"rows": (
await _zeitbild.frontend.helpers.promise_row<string>(
await _zeitbild.frontend_web.helpers.promise_row<string>(
stuff.rows
.map(
(row) => async () => _zeitbild.frontend.helpers.template_coin(
(row) => async () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-row",
{
"week": row.week.toFixed(0).padStart(2, "0"),
"cells": (
await _zeitbild.frontend.helpers.promise_row<string>(
await _zeitbild.frontend_web.helpers.promise_row<string>(
row.data
.map(
(cell) => async () => _zeitbild.frontend.helpers.template_coin(
(cell) => async () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-cell",
{
"extra_classes": (
@ -499,8 +521,8 @@ namespace _zeitbild.frontend.view
"title": lib_plankton.call.convey(
cell.pit,
[
_zeitbild.frontend.helpers.pit_to_datetime,
(x : _zeitbild.frontend.helpers.type_datetime) => lib_plankton.string.coin(
_zeitbild.frontend_web.helpers.pit_to_datetime,
(x : _zeitbild.frontend_web.helpers.type_datetime) => lib_plankton.string.coin(
"{{year}}-{{month}}-{{day}}",
{
"year": x.date.year.toFixed(0).padStart(4, "0"),
@ -513,8 +535,8 @@ namespace _zeitbild.frontend.view
"day": lib_plankton.call.convey(
cell.pit,
[
_zeitbild.frontend.helpers.pit_to_datetime,
(x : _zeitbild.frontend.helpers.type_datetime) => lib_plankton.string.coin(
_zeitbild.frontend_web.helpers.pit_to_datetime,
(x : _zeitbild.frontend_web.helpers.type_datetime) => lib_plankton.string.coin(
"{{day}}",
{
"year": x.date.year.toFixed(0).padStart(4, "0"),
@ -525,21 +547,19 @@ namespace _zeitbild.frontend.view
]
),
"entries": (
await _zeitbild.frontend.helpers.promise_row<string>(
await _zeitbild.frontend_web.helpers.promise_row<string>(
cell.entries
.map(
(entry) => () => _zeitbild.frontend.helpers.template_coin(
(entry) => () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-cell-entry",
{
"color": lib_plankton.color.output_hex(
lib_plankton.structures.hashmap_get(
sources,
sources.get(
entry.calendar_id
).color
),
"title": event_generate_tooltip(
lib_plankton.structures.hashmap_get(
sources,
sources.get(
entry.calendar_id
).name,
entry.event
@ -570,8 +590,8 @@ namespace _zeitbild.frontend.view
async function calendar_view_list_data(
calendar_ids : Array<type_calendar_id>,
options : {
from ?: _zeitbild.frontend.helpers.type_pit;
to ?: _zeitbild.frontend.helpers.type_pit;
from ?: _zeitbild.frontend_web.helpers.type_pit;
to ?: _zeitbild.frontend_web.helpers.type_pit;
timezone_shift ?: int;
} = {}
) : Promise<
@ -583,19 +603,19 @@ namespace _zeitbild.frontend.view
>
>
{
const now_pit : _zeitbild.frontend.helpers.type_pit = _zeitbild.frontend.helpers.pit_now();
const now_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_now();
options = Object.assign(
{
"from": lib_plankton.call.convey(
now_pit,
[
(x : _zeitbild.frontend.helpers.type_pit) => _zeitbild.frontend.helpers.pit_shift_day(x, -1),
(x : _zeitbild.frontend_web.helpers.type_pit) => _zeitbild.frontend_web.helpers.pit_shift_day(x, -1),
]
),
"to": lib_plankton.call.convey(
now_pit,
[
(x : _zeitbild.frontend.helpers.type_pit) => _zeitbild.frontend.helpers.pit_shift_week(x, +4),
(x : _zeitbild.frontend_web.helpers.type_pit) => _zeitbild.frontend_web.helpers.pit_shift_week(x, +4),
]
),
"timezone_shift": 0,
@ -608,17 +628,19 @@ namespace _zeitbild.frontend.view
calendar_id : type_calendar_id;
event : type_event;
}
> = await _zeitbild.frontend.resources.backend.calendar_gather_events(
calendar_ids,
(options.from as _zeitbild.frontend.helpers.type_pit),
(options.to as _zeitbild.frontend.helpers.type_pit)
> = await _zeitbild.frontend_web.backend.events(
(options.from as _zeitbild.frontend_web.helpers.type_pit),
(options.to as _zeitbild.frontend_web.helpers.type_pit),
{
"calendar_ids": calendar_ids,
}
);
// TODO: optimize
entries.sort(
(entry_1, entry_2) => (
_zeitbild.frontend.helpers.pit_from_datetime(entry_1.event.begin)
_zeitbild.frontend_web.helpers.pit_from_datetime(entry_1.event.begin)
-
_zeitbild.frontend.helpers.pit_from_datetime(entry_2.event.begin)
_zeitbild.frontend_web.helpers.pit_from_datetime(entry_2.event.begin)
)
);
@ -631,8 +653,8 @@ namespace _zeitbild.frontend.view
export async function calendar_view_list_html(
calendar_ids : Array<type_calendar_id>,
options : {
from ?: _zeitbild.frontend.helpers.type_pit;
to ?: _zeitbild.frontend.helpers.type_pit;
from ?: _zeitbild.frontend_web.helpers.type_pit;
to ?: _zeitbild.frontend_web.helpers.type_pit;
timezone_shift ?: int;
} = {}
) : Promise<string>

View file

@ -24,14 +24,6 @@ def main():
metavar = "<conf-path>",
help = "conf path",
)
argument_parser.add_argument(
"-d",
"--data-path",
type = str,
default = None,
metavar = "<data-path>",
help = "data path",
)
args = argument_parser.parse_args()
## exec
@ -55,17 +47,6 @@ def main():
args.output_directory,
)
)
if True:
if (args.data_path is None):
pass
else:
_os.system(
"cp %s %s/data.json"
% (
args.data_path,
args.output_directory,
)
)
_sys.stdout.write("%s\n" % args.output_directory)

View file

@ -48,13 +48,14 @@ logic: ${dir_build}/logic.js
${dir_temp}/logic-unlinked.js: \
${dir_lib}/plankton/plankton.d.ts \
${dir_source}/logic/helpers.ts \
${dir_source}/logic/conf.ts \
${dir_source}/logic/types.ts \
${dir_source}/logic/backend.ts \
${dir_source}/logic/view.ts \
${dir_source}/logic/main.ts
@ ${cmd_log} "logic | compile …"
@ ${cmd_mkdir} $(dir $@)
@ ${cmd_tsc} --lib dom,es2020 --strict $^ --outFile $@
@ ${cmd_tsc} --lib dom,es2020 $^ --outFile $@ # --strict
${dir_build}/logic.js: \
${dir_lib}/plankton/plankton.js \

View file

@ -8,16 +8,18 @@ modules=""
modules="${modules} base"
modules="${modules} call"
modules="${modules} file"
modules="${modules} structures"
modules="${modules} json"
modules="${modules} args"
modules="${modules} string"
modules="${modules} color"
modules="${modules} xml"
modules="${modules} ical"
modules="${modules} map"
# modules="${modules} ical"
modules="${modules} http"
modules="${modules} log"
modules="${modules} url"
modules="${modules} conf"
modules="${modules} www_form"
## exec