First commit

This commit is contained in:
2025-12-25 11:16:59 +01:00
commit 0c5ca09a63
720 changed files with 329234 additions and 0 deletions

View File

@@ -0,0 +1,178 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
import tools from '../../unify/tools.js';
import querySQL from '../../unify/querySQL.js';
import Console from '../console.js';
import database from '../database.js';
import deepclone from '../../unify/clonedeep.js';
export default class columnController{
prepareQuery() {
}
deleteByParentID( tableName, parent_id, storageCollection ) {
var query = new querySQL();
query.type = "delete";
query.table = tableName;
query.find( storageCollection.getLeft() + "_id", parent_id );
database.query( query );
}
updateRow( row, clientValue ) {
if( clientValue == "" ) {
clientValue = false;
}
var validated = true;
if( object.validate ) {
validated = object.validate( row, client, eventName );
}
if( clientValue == true && validated ) {
var row_id = row.id;
var query = new querySQL();
query.type = "insert";
query.table = tableName;
query.setColumn( storageCollection.getLeft() + "_id", parent_id );
query.setColumn( storageCollection.getRight() + "_id", row_id );
database.query( query );
}
}
updateRenderCollection( object ) {
var clientObject = deepclone( object );
var storageCollection = object.storageCollection;
var leftTableName = storageCollection.parentName;
var rightTableName = storageCollection.parent.propertyName;
var tableName = leftTableName + "_" + rightTableName;
var parent_id = object.parent.id;
this.deleteByParentID( tableName, parent_id, storageCollection );
object.get( client );
for( var c = 0; c < object.rows.length; c++ ) {
var row = object.rows[c];
var clientValue = clientObject.rows[c].value;
this.updateRow( row, clientValue );
}
}
findParentTable( object ) {
if( object.type == "table" ) {
return object;
} else {
return this.findParentTable( object.parent );
}
}
updateColumn( object ) {
var table = this.findParentTable( object );
var query = new querySQL();
query.type = "update";
//console.log( table );
query.addObject( table );
database.query( query );
//this.objectManager.updateClient( object, client, eventName );
}
public update( object, client, eventName ) {
if( !object.isAllowed( client.user, "WRITE" ) ) {
object.deserialize();
return false;
}
if( object.type == "renderCollection" ) {
// For storageCollection selects and check buttons
this.updateRenderCollection( object );
} else {
this.updateColumn( object );
}
return object;
}
}

View File

@@ -0,0 +1,95 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
import tools from '../../unify/tools.js';
import querySQL from '../../unify/querySQL.js';
import Console from '../console.js';
import database from '../database.js';
import deepclone from '../../unify/clonedeep.js';
export default class objectController{
public async callNodeMethod( object, client, eventName ) {
console.log("called method", object.nodeMethodName, eventName);
var args = JSON.parse( object.nodeMethodArguments );
object.client = client;
var output = object[ eventName ]( args[0], args[1], args[2], args[3], args[4], args[5] );
delete object.client;
var out = await output;
if( !typeof out ) {
return object;
} else {
//console.log("output", out);
return out;
}
}
// Deprecated, Unsafe.
add( json, client, eventName ) {
/*
// todo : this is not save
var properties = JSON.parse( json );
var parentObject = tools.getObjectByPath( client.application, properties.parentApplicationPath );
var classObjects = client.classObjects;
var object = client.classObjects[ properties.className ];
var objectClone = deepclone( object );
parentObject[ properties.propertyName ] = objectClone;
objectClone.parent = parentObject;
objectClone.propertyName = properties.propertyName;
objectClone.id = properties.id;
*/
}
}

View File

@@ -0,0 +1,183 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
import tools from '../../unify/tools.js';
import querySQL from '../../unify/querySQL.js';
import Console from '../console.js';
import database from '../database.js';
import userManager from '../userManager.js';
import filemanager from '../filemanager.js';
import path from 'path';
import fs from 'fs';
var __dirname = path.resolve();
var files = new filemanager();
export default class settingsController{
public setType( object, client, eventName ) {
//console.log("set type", object);
switch( object ) {
case "debug":
client.type = "debug";
break;
}
}
removeClient( object, client, eventName ) {
//client.destroy();
//console.log( "removed client", client.id );
}
public getCacheDateTime() {
return fs.statSync( "./assets/cache/cache.js" ).mtime
}
public recreateCache( object ) {
console.log("object.performCacheUpdate = true;", object.getClassName());
object.performCacheUpdate = true;
}
public setVisibleElements( elements, client, eventName ) {
//console.log("setVisibleElements", elements);
global.visibleElements = elements.split(",");
}
public setTheme( themeProfileJSON ) {
var themeProfile = JSON.parse( themeProfileJSON );
console.log("setTheme", themeProfile );
global.os = tools.CamelCase( themeProfile.os );
global.device = tools.CamelCase( themeProfile.device );
global.tint = tools.CamelCase( themeProfile.tint );
}
debugObject( path, client, eventName ){
//Console.enableLog( path );
console.log( "enable debug object", path );
}
public signOut( cookieUser, client, eventName ) {
return userManager.signOut( cookieUser, client, eventName );
}
public signIn( cookieUser, client, eventName ) {
return userManager.signin( cookieUser, client );
}
deleteFile( file ) {
files.removeFile( __dirname + "/application/" + file.path + "/" + file.name );
files.removeFile( __dirname + "/framework/cache/" + file.path + "/" + file.name );
this.updateCache();
}
removeDirectory( file ) {
files.removeDir( __dirname + "/application/" + file.path + "/" );
files.removeDir( __dirname + "/framework/cache/" + file.path + "/" );
this.updateCache();
}
async updateCache() {
//await files.findApplicationFiles( "./application");
//global.applicationManager.applications = files.applications;
//console.log("updated applications", files.applications);
/*
await files.removeFiles( "./framework/cache/");
await files.removeDirectories( "./framework/cache/" );
await files.createDirectories();
await files.writeFiles();
*/
}
saveFile( file ) {
fs.writeFileSync( __dirname + "/application/" + file.path + "/" + file.name, file.source );
fs.writeFileSync( __dirname + "/framework/cache/" + file.path + "/" + file.name, files.parseSource( file.source) );
this.updateCache();
}
createDirectory( file ) {
console.log( "create directory", file );
files.createDir( __dirname + "/application/" + file.path );
files.createDir( __dirname + "/framework/cache/" + file.path );
}
}

