184 lines
3.6 KiB
JavaScript
184 lines
3.6 KiB
JavaScript
/*
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|