Warning: session_start(): open(/var/lib/php/sessions/sess_44egv9bd3ptjlq8klvh2lve8pt, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
concept Rule > ConceptWithGlobalID {
S input, output, variables /* comma-separated */, comment;
sS _fieldOrder = "globalID input output variables comment";
}
concept Example > ConceptWithGlobalID {
Rule rule;
S input, output;
SS mapping;
sS _fieldOrder = "globalID rule input output mapping";
}
concept PossibleInput > ConceptWithGlobalID {
Rule rule;
S input;
}
p { dbIndexing(Rule, 'globalID, Example, 'rule); }
static HCRUD rulesCRUD() {
ret new HCRUD(rawLink("admin"), new HCRUD_Concepts(Rule) {
MapSO itemToMap(Rule r) {
ret mapPlus(super.itemToMap(r), "Examples" := countConcepts(Example, rule := r));
}
}.fieldHelp(variables := "comma-separated")
) {
S renderValue(S field, O value) {
S html = super.renderValue(field, value);
if (eq(field, 'globalID))
ret ahref(rawLink(str(value)), html);
if (eq(field, 'input))
ret b(html);
ret html;
}
};
}
html {
bool authed = webAuthed(params);
if (eqic(uri = dropSlashPrefix(uri), "admin")) {
try object checkWebAuthed(params);
ret rulesCRUD().renderPage(params);
}
if (empty(uri))
ret htitle_h1("Rules")
+ (webAuthed(params) ? p(ahref(rawLink("admin"), "Admin")) : "")
+ ul_noEncode(map(list(Rule), r -> ahref(rawLink(r.globalIDStr()), htmlEncode2(r.input + " => " + r.output))));
// serve rule
if (possibleGlobalID(uri)) {
Rule r = conceptWhere(Rule, globalID := GlobalID(uri));
if (r == null) ret subBot_serve404("Rule not found");
S html = htitle_h1("Rule " + r.globalID)
+ htmlTable2(mapToTwoElementMaps("Field", "Value", litorderedmap("Input" := r.input, "Output" := r.output, "Variables" := r.variables, "Comment" := r.comment)));
//html += conceptsWhere PossibleInput(rule := r);
if (webAuthed(params))
html += new HCRUD(rawLink(r.globalIDStr()), new HCRUD_Concepts(PossibleInput.class).addFilter(rule := r))
.makeFrame((title, contents) -> h3(title) + contents)
.renderPage(params);
ret html;
}
new Matches m;
if (swic(uri, "multi/", m))
ret new HMultiCRUD(rawLink("multi"), Rule, Example, PossibleInput) {
HCRUD makeCRUD(S className) {
if (eq(className, "Rule"))
ret rulesCRUD();
null;
}
} .mutationRights(authed)
.renderPage(m.rest(), params);
ret subBot_serve404();
}