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", "version": 1
"timezone_shift": 0
} }

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( document.addEventListener(
"DOMContentLoaded", "DOMContentLoaded",
() => { () => {
_zeitbild.frontend.main() _zeitbild.frontend_web.main()
.then( .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(
) : Promise<void> method : lib_plankton.http.enum_method,
action : string,
input : (null | any)
) : Promise<any>
{ {
const path : string = "data.json"; const with_body : boolean = (
if (_data === undefined) {
_data = lib_plankton.call.convey(
await lib_plankton.file.read(path),
[ [
lib_plankton.json.decode, lib_plankton.http.enum_method.post,
(data_raw : any) => ( lib_plankton.http.enum_method.put,
({ lib_plankton.http.enum_method.patch,
"users": data_raw["users"], ].includes(method)
"calendars": ( );
data_raw["calendars"] const http_request : lib_plankton.http.type_request = {
.map( "version": "HTTP/2",
(calendar_entry_raw : any) => ({ "scheme": (
"id": calendar_entry_raw["id"], (_zeitbild.frontend_web.conf.get()["backend"]["scheme"] === "http")
"object": ( ?
((calendar_object_raw) => { "http"
switch (calendar_object_raw["kind"]) { :
default: { "https"
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"], "host": lib_plankton.string.coin(
"events": ( "{{host}}:{{port}}",
calendar_object_raw["data"]["events"] {
.map( "host": _zeitbild.frontend_web.conf.get()["backend"]["host"],
(event_raw : any) => ({ "port": _zeitbild.frontend_web.conf.get()["backend"]["port"].toFixed(0),
"name": event_raw["name"], }
"begin": event_raw["begin"], ),
"end": ( "path": lib_plankton.string.coin(
( "{{base}}{{action}}",
( {
event_raw["end"] "base": _zeitbild.frontend_web.conf.get()["backend"]["path"],
?? "action": action,
null }
) ),
=== "method": method,
null "query": (
) (with_body || (input === null))
? ?
null null
: :
event_raw["end"] ("?" + lib_plankton.www_form.encode(input))
), ),
"location": ( "headers": Object.assign(
event_raw["location"] {},
?? (
null (! with_body)
?
{}
:
{"Content-Type": "application/json"}
), ),
"description": ( (
event_raw["description"] (_session_key === null)
?? ?
null {}
), :
}) {"X-Session-Key": _session_key}
) )
), ),
}, "body": (
((! with_body) || (input === null))
?
null
:
/*Buffer.from*/(lib_plankton.json.encode(input))
),
}; };
break; 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>
{
_session_key = await call(
lib_plankton.http.enum_method.post,
"/session/begin",
{
"name": name,
"password": password,
} }
}) (calendar_entry_raw["object"])
),
})
)
),
}) as type_datamodel
),
]
); );
}
else {
// do nothing
}
return Promise.resolve<void>(undefined); 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( export async function calendar_list(
@ -115,65 +131,23 @@ namespace _zeitbild.frontend.resources.backend
> >
> >
{ {
await init(); return call(
return Promise.resolve( lib_plankton.http.enum_method.get,
_data.calendars "/calendars",
.map( null
(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)",
}
};
}
}
}
)
); );
} }
/**
*/
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 * @todo prevent loops
*/ */
export async function calendar_gather_events( export async function events(
calendar_ids : Array<type_calendar_id>, from_pit : _zeitbild.frontend_web.helpers.type_pit,
from_pit : _zeitbild.frontend.helpers.type_pit, to_pit : _zeitbild.frontend_web.helpers.type_pit,
to_pit : _zeitbild.frontend.helpers.type_pit options : {
calendar_ids ?: (null | Array<type_calendar_id>);
} = {}
) : Promise< ) : Promise<
Array< Array<
{ {
@ -184,150 +158,30 @@ namespace _zeitbild.frontend.resources.backend
> >
> >
{ {
lib_plankton.log.info( options = Object.assign(
"calendar_gather_events",
{ {
"calendar_ids": calendar_ids, "calendar_ids": null,
} },
options
); );
await init();
let result : Array< return call(
lib_plankton.http.enum_method.get,
"/events",
Object.assign(
{ {
calendar_id : type_calendar_id; "from": from_pit,
calendar_name : string; "to": to_pit,
event : type_event; },
} (
> = []; (options.calendar_ids === null)
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
: :
"???" {"calendar_ids": options.calendar_ids.join(",")}
),
"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
{ {
/** /**
@ -533,58 +533,4 @@ 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( async function render(
conf : type_conf,
calendar_ids : Array<type_calendar_id>
) : Promise<void> ) : Promise<void>
{ {
calendar_ids.sort();
const target : HTMLElement = (document.querySelector("body") as HTMLBodyElement); const target : HTMLElement = (document.querySelector("body") as HTMLBodyElement);
switch (conf.view_mode) { const view_type : string = "table";
switch (view_type) {
default: { default: {
throw (new Error("invalid view mode")); throw (new Error("invalid view mode"));
break; break;
} }
case "table": { case "table": {
const content : string = await _zeitbild.frontend.view.calendar_view_table_html( const content : string = await _zeitbild.frontend_web.view.calendar_view_table_html(
calendar_ids,
{ {
"calendar_ids": null,
"from": { "from": {
"year": 2024, "year": 2024,
"week": 35 "week": 37
}, },
"to": { "to": {
"year": 2024, "year": 2024,
"week": 43 "week": 43
}, },
"timezone_shift": conf.timezone_shift, "timezone_shift": /*conf.timezone_shift*/0,
} }
); );
target.innerHTML = content; target.innerHTML = content;
@ -74,10 +73,10 @@ namespace _zeitbild.frontend
break; break;
} }
case "list": { case "list": {
const content : string = await _zeitbild.frontend.view.calendar_view_list_html( const content : string = await _zeitbild.frontend_web.view.calendar_view_list_html(
calendar_ids, null,
{ {
"timezone_shift": conf.timezone_shift, "timezone_shift": /*conf.timezone_shift*/0,
} }
); );
target.innerHTML = content; target.innerHTML = content;
@ -101,10 +100,16 @@ namespace _zeitbild.frontend
); );
// conf // 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 // args
/*
const url : URL = new URL(window.location.toString()); const url : URL = new URL(window.location.toString());
const calendar_ids : Array<type_calendar_id> = ( const calendar_ids : Array<type_calendar_id> = (
(url.searchParams.get("ids") !== null) (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 // exec
await render( await render();
conf,
calendar_ids
);
return Promise.resolve<void>(undefined); 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 = { export type type_event = {
name : string; name : string;
begin : _zeitbild.frontend.helpers.type_datetime; begin : _zeitbild.frontend_web.helpers.type_datetime;
end : ( end : (
null null
| |
_zeitbild.frontend.helpers.type_datetime _zeitbild.frontend_web.helpers.type_datetime
); );
location : ( location : (
null 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" * @todo kein "while"
*/ */
async function calendar_view_table_data( async function calendar_view_table_data(
calendar_ids : Array<type_calendar_id>, calendar_ids : (
options : { null
from ?: { |
Array<type_calendar_id>
),
from : {
year : int; year : int;
week : int; week : int;
}, },
to ?: { to : {
year : int; year : int;
week : int; week : int;
}, },
timezone_shift ?: int; timezone_shift : int,
} = {}
) : Promise< ) : Promise<
{ {
sources : lib_plankton.structures.type_hashmap< sources : lib_plankton.map.type_map<
type_calendar_id, type_calendar_id,
{ {
name : string; name : string;
@ -159,7 +161,7 @@ namespace _zeitbild.frontend.view
week : int; week : int;
data : Array< data : Array<
{ {
pit : _zeitbild.frontend.helpers.type_pit; pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array< entries : Array<
{ {
calendar_id : type_calendar_id; 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(); 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_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 calendar_object : type_calendar_object = calendar_read( const calendar_object : type_calendar_object = calendar_read(
data, data,
calendar_id calendar_id
); );
*/ */
const from_pit : _zeitbild.frontend.helpers.type_pit = _zeitbild.frontend.helpers.pit_from_year_and_week( const from_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_from_year_and_week(
(options.from as {year : int; week : int}).year, (from as {year : int; week : int}).year,
(options.from as {year : int; week : int}).week, (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( const to_pit : _zeitbild.frontend_web.helpers.type_pit = _zeitbild.frontend_web.helpers.pit_from_year_and_week(
(options.to as {year : int; week : int}).year, (to as {year : int; week : int}).year,
(options.to as {year : int; week : int}).week, (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; calendar_name : string;
event : type_event; event : type_event;
} }
> = await _zeitbild.frontend.resources.backend.calendar_gather_events( > = await _zeitbild.frontend_web.backend.events(
calendar_ids,
from_pit, from_pit,
to_pit to_pit,
{
"calendar_ids": calendar_ids,
}
); );
let result : { let result : {
sources : lib_plankton.structures.type_hashmap< sources : lib_plankton.map.type_map<
type_calendar_id, type_calendar_id,
{ {
name : string; name : string;
@ -248,7 +224,7 @@ namespace _zeitbild.frontend.view
week : int; week : int;
data : Array< data : Array<
{ {
pit : _zeitbild.frontend.helpers.type_pit; pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array< entries : Array<
{ {
calendar_id : type_calendar_id; calendar_id : type_calendar_id;
@ -261,9 +237,11 @@ namespace _zeitbild.frontend.view
} }
>; >;
} = { } = {
"sources": lib_plankton.structures.hashmap_construct( "sources": lib_plankton.map.hashmap.implementation_map(
lib_plankton.map.hashmap.make(
x => x.toFixed(0), x => x.toFixed(0),
( {
"pairs": (
entries entries
.map( .map(
(entry) => ( (entry) => (
@ -276,12 +254,14 @@ namespace _zeitbild.frontend.view
) )
) )
) )
}
)
), ),
"rows": [], "rows": [],
}; };
let row : Array< let row : Array<
{ {
pit : _zeitbild.frontend.helpers.type_pit; pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array< entries : Array<
{ {
calendar_id : type_calendar_id; calendar_id : type_calendar_id;
@ -293,12 +273,12 @@ namespace _zeitbild.frontend.view
> = []; > = [];
let day : int = 0; let day : int = 0;
while (true) { 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, from_pit,
day day
); );
if ( if (
_zeitbild.frontend.helpers.pit_is_before( _zeitbild.frontend_web.helpers.pit_is_before(
pit_current, pit_current,
to_pit to_pit
) )
@ -315,7 +295,7 @@ namespace _zeitbild.frontend.view
result.rows.push( result.rows.push(
{ {
"week": ( "week": (
(options.from as {year : int; week : int}).week (from as {year : int; week : int}).week
+ +
Math.floor(day / 7) Math.floor(day / 7)
- -
@ -343,7 +323,7 @@ namespace _zeitbild.frontend.view
.forEach( .forEach(
(entry) => { (entry) => {
const distance_seconds : int = ( 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 from_pit
); );
@ -389,8 +369,12 @@ namespace _zeitbild.frontend.view
/** /**
*/ */
export async function calendar_view_table_html( export async function calendar_view_table_html(
calendar_ids : Array<type_calendar_id>,
options : { options : {
calendar_ids ?: (
null
|
Array<type_calendar_id>
);
from ?: { from ?: {
year : int; year : int;
week : int; week : int;
@ -403,8 +387,38 @@ namespace _zeitbild.frontend.view
} = {} } = {}
) : Promise<string> ) : 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 : { const stuff : {
sources : lib_plankton.structures.type_hashmap< sources : lib_plankton.map.type_map<
type_calendar_id, type_calendar_id,
{ {
name : string; name : string;
@ -415,7 +429,7 @@ namespace _zeitbild.frontend.view
week : int; week : int;
data : Array< data : Array<
{ {
pit : _zeitbild.frontend.helpers.type_pit; pit : _zeitbild.frontend_web.helpers.type_pit;
entries : Array< entries : Array<
{ {
calendar_id : type_calendar_id; calendar_id : type_calendar_id;
@ -428,18 +442,23 @@ namespace _zeitbild.frontend.view
} }
>; >;
} = await calendar_view_table_data( } = await calendar_view_table_data(
calendar_ids, options.calendar_ids,
options options.from,
options.to,
options.timezone_shift
); );
const sources : lib_plankton.structures.type_hashmap< const sources : lib_plankton.map.type_map<
type_calendar_id, type_calendar_id,
{ {
name : string; name : string;
color : lib_plankton.color.type_color; color : lib_plankton.color.type_color;
} }
> = lib_plankton.structures.hashmap_construct( > = lib_plankton.map.hashmap.implementation_map(
lib_plankton.map.hashmap.make(
(x => x.toFixed(0)), (x => x.toFixed(0)),
lib_plankton.structures.hashmap_dump( {
"pairs": (
lib_plankton.map.dump(
stuff.sources stuff.sources
) )
.map( .map(
@ -457,15 +476,18 @@ namespace _zeitbild.frontend.view
} }
}) })
) )
)
}
)
); );
return _zeitbild.frontend.helpers.template_coin( return _zeitbild.frontend_web.helpers.template_coin(
"tableview", "tableview",
{ {
"sources": ( "sources": (
await _zeitbild.frontend.helpers.promise_row<string>( await _zeitbild.frontend_web.helpers.promise_row<string>(
lib_plankton.structures.hashmap_dump(sources) lib_plankton.map.dump(sources)
.map( .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", "tableview-sources-entry",
{ {
"name": data.name, "name": data.name,
@ -477,18 +499,18 @@ namespace _zeitbild.frontend.view
) )
).join(""), ).join(""),
"rows": ( "rows": (
await _zeitbild.frontend.helpers.promise_row<string>( await _zeitbild.frontend_web.helpers.promise_row<string>(
stuff.rows stuff.rows
.map( .map(
(row) => async () => _zeitbild.frontend.helpers.template_coin( (row) => async () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-row", "tableview-row",
{ {
"week": row.week.toFixed(0).padStart(2, "0"), "week": row.week.toFixed(0).padStart(2, "0"),
"cells": ( "cells": (
await _zeitbild.frontend.helpers.promise_row<string>( await _zeitbild.frontend_web.helpers.promise_row<string>(
row.data row.data
.map( .map(
(cell) => async () => _zeitbild.frontend.helpers.template_coin( (cell) => async () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-cell", "tableview-cell",
{ {
"extra_classes": ( "extra_classes": (
@ -499,8 +521,8 @@ namespace _zeitbild.frontend.view
"title": lib_plankton.call.convey( "title": lib_plankton.call.convey(
cell.pit, cell.pit,
[ [
_zeitbild.frontend.helpers.pit_to_datetime, _zeitbild.frontend_web.helpers.pit_to_datetime,
(x : _zeitbild.frontend.helpers.type_datetime) => lib_plankton.string.coin( (x : _zeitbild.frontend_web.helpers.type_datetime) => lib_plankton.string.coin(
"{{year}}-{{month}}-{{day}}", "{{year}}-{{month}}-{{day}}",
{ {
"year": x.date.year.toFixed(0).padStart(4, "0"), "year": x.date.year.toFixed(0).padStart(4, "0"),
@ -513,8 +535,8 @@ namespace _zeitbild.frontend.view
"day": lib_plankton.call.convey( "day": lib_plankton.call.convey(
cell.pit, cell.pit,
[ [
_zeitbild.frontend.helpers.pit_to_datetime, _zeitbild.frontend_web.helpers.pit_to_datetime,
(x : _zeitbild.frontend.helpers.type_datetime) => lib_plankton.string.coin( (x : _zeitbild.frontend_web.helpers.type_datetime) => lib_plankton.string.coin(
"{{day}}", "{{day}}",
{ {
"year": x.date.year.toFixed(0).padStart(4, "0"), "year": x.date.year.toFixed(0).padStart(4, "0"),
@ -525,21 +547,19 @@ namespace _zeitbild.frontend.view
] ]
), ),
"entries": ( "entries": (
await _zeitbild.frontend.helpers.promise_row<string>( await _zeitbild.frontend_web.helpers.promise_row<string>(
cell.entries cell.entries
.map( .map(
(entry) => () => _zeitbild.frontend.helpers.template_coin( (entry) => () => _zeitbild.frontend_web.helpers.template_coin(
"tableview-cell-entry", "tableview-cell-entry",
{ {
"color": lib_plankton.color.output_hex( "color": lib_plankton.color.output_hex(
lib_plankton.structures.hashmap_get( sources.get(
sources,
entry.calendar_id entry.calendar_id
).color ).color
), ),
"title": event_generate_tooltip( "title": event_generate_tooltip(
lib_plankton.structures.hashmap_get( sources.get(
sources,
entry.calendar_id entry.calendar_id
).name, ).name,
entry.event entry.event
@ -570,8 +590,8 @@ namespace _zeitbild.frontend.view
async function calendar_view_list_data( async function calendar_view_list_data(
calendar_ids : Array<type_calendar_id>, calendar_ids : Array<type_calendar_id>,
options : { options : {
from ?: _zeitbild.frontend.helpers.type_pit; from ?: _zeitbild.frontend_web.helpers.type_pit;
to ?: _zeitbild.frontend.helpers.type_pit; to ?: _zeitbild.frontend_web.helpers.type_pit;
timezone_shift ?: int; timezone_shift ?: int;
} = {} } = {}
) : Promise< ) : 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( options = Object.assign(
{ {
"from": lib_plankton.call.convey( "from": lib_plankton.call.convey(
now_pit, 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( "to": lib_plankton.call.convey(
now_pit, 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, "timezone_shift": 0,
@ -608,17 +628,19 @@ namespace _zeitbild.frontend.view
calendar_id : type_calendar_id; calendar_id : type_calendar_id;
event : type_event; event : type_event;
} }
> = await _zeitbild.frontend.resources.backend.calendar_gather_events( > = await _zeitbild.frontend_web.backend.events(
calendar_ids, (options.from as _zeitbild.frontend_web.helpers.type_pit),
(options.from as _zeitbild.frontend.helpers.type_pit), (options.to as _zeitbild.frontend_web.helpers.type_pit),
(options.to as _zeitbild.frontend.helpers.type_pit) {
"calendar_ids": calendar_ids,
}
); );
// TODO: optimize // TODO: optimize
entries.sort( entries.sort(
(entry_1, entry_2) => ( (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( export async function calendar_view_list_html(
calendar_ids : Array<type_calendar_id>, calendar_ids : Array<type_calendar_id>,
options : { options : {
from ?: _zeitbild.frontend.helpers.type_pit; from ?: _zeitbild.frontend_web.helpers.type_pit;
to ?: _zeitbild.frontend.helpers.type_pit; to ?: _zeitbild.frontend_web.helpers.type_pit;
timezone_shift ?: int; timezone_shift ?: int;
} = {} } = {}
) : Promise<string> ) : Promise<string>

View file

@ -24,14 +24,6 @@ def main():
metavar = "<conf-path>", metavar = "<conf-path>",
help = "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() args = argument_parser.parse_args()
## exec ## exec
@ -55,17 +47,6 @@ def main():
args.output_directory, 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) _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_temp}/logic-unlinked.js: \
${dir_lib}/plankton/plankton.d.ts \ ${dir_lib}/plankton/plankton.d.ts \
${dir_source}/logic/helpers.ts \ ${dir_source}/logic/helpers.ts \
${dir_source}/logic/conf.ts \
${dir_source}/logic/types.ts \ ${dir_source}/logic/types.ts \
${dir_source}/logic/backend.ts \ ${dir_source}/logic/backend.ts \
${dir_source}/logic/view.ts \ ${dir_source}/logic/view.ts \
${dir_source}/logic/main.ts ${dir_source}/logic/main.ts
@ ${cmd_log} "logic | compile …" @ ${cmd_log} "logic | compile …"
@ ${cmd_mkdir} $(dir $@) @ ${cmd_mkdir} $(dir $@)
@ ${cmd_tsc} --lib dom,es2020 --strict $^ --outFile $@ @ ${cmd_tsc} --lib dom,es2020 $^ --outFile $@ # --strict
${dir_build}/logic.js: \ ${dir_build}/logic.js: \
${dir_lib}/plankton/plankton.js \ ${dir_lib}/plankton/plankton.js \

View file

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