tracker schema

This commit is contained in:
philc 2025-02-20 19:40:15 +01:00
parent baef67ef98
commit 9b64d946cd
6 changed files with 214 additions and 38 deletions

4
.gitignore vendored
View File

@ -18,10 +18,6 @@
!objects/ !objects/
!objects/options/ !objects/options/
!objects/options/** !objects/options/**
!objects/tpldata/
!objects/tpldata/**
!objects/screens/
!objects/screens/**
!objects/tplstrings/ !objects/tplstrings/
!objects/tplstrings/** !objects/tplstrings/**

View File

@ -47,15 +47,18 @@ Wwws.getwco = (wconame, ctx) => {
const wcoinfo = fs.readJSONSync(wcoconf); const wcoinfo = fs.readJSONSync(wcoconf);
const webpage = fs.readJSONSync(webconf); const webpage = fs.readJSONSync(webconf);
// check that webconf for tailwindcsscontent property exist for this wco request // check that webconf for tailwindcsscontent property exist for this wco request
const pathtocheckfortw=[`../adminapi/objects/wco/${wconame}/*.{html,js,mustache}`,`../${ctx.tribe}/objects/wwws/${ctx.xapp}/src/**/*.{html,js,mustache}`] const pathtocheckfortw = [
if (!webpage.tailwindcsscontent){ `../adminapi/objects/wco/${wconame}/*.{html,js,mustache}`,
webpage.tailwindcsscontent=[] `../${ctx.tribe}/objects/wwws/${ctx.xapp}/src/**/*.{html,js,mustache}`,
];
if (!webpage.tailwindcsscontent) {
webpage.tailwindcsscontent = [];
} }
pathtocheckfortw.forEach(tw=>{ pathtocheckfortw.forEach((tw) => {
if (!webpage.tailwindcsscontent.includes(tw)){ if (!webpage.tailwindcsscontent.includes(tw)) {
webpage.tailwindcsscontent.push(tw) webpage.tailwindcsscontent.push(tw);
} }
}) });
// check that all tpl for this compoent are well in pages tpl object // check that all tpl for this compoent are well in pages tpl object
if (wcoinfo.tpl && Object.keys(wcoinfo.tpl).length > 0) { if (wcoinfo.tpl && Object.keys(wcoinfo.tpl).length > 0) {
Object.keys(wcoinfo.tpl).forEach((t) => { Object.keys(wcoinfo.tpl).forEach((t) => {
@ -68,26 +71,60 @@ Wwws.getwco = (wconame, ctx) => {
}); });
} }
// check that tpldata exist for the wco, if not create them with template data example into the project // check that tpldata exist for the wco, if not create them with template data example into the project
if (ctx.tagid && wcoinfo.tpldatamodel && Object.keys(wcoinfo.tpldatamodel).length > 0) { //console.log(wcoinfo,ctx)
if (
!ctx.tagid &&
wcoinfo.tpldatamodel &&
Object.keys(wcoinfo.tpldatamodel).length > 0
) {
console.log(
`Warning: you add a wco that request tagid to initiate tpldata into your project, please add in wwws/getwco/${wcoinfo.wconame}.js?xx&tagid=id1,id2 where this wco is used`
);
}
if (
ctx.tagid &&
wcoinfo.tpldatamodel &&
Object.keys(wcoinfo.tpldatamodel).length > 0
) {
Object.keys(wcoinfo.tpldatamodel).forEach((t) => { Object.keys(wcoinfo.tpldatamodel).forEach((t) => {
const pathtpldata = `${ctx.tribe}/objects/wwws/${ctx.xapp}/src/tpldata/${ctx.pagename}/${ctx.tagid}_${t}`; //tagid can concern many id then tagid=idA,idB,idC
const localdbname=`${ctx.pagename}_${ctx.tagid}_${t}` ctx.tagid = ctx.tagid.includes(",") ? ctx.tagid.split(",") : [ctx.tagid];
if (!Object.keys(webpage.pages[ctx.pagename].tpldata).includes(localdbname)) { ctx.tagid.forEach((tid) => {
webpage.pages[ctx.pagename].tpldata[localdbname] = pathtpldata; const pathtpldata = `${ctx.tribe}/objects/wwws/${ctx.xapp}/src/tpldata/${ctx.pagename}/${tid}_${t}`;
} console.log("pathtpldata:", pathtpldata);
wcoinfo.lang.forEach((l) => { const localdbname = `${ctx.pagename}_${tid}_${t}`;
if ( if (
!fs.existsSync(`../${pathtpldata}_${l}.json`) && !Object.keys(webpage.pages[ctx.pagename].tpldata).includes(
fs.existsSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`) localdbname
)
) { ) {
const tpldataexample=fs.readJSONSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`) webpage.pages[ctx.pagename].tpldata[localdbname] = pathtpldata;
Object.keys(ctx).forEach(k=>{
tpldataexample[k]=ctx[k]
})
fs.outputJSONSync(
`../${pathtpldata}_${l}.json`,tpldataexample
);
} }
wcoinfo.lang.forEach((l) => {
if (!fs.existsSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`)) {
console.log(
`Warning, this file is suppose to exist ../${wcoinfo.tpldatamodel[t]}_${l}.json check lg or mispelling`
);
}
if (
!fs.existsSync(`../${pathtpldata}_${l}.json`) &&
fs.existsSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`)
) {
const tpldataexample = fs.readJSONSync(
`../${wcoinfo.tpldatamodel[t]}_${l}.json`
);
Object.keys(ctx).forEach((k) => {
if (k == "tagid") {
tpldataexample[k] = tid;
} else {
tpldataexample[k] = ctx[k];
}
});
fs.outputJSONSync(`../${pathtpldata}_${l}.json`, tpldataexample, {
spaces: 2,
});
}
});
}); });
}); });
} }
@ -111,7 +148,7 @@ Wwws.getwco = (wconame, ctx) => {
}), }),
]; ];
// save the conf for update localdb when the web page request it // save the conf for update localdb when the web page request it
fs.outputJSONSync(webconf, webpage, {spaces:2}); fs.outputJSONSync(webconf, webpage, { spaces: 2 });
return { return {
status: 200, status: 200,
ref: "Wwws", ref: "Wwws",
@ -122,6 +159,12 @@ Wwws.getwco = (wconame, ctx) => {
Wwws.build = (tribeId, webapp, srcdist, options) => { Wwws.build = (tribeId, webapp, srcdist, options) => {
console.log(`Building ${tribeId}/objects/wwws/${webapp}/${srcdist}`); console.log(`Building ${tribeId}/objects/wwws/${webapp}/${srcdist}`);
/*
mettre en cdn de la tribe /cdn/share/lib/nom du fichier
/adminapi/node_modules/axios/dist/axios.min.js ds /cdn/lib/axios/dist/axios.min.js
et dans html le build sera src="/cdn/lib/axios/dist/axios.min.js"
*/
const pathto = `../${tribeId}/objects/wwws`; const pathto = `../${tribeId}/objects/wwws`;
let confwww; let confwww;
if (fs.existsSync(`${pathto}/itm/${webapp}.json`)) { if (fs.existsSync(`${pathto}/itm/${webapp}.json`)) {
@ -379,7 +422,12 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
const fileparam = `../${tribe}/objects/wwws/itm/${appname}.json`; const fileparam = `../${tribe}/objects/wwws/itm/${appname}.json`;
//console.log(path.resolve(fileparam)); //console.log(path.resolve(fileparam));
if (!fs.existsSync(fileparam)) { if (!fs.existsSync(fileparam)) {
return { status: 404, ref: "Wwws", msg: "appdoesnotexist", data: {} }; return {
status: 404,
ref: "Wwws",
msg: "appdoesnotexist",
data: { fileparam },
};
} }
const locals = fs.readJSONSync(fileparam); const locals = fs.readJSONSync(fileparam);
if (!locals.pages[pagename]) { if (!locals.pages[pagename]) {
@ -423,11 +471,11 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
options: {}, options: {},
tpl: {}, tpl: {},
tpldata: {}, tpldata: {},
tpldatanew:{}, tpldatanew: {},
ref: {}, ref: {},
schema: {}, schema: {},
screens:{}, screens: {},
screensnew:{} screensnew: {},
}; };
localstorage.headers.xlang = lg; localstorage.headers.xlang = lg;
// A faire plus tard charger tous les referentiele et les data pour une page adminpage // A faire plus tard charger tous les referentiele et les data pour une page adminpage
@ -494,6 +542,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
} }
if (loc.tpl) { if (loc.tpl) {
Object.keys(loc.tpl).forEach((r) => { Object.keys(loc.tpl).forEach((r) => {
// possible to store an independant language mustache
let src = `../${loc.tpl[r]}`; let src = `../${loc.tpl[r]}`;
if (!fs.existsSync(src)) { if (!fs.existsSync(src)) {
src += `_${lg}.mustache`; src += `_${lg}.mustache`;
@ -540,7 +589,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
} }
}); });
} }
if (!loc.screens) loc.screens={} if (!loc.screens) loc.screens = {};
if (loc.screens) { if (loc.screens) {
Object.keys(loc.screens).forEach((r) => { Object.keys(loc.screens).forEach((r) => {
let src = `../${loc.screens[r]}`; let src = `../${loc.screens[r]}`;
@ -557,7 +606,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
} }
}); });
} }
if (!loc.screensnew) loc.screensnew={} if (!loc.screensnew) loc.screensnew = {};
if (loc.screensnew) { if (loc.screensnew) {
Object.keys(loc.screensnew).forEach((r) => { Object.keys(loc.screensnew).forEach((r) => {
let src = `../${loc.screensnew[r]}`; let src = `../${loc.screensnew[r]}`;

View File

@ -24,7 +24,7 @@
# .setup.sh smatchit https://testwall-ants.ndda.fr https://gitea.ndda.fr/smatchit/smatchit # .setup.sh smatchit https://testwall-ants.ndda.fr https://gitea.ndda.fr/smatchit/smatchit
tribe=$1 # name of the tribe to install tribe=$1 # name of the tribe to install
url=$2 # url to get the data from OR newtribe url=$2 # url to get the data from OR "newtribe" value
gitrepo=$3 # url to get apxtri code from a git repo (empty if must come from a backup or the url) gitrepo=$3 # url to get apxtri code from a git repo (empty if must come from a backup or the url)
codekey=$4 # code to access backend of the tribe in case it is not newtribe or adminapi tribe codekey=$4 # code to access backend of the tribe in case it is not newtribe or adminapi tribe

View File

@ -0,0 +1,30 @@
{
"title": "Country Code",
"description": "Country Code and Info",
"commment": "Alpha-2 country code (ISO 3166-2:XX)",
"lastupdatedata": "",
"lst_idx": ["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],
"itms": {
"monday": {
"title": "Monday"
},
"tuesday": {
"title": "Tuesday"
},
"wednesday": {
"title": "Wednesday"
},
"thursday": {
"title": "Thursday"
},
"friday": {
"title": "Friday"
},
"saturday": {
"title": "Saturday"
},
"sunday": {
"title": "Sunday"
}
}
}

View File

@ -0,0 +1,30 @@
{
"title": "Country Code",
"description": "Country Code and Info",
"commment": "Alpha-2 country code (ISO 3166-2:XX)",
"lastupdatedata": "",
"lst_idx": ["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],
"itms": {
"monday": {
"title": "Lundi"
},
"tuesady": {
"title": "Mardi"
},
"wednesday": {
"title": "Mercredi"
},
"thursday": {
"title": "Jeudi"
},
"friday": {
"title": "Vendredi"
},
"saturday": {
"title": "Samedi"
},
"sunday": {
"title": "Dimanche"
}
}
}

71
schema/devices.json Normal file
View File

@ -0,0 +1,71 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "adminapi/schema/wco",
"title": "web components",
"description": "A web component wco is a folder with list of mustache and one name.js that deal all the business logic",
"type": "object",
"properties": {
"wconame": {
"description": "Folder name into a tribeId/objects/wco/itm",
"title": "Web component reusable in web project based with tailwindcss",
"type": "string"
},
"owner": {
"description": "owner that earn some fees",
"type": "string"
},
"codehash": {
"description": "Code signature of alias publickey",
"type": "string"
},
"thumbnail":{
"title":"Thumbnail of the component",
"type":"string"
},
"title":{
"title":"Short description of the wco",
"type":"string"
},
"description":{
"title":"Long description in html of the component",
"type":"string"
},
"tpl":{
"description":"list of mustache template to manage components each file must ended by _xx.mustache where xx is the language of the template, so you can add translation easily",
"type":"array"
},
"tpldata":{
"description":"Example of tpldata that you have to add in your local to customize the wco ended by _xx.json where xx is the language of the template",
"type":"array"
}
},
"required": [
"wconame",
"owner",
"title"
],
"apxid": "wconame",
"apxuniquekey": [
"wconame"
],
"apxidx": [
{
"name": "lst_wconame",
"type": "array",
"keyval": "wconame"
}
],
"apxaccessrights": {
"owner": {
"D": [],
"R": [],
"U": []
},
"mayor": {
"C": []
},
"person": {
"R": []
}
}
}