View File

@@ -0,0 +1,300 @@
/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
import Console from '../console.js';
import tools from '../../unify/tools.js';
import database from '../database.js';
import shared from '../../unify/shared.js';
import userManager from '../userManager.js';
import defaultObject from '../../unify/defaultObject.js';
import consoleColors from '../../unify/consoleColors.js';
export default class tableController {
id = 3;
constructor() {
Console.setFilename("tableController.js");
}
getLastID() {
return ++this.id;
}
getParentObject( object ) {
if( object.type == "table" ) {
return object;
} else {
return object.parent;
}
}
public async save( object, client, eventName ) {
var parentObject = this.getParentObject( object );
if( !parentObject.isAllowed( client.user, "WRITE" ) ) {
parentObject = parentObject.deserialize();
return parentObject;
}
parentObject.signed.value = true;
if( parentObject.id == 0 || !parentObject.id ) {
var parentObject = this.create( parentObject, client, eventName );
} else {
parentObject.save();
}
//this.updateBidirectionalCollection( parentObject, collection, client, eventName );
return parentObject;
}
updateBidirectionalCollection( object, collection, client, eventName ) {
if( object.parent.getCollection ) {
var collection = object.parent.getCollection();
if( collection ) {
this.objectManager.updateClient( collection, client, eventName );
}
}
}
updateBidirectionalObject( object, client, eventName ) {
if( eventName ) {
this.objectManager.updateClient( object, client, eventName );
}
}
registerBidirectionalObject( object ) {
this.objectManager.registerObject( object, client );
var collection = object.getCollection();
if( collection ) {
this.objectManager.registerObject( collection, client );
}
}
public delete( object, client, eventName ) {
if( !object.isAllowed( client.user, "DELETE" ) ) {
object = object.deserialize();
return object;
}
var result = object.delete();
//this.updateBidirectionalCollection( object );
return object;
}
getObject( object, client, eventName ) {
if( object.preprocess ) {
object.preprocess( object, client, eventName );
}
//console.log("object.get");
object.get( client );
//console.log("//object.get");
if( object.process ) {
object.process( object, client, eventName );
}
}
public get( object, client, eventName ) {
object.updated = false;
if( !object.isAllowed( client.user, "READ" ) ) {
object.deserialize();
object.updateChildrenPermissions( object, client.user );
return object;
}
if( object.get ) {
if( object.type == "renderCollection" ) {
//console.log("clearCollection");
//object.removeChildren( );
//object.getChildrenRenderCollections( client );
}
this.getObject( object, client, eventName );
}
//this.registerBidirectionalObject( object );
return object;
}
insertObject( object, client ) {
var last_id = database.insertRow( object );
object.permissions = userManager.computePermissions( object, client.user );
object.id = last_id;
return object;
}
insertCollection( object, last_insert_id ) {
var collection = object.getCollection();
if( collection ) {
collection.addObject( object );
//if( !collection.id ) {
console.log("");
console.log(consoleColors.green( "create->insertCollection(" ), collection.id, last_insert_id, consoleColors.green(")") );
var parent_id = collection.parent.id;
var insert = collection.queryInsert( parent_id, last_insert_id );
//}
}
return insert;
}
public create( object, client, eventName ){
if( !object.isAllowed( client.user, "WRITE" ) ) {
object = object.deserialize();
return object;
}
object = this.insertObject( object, client );
//this.objectManager.registerObject( object, client );
this.insertCollection( object, object.id );
//console.log("return object", object);
return object;
}
public count( collection, client, eventName ) {
collection.count = collection.countRows();
if( collection.count == 0 ) {
collection.count = 0;
}
return collection;
}
}