Compare commits

...

3 commits

Author SHA1 Message Date
fenris 4612128134 [task-408] [mod] Wochenansich-Steuerelement umgestellt 2025-10-14 22:10:56 +02:00
fenris 7e1f585f34 [upd] plankton 2025-10-14 22:09:57 +02:00
fenris c53837ebfe [upd] plankton 2025-10-14 22:09:49 +02:00
9 changed files with 863 additions and 944 deletions

View file

@ -1,11 +1,11 @@
/** /**
* @author fenris * @author fenris
*/ */
declare type int = number; type int = number;
/** /**
* @author fenris * @author fenris
*/ */
declare type float = number; type float = number;
declare class Buffer { declare class Buffer {
constructor(x: string, modifier?: string); constructor(x: string, modifier?: string);
toString(modifier?: string): string; toString(modifier?: string): string;
@ -19,7 +19,7 @@ declare namespace lib_plankton.base {
/** /**
* @author fenris * @author fenris
*/ */
declare type type_pseudopointer<type_value> = { type type_pseudopointer<type_value> = {
value: type_value; value: type_value;
}; };
/** /**
@ -1969,7 +1969,7 @@ declare namespace lib_plankton.storage.memory {
clear(): Promise<void>; clear(): Promise<void>;
write(key: any, value: any): Promise<boolean>; write(key: any, value: any): Promise<boolean>;
delete(key: any): Promise<void>; delete(key: any): Promise<void>;
read(key: any): Promise<type_item>; read(key: any): Promise<Awaited<type_item>>;
search(term: any): Promise<{ search(term: any): Promise<{
key: string; key: string;
preview: string; preview: string;
@ -2693,6 +2693,51 @@ declare namespace lib_plankton.map.collatemap {
export function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>; export function implementation_map<type_key, type_value>(subject: type_subject<type_key, type_value>): type_map<type_key, type_value>;
export {}; export {};
} }
declare namespace lib_plankton.cache {
/**
*/
type type_result<type_value> = {
retrieved: boolean;
value: type_value;
};
/**
*/
type type_entry<type_value> = {
value: type_value;
expiry: (null | float);
};
/**
*/
type type_subject<type_value> = lib_plankton.storage.type_chest<string, type_entry<type_value>, void, any, any>;
}
declare namespace lib_plankton.cache {
/**
*/
function make<type_value>({ "chest": chest, }?: {
chest?: lib_plankton.storage.type_chest<string, type_entry<type_value>, void, any, any>;
}): type_subject<type_value>;
/**
*/
function init<type_value>(subject: type_subject<type_value>): Promise<void>;
/**
*/
function clear<type_value>(subject: type_subject<type_value>): Promise<void>;
/**
*/
function invalidate<type_value>(subject: type_subject<type_value>, key: string): Promise<void>;
/**
*/
function query<type_value>(subject: type_subject<type_value>, key: string, lifetime: (null | float), retrieve: (() => Promise<type_value>)): Promise<type_result<type_value>>;
/**
* syntactic sugar: if the information, whether the value was retrieved, is irrelevant
*/
function get<type_value>(subject: type_subject<type_value>, key: string, lifetime: (null | float), retrieve: (() => Promise<type_value>)): Promise<type_value>;
/**
*/
function get_complex<type_input, type_value>(cache: type_subject<type_value>, group: string, input: type_input, lifetime: (null | float), retrieve: ((input: type_input) => Promise<type_value>), { "encode_input": encode_input, }?: {
encode_input?: ((input: type_input) => string);
}): Promise<type_value>;
}
declare namespace lib_plankton.complex { declare namespace lib_plankton.complex {
/** /**
* @author fenris * @author fenris

View file

@ -2151,7 +2151,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
function verb(n) { return function (v) { return step([n, v]); }; } function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) { function step(op) {
if (f) throw new TypeError("Generator is already executing."); if (f) throw new TypeError("Generator is already executing.");
while (_) try { while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value]; if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) { switch (op[0]) {
@ -8710,6 +8710,136 @@ var lib_plankton;
})(map = lib_plankton.map || (lib_plankton.map = {})); })(map = lib_plankton.map || (lib_plankton.map = {}));
})(lib_plankton || (lib_plankton = {})); })(lib_plankton || (lib_plankton = {}));
/* /*
This file is part of »bacterio-plankton:cache«.
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
<info@greenscale.de>
»bacterio-plankton:cache« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»bacterio-plankton:cache« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »bacterio-plankton:cache«. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This file is part of »bacterio-plankton:cache«.
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
<info@greenscale.de>
»bacterio-plankton:cache« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»bacterio-plankton:cache« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »bacterio-plankton:cache«. If not, see <http://www.gnu.org/licenses/>.
*/
var lib_plankton;
(function (lib_plankton) {
var cache;
(function (cache_1) {
/**
*/
function make({ "chest": chest = lib_plankton.storage.memory.implementation_chest({}), } = {}) {
return chest;
}
cache_1.make = make;
/**
*/
function init(subject) {
return subject.setup(undefined);
}
cache_1.init = init;
/**
*/
function clear(subject) {
return subject.clear();
}
cache_1.clear = clear;
/**
*/
function invalidate(subject, key) {
return subject.delete(key);
}
cache_1.invalidate = invalidate;
/**
*/
async function query(subject, key, lifetime, retrieve) {
const now = lib_plankton.base.get_current_timestamp();
return ((subject.read(key)
.then((entry) => Promise.resolve({
"found": true,
"entry": entry,
}))
.catch(() => Promise.resolve({
"found": false,
"entry": null,
})))
.then((item) => {
if ((!item.found)
||
((item.entry.expiry !== null)
&&
(item.entry.expiry <= now))) {
lib_plankton.log.info("plankton.cache.unknown_or_expired", {
"key": key,
});
return (retrieve()
.then((value) => (subject.write(key, {
"value": value,
"expiry": ((lifetime === null)
?
null
:
(now + lifetime))
})
.then(() => Promise.resolve({
"retrieved": true,
"value": value
})))));
}
else {
lib_plankton.log.info("plankton.cache.known_and_valid", {
"key": key,
});
return Promise.resolve({
"retrieved": false,
"value": item.entry.value
});
}
}));
}
cache_1.query = query;
/**
* syntactic sugar: if the information, whether the value was retrieved, is irrelevant
*/
function get(subject, key, lifetime, retrieve) {
return (query(subject, key, lifetime, retrieve)
.then(result => Promise.resolve(result.value)));
}
cache_1.get = get;
/**
*/
function get_complex(cache, group, input, lifetime, retrieve, { "encode_input": encode_input = (input => JSON.stringify(input)), } = {}) {
return get(cache, (group + "." + encode_input(input)), lifetime, () => retrieve(input));
}
cache_1.get_complex = get_complex;
})(cache = lib_plankton.cache || (lib_plankton.cache = {}));
})(lib_plankton || (lib_plankton = {}));
/*
This file is part of »bacterio-plankton:complex«. This file is part of »bacterio-plankton:complex«.
Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' Copyright 2016-2024 'Christian Fraß, Christian Neubauer, Martin Springwald GbR'
@ -9449,6 +9579,12 @@ var lib_plankton;
* @author fenris * @author fenris
*/ */
class class_relation { class class_relation {
/**
* @author fenris
*/
check(value, reference) {
return this.predicate(value, reference);
}
/** /**
* @author fenris * @author fenris
*/ */
@ -9458,12 +9594,6 @@ var lib_plankton;
this.name = name; this.name = name;
this.predicate = predicate; this.predicate = predicate;
} }
/**
* @author fenris
*/
check(value, reference) {
return this.predicate(value, reference);
}
/** /**
* @author fenris * @author fenris
*/ */

View file

@ -1,6 +1,37 @@
namespace _dali namespace _dali
{ {
/**
*/
export function access_level_encode(
access_level : _dali.type.enum_access_level
) : ("none" | "view" | "edit" | "admin")
{
switch (access_level) {
case _dali.type.enum_access_level.none: return "none";
case _dali.type.enum_access_level.view: return "view";
case _dali.type.enum_access_level.edit: return "edit";
case _dali.type.enum_access_level.admin: return "admin";
}
}
/**
*/
export function access_level_decode(
representation : /*("none" | "view" | "edit" | "admin")*/string
) : _dali.type.enum_access_level
{
switch (representation)
{
case "none": return _dali.type.enum_access_level.none;
case "view": return _dali.type.enum_access_level.view;
case "edit": return _dali.type.enum_access_level.edit;
case "admin": return _dali.type.enum_access_level.admin;
default: throw (new Error("invalid access level representation: " + representation));
}
}
/** /**
*/ */

View file

@ -42,9 +42,9 @@ namespace _dali.type
* extern eingebundene Events kodiert * extern eingebundene Events kodiert
* *
* @example "local:1234" * @example "local:1234"
* @example "ics:2345" * @example "ics~2345"
*/ */
export type event_id = string; export type event_key = string;
/** /**
@ -78,7 +78,8 @@ namespace _dali.type
/** /**
*/ */
export type event_entry = { export type event_entry = {
id : event_id; id : (null | local_resource_event_id);
key : event_key;
object : event_object; object : event_object;
}; };

View file

@ -17,13 +17,6 @@ namespace _dali.pages.overview
target_element.querySelector("#overview").classList.toggle("overview-compact", compact); target_element.querySelector("#overview").classList.toggle("overview-compact", compact);
}; };
/**
* @todo geschickter bauen (MVC, MVVM, )
*/
const update = () => {
lib_plankton.zoo_page.reload();
};
// exec // exec
target_element.innerHTML = await _dali.helpers.template_coin( target_element.innerHTML = await _dali.helpers.template_coin(
"overview", "overview",
@ -66,6 +59,12 @@ namespace _dali.pages.overview
let widget_weekview : _dali.widgets.weekview.class_widget_weekview; let widget_weekview : _dali.widgets.weekview.class_widget_weekview;
let widget_listview : _dali.widgets.listview.class_widget_listview; let widget_listview : _dali.widgets.listview.class_widget_listview;
/**
* @todo update sources
*/
const update = () => {
widget_weekview.update_entries();
};
// hint // hint
{ {
if (! await _dali.backend.is_logged_in()) if (! await _dali.backend.is_logged_in())
@ -176,6 +175,15 @@ namespace _dali.pages.overview
} }
); );
const action_select_event = (calendar_id, access_level, event_id) => { const action_select_event = (calendar_id, access_level, event_id) => {
/*
if (! await _dali.backend.is_logged_in())
{
// do nothing
}
else
{
}
*/
let read_only : boolean; let read_only : boolean;
switch (access_level) switch (access_level)
{ {
@ -304,6 +312,15 @@ namespace _dali.pages.overview
{ {
"action_select_event": action_select_event, "action_select_event": action_select_event,
"action_select_day": (date) => { "action_select_day": (date) => {
/*
if (! await _dali.backend.is_logged_in())
{
// do nothing
}
else
{
}
*/
(async () => { (async () => {
const widget = new _dali.widgets.event_edit.class_widget_event_edit( const widget = new _dali.widgets.event_edit.class_widget_event_edit(
{ {

View file

@ -14,6 +14,16 @@ namespace _dali.backend
/** /**
*/ */
var _cache : (
null
|
lib_plankton.cache.type_subject<boolean>
);
/**
* meant for translation of the API values
*/
function access_level_encode( function access_level_encode(
access_level : _dali.type.enum_access_level access_level : _dali.type.enum_access_level
) : ("none" | "view" | "edit" | "admin") ) : ("none" | "view" | "edit" | "admin")
@ -28,6 +38,7 @@ namespace _dali.backend
/** /**
* meant for translation of the API values
*/ */
function access_level_decode( function access_level_decode(
access_level_encoded : ("none" | "view" | "edit" | "admin") access_level_encoded : ("none" | "view" | "edit" | "admin")
@ -52,6 +63,14 @@ namespace _dali.backend
"corner": "zeitbild", "corner": "zeitbild",
} }
); );
_cache = lib_plankton.cache.make<boolean>(
/*
lib_plankton.storage.memory.implementation_chest(
{
}
)
*/
);
return Promise.resolve<void>(undefined); return Promise.resolve<void>(undefined);
} }
@ -162,19 +181,27 @@ namespace _dali.backend
/** /**
* @todo mneh
*/ */
export async function is_logged_in( export async function is_logged_in(
) : Promise<boolean> ) : Promise<boolean>
{ {
// return ((await get_session_key()) !== null); return lib_plankton.cache.get(
const result : { _cache,
logged_in : boolean; "status",
} = await call( 5,
lib_plankton.http.enum_method.get, async () => {
"/session/status", // return ((await get_session_key()) !== null);
null const result : {
logged_in : boolean;
} = await call(
lib_plankton.http.enum_method.get,
"/session/status",
null
);
return result.logged_in;
}
); );
return result.logged_in;
} }
@ -596,12 +623,20 @@ namespace _dali.backend
export async function events( export async function events(
from_pit : lib_plankton.pit.type_pit, from_pit : lib_plankton.pit.type_pit,
to_pit : lib_plankton.pit.type_pit, to_pit : lib_plankton.pit.type_pit,
options : { {
"calendar_ids": calendar_ids = null,
}
:
{
calendar_ids ?: (null | Array<_dali.type.calendar_id>); calendar_ids ?: (null | Array<_dali.type.calendar_id>);
} = {} }
=
{
}
) : Promise< ) : Promise<
Array< Array<
{ {
key : _dali.type.event_key;
calendar_id : _dali.type.calendar_id; calendar_id : _dali.type.calendar_id;
calendar_name : string; calendar_name : string;
hue : float; hue : float;
@ -612,13 +647,6 @@ namespace _dali.backend
> >
> >
{ {
options = Object.assign(
{
"calendar_ids": null,
},
options
);
return ( return (
call( call(
lib_plankton.http.enum_method.get, lib_plankton.http.enum_method.get,
@ -629,11 +657,11 @@ namespace _dali.backend
"to": to_pit, "to": to_pit,
}, },
( (
(options.calendar_ids === null) (calendar_ids === null)
? ?
{} {}
: :
{"calendar_ids": options.calendar_ids.join(",")} {"calendar_ids": calendar_ids.join(",")}
) )
) )
) )
@ -642,6 +670,7 @@ namespace _dali.backend
data data
.map( .map(
(entry) => ({ (entry) => ({
"key": entry.hash,
"calendar_id": entry.calendar_id, "calendar_id": entry.calendar_id,
"calendar_name": entry.calendar_name, "calendar_name": entry.calendar_name,
"hue": entry.hue, "hue": entry.hue,

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,6 @@
<span>{{label_control_count}}</span> <span>{{label_control_count}}</span>
<input type="number"/> <input type="number"/>
</label> </label>
<input type="submit" class="weekview-control weekview-control-apply" value="{{label_control_apply}}"/>
</div> </div>
<div class="weekview-table"> <div class="weekview-table">
<table> <table>

View file

@ -14,6 +14,7 @@ modules="${modules} json"
modules="${modules} string" modules="${modules} string"
modules="${modules} random" modules="${modules} random"
modules="${modules} map" modules="${modules} map"
modules="${modules} cache"
modules="${modules} color" modules="${modules} color"
# modules="${modules} xml" # modules="${modules} xml"
modules="${modules} map" modules="${modules} map"