diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 1832095..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,19 +0,0 @@ -pipeline { - agent any - - stages { - stage('[Neutral] - Déploiement') { - steps { - script { - - echo "[Neutral-Deploy] - Deploy Stage" - sh "ssh raphix@raphix.fr sudo apt update -y" - sh "ssh raphix@raphix.fr sudo apt upgrade -y" - sh "ssh raphix@raphix.fr sudo -S -u gitlab-ci /home/gitlab-ci/neutral_deploy.sh" - - } - - } - } - } -} \ No newline at end of file diff --git a/bin/auth.js b/bin/auth.js index 171e4c7..85560cf 100644 --- a/bin/auth.js +++ b/bin/auth.js @@ -34,7 +34,7 @@ module.exports.check = function(token) { } /** - * Permet de se connecter à Neutral + * Permet de se connecter à Inventory * @param {object} data * @returns Token or AUTH_FAILED */ diff --git a/bin/config.js b/bin/config.js index ef9e047..9aff90c 100644 --- a/bin/config.js +++ b/bin/config.js @@ -35,11 +35,6 @@ module.exports.updateFile = function (file) { } } -module.exports.getSettings = function () { - const file = this.getFile() - return {"jenkins_token": file.JENKINS_TOKEN, "omega_token": file.OMEGA_KEY} -} - module.exports.saveSettings = function (settings) { const file = this.getFile() file.JENKINS_TOKEN = settings.jenkins_token diff --git a/bin/files.js b/bin/files.js deleted file mode 100644 index 2cea76b..0000000 --- a/bin/files.js +++ /dev/null @@ -1,268 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -const { __glob } = require("./global-variables") -const clog = new LogType("Fichier") -const os = require("os"); -const uuid = require('uuid'); -var mime = require('mime-types'); - - -// check if shared folder exist, if not create it -if(!fs.existsSync(__glob.SHARED)) { - fs.mkdirSync(__glob.SHARED) -} - -module.exports.getFiles = function(root) { - - var response = new Object() - response.content = new Array() - - - try{ - - if(root == "homepath") { - - root = os.homedir() - - } - - if(root == "sharepath") { - - root = __glob.SHARED - - } - - if(root == "logpath") { - - root = __glob.LOGS - - } - - - if(!fs.existsSync(root)) { - response.content = "NOT_EXIST" - - } else { - - for(var file of fs.readdirSync(root)) { - - const stat = fs.statSync(root + path.sep + file) - - response.content.push({"name":file, id: uuid.v4().toString() ,"fileDirectory" : root + path.sep + file , "type":mime.lookup(file), "size":stat.size, "lastedition":stat.mtimeMs, "directory":stat.isDirectory()}) - } - - } - - - - - - }catch(err) { - - response.content = "NOT_PERMITTED" - } - - response.root = root - response.parent = path.dirname(root) - - - return response - -} - -module.exports.createFolder = function(root) { - - // Check if folder already exist - - if(!fs.existsSync(root)) { - - try { - fs.mkdirSync(root) - return "OK" - } catch(err) { - - return "NOT_PERMITTED" - } - - } else { - - return 'EXIST' - } - -} - -module.exports.deleteFile = function(root) { - - if(fs.existsSync(root)) { - - try { - - fs.rmSync(root, { recursive: true, force: true }) - return "OK" - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } else { - - return "NOT_EXIST" - } -} - -module.exports.renameFile = function(settings) { - - if(fs.existsSync(settings.root)) { - - try { - - fs.renameSync(settings.root + path.sep + settings.oldName, settings.root + path.sep + settings.newName) - return "OK" - } catch(err) { - - return "NOT_PERMITTED" - } - } else { - - return "NOT_EXIST" - } -} - -module.exports.shareFile = function(settings) { - - - if(fs.existsSync(settings.root)) { - - try { - //Create a sybolic link to shared folder - - fs.symlinkSync(settings.root + path.sep + settings.name, __glob.SHARED + path.sep + settings.name) - - // return the link of the file shared - if(process.env.DEV) { - return "http://localhost:3001/shared/" + settings.name - - } else { - return "https://neutral.raphix.fr/shared/" + settings.name - - } - - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } else { - - return "NOT_EXIST" - } -} - - -module.exports.getFile = function(root) { - - if(fs.existsSync(root)) { - - try { - - // Check if the file is an image and if it is return the base64 - if(mime.lookup(root).includes("image")) { - return "data:" + mime.lookup(root) + ";base64," + fs.readFileSync(root, "base64") - } else { - return fs.readFileSync(root, "utf-8") - } - - - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } else { - - return "NOT_EXIST" - } - -} - -module.exports.saveFile = function(settings) { - - try { - - fs.writeFileSync(settings.root + path.sep + settings.name, settings.content) - return "OK" - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } -} - -module.exports.downloadFile = function(root) { - - if(fs.existsSync(root)) { - - try { - - return fs.readFileSync(root) - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } else { - - return "NOT_EXIST" - } -} - - - -module.exports.uploadFile = function(settings) { - - try { - - fs.writeFileSync(settings.root + path.sep + settings.name, settings.file) - return "OK" - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } -} - -module.exports.newFile = function(settings) { - - if(!fs.existsSync(settings)) { - - try { - - fs.writeFileSync(settings, "") - return "OK" - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } else { - - return "EXIST" - } - } - -module.exports.pasteFile = function(settings) { - if(settings.action == "cut") { - - try { - - fs.renameSync(settings.file.fileDirectory, settings.newPath + path.sep + settings.name) - return "OK" - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } else if(settings.action == "copy") { - - try { - fs.copyFileSync(settings.file.fileDirectory, settings.newPath + path.sep + settings.name) - return "OK" - } catch(err) { - console.log(err) - return "NOT_PERMITTED" - } - } -} \ No newline at end of file diff --git a/bin/global-variables.js b/bin/global-variables.js index d563837..5a99b29 100644 --- a/bin/global-variables.js +++ b/bin/global-variables.js @@ -5,12 +5,9 @@ const __glob = { ROUTES: root + path.sep + "routes" + path.sep, ROOT: root, LOGS: root + path.sep + "logs", - ICON: root + path.sep + "public" + path.sep + 'images' + path.sep + "FormatLogo_WHITE.ico", DATA: root + path.sep + "data", USERS: root + path.sep + "data" + path.sep + "users.json", CONFIG: root + path.sep + "data" + path.sep + "config.json", - SHARED: root + path.sep + "data" + path.sep + "shared", - USERS_IMAGES: root + path.sep + "data" + path.sep + "user_images", PACKAGE_JSON: root + path.sep + "package.json", }; diff --git a/bin/links.js b/bin/links.js deleted file mode 100644 index 5850281..0000000 --- a/bin/links.js +++ /dev/null @@ -1,106 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -const { __glob } = require("./global-variables") -const ulog = new LogType("Links") -const uuid = require("uuid") -const config = require("./config") -const {ApplyLinks} = require("../routes/link") - - - -if(!fs.existsSync(__glob.DATA + path.sep + "links.json")) { - fs.writeFileSync(__glob.DATA + path.sep + "links.json", JSON.stringify([], null, 2)) -} - -module.exports.getLinks = function() { - return JSON.parse(fs.readFileSync(__glob.DATA + path.sep + "links.json")) -} - -const FirstLinkManager = new ApplyLinks(this.getLinks()) - - -module.exports.addLink = function(settings) { - - var canDo = true - const links = this.getLinks() - var id = makeid(8) - - if(settings.abstractLink) { - settings.dest = id.toString() - } - - - - // Check if a destination already exists between links and if it's the case, we return an error "ALREADY_EXiST" - links.forEach((link) => { - if(link.dest == settings.dest) { - - canDo = false - } - - }) - - const link = { - id: id, - title: settings.title, - url: settings.url, - dest: settings.dest, - } - - if(canDo) { - - links.push(link) - fs.writeFileSync(__glob.DATA + path.sep + "links.json", JSON.stringify(links, null, 2)) - const LinkManager = new ApplyLinks(this.getLinks()) - return "OK" - - } else { - - return "ALREADY_EXIST" - } - - -} - -module.exports.removeLink = function(id) { - const links = this.getLinks() - const newLinks = [] - links.forEach((link) => { - if(link.id != id) { - newLinks.push(link) - } - }) - fs.writeFileSync(__glob.DATA + path.sep + "links.json", JSON.stringify(newLinks, null, 2)) - const LinkManager = new ApplyLinks(this.getLinks()) - return "OK" -} - -module.exports.updateLink = function(id, settings) { - const links = this.getLinks() - const newLinks = [] - links.forEach((link) => { - if(link.id == id) { - link.title = settings.title - link.url = settings.url - } - newLinks.push(link) - }) - fs.writeFileSync(__glob.DATA + path.sep + "links.json", JSON.stringify(newLinks, null, 2)) - const LinkManager = new ApplyLinks(this.getLinks()) - return "OK" -} - - - -function makeid(length) { - let result = ''; - const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - const charactersLength = characters.length; - let counter = 0; - while (counter < length) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - counter += 1; - } - return result; -} diff --git a/bin/metrics.js b/bin/metrics.js deleted file mode 100644 index a492baf..0000000 --- a/bin/metrics.js +++ /dev/null @@ -1,128 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -var CryptoJS = require("crypto-js") -const { __glob } = require("./global-variables") -const { captureRejectionSymbol } = require("events") -const clog = new LogType("Metrics") - - -if(!fs.existsSync(__glob.DATA + path.sep + "metrics.json")) { - fs.writeFileSync(__glob.DATA + path.sep + "metrics.json", JSON.stringify([], null, 2)) -} - -module.exports.getDataMetrics = function() { - return JSON.parse(fs.readFileSync(__glob.DATA + path.sep + "metrics.json")) -} - -module.exports.getMetrics = function() { - - - - const metrics = this.getDataMetrics() - var metricsToReturn = new Array() - - return new Promise(async (resolve, reject) => { - - // Count the number processed - - var processed = 0 - - if(metrics.length == 0) { - resolve(metricsToReturn) - } - - await metrics.forEach(async (metric) => { - - // Try to connect to the metric server with the key in query params named "privatekey" - // If the connection is successful, we add the metric to the list of metrics to return - - const url = `http://${metric.address}:${metric.port}/metrics?privatekey=${metric.key}` - const fet = await fetch(url, { - method: "GET", - headers: { - "Accept": "application/json", - }, - credentials: "include" - }).then(res => res.json()) - .then(res => { - - if(res) { - metric.data = res - metricsToReturn.push(metric) - processed++ - } else { - metric.data = "ERROR" - metricsToReturn.push(metric) - } - - if(processed == metrics.length) { - resolve(metricsToReturn) - } - - }).catch((err) => { - metric.data = "ERROR" - metricsToReturn.push(metric) - processed++ - if(processed == metrics.length) { - resolve(metricsToReturn) - } - }) - - - - }) - - - - - - - - }) - -} - -module.exports.addMetric = function(settings) { - - const metrics = this.getDataMetrics() - - const metric = { - id: makeid(8), - name: settings.name, - address: settings.address, - port: settings.port, - key: settings.key, - } - - metrics.push(metric) - fs.writeFileSync(__glob.DATA + path.sep + "metrics.json", JSON.stringify(metrics, null, 2)) - return "OK" -} - -module.exports.deleteMetric = function(id) { - - const metrics = this.getDataMetrics() - - metrics.forEach((metric) => { - if(metric.id == id) { - metrics.splice(metrics.indexOf(metric), 1) - } - }) - - fs.writeFileSync(__glob.DATA + path.sep + "metrics.json", JSON.stringify(metrics, null, 2)) - return "OK" -} - - - -function makeid(length) { - var result = []; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result.push(characters.charAt(Math.floor(Math.random() * - charactersLength))); - } - return result.join(''); -} \ No newline at end of file diff --git a/bin/pipelines.js b/bin/pipelines.js deleted file mode 100644 index bb4dda6..0000000 --- a/bin/pipelines.js +++ /dev/null @@ -1,138 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -const { __glob } = require("./global-variables") -const clog = new LogType("Pïpeline") -const config = require("./config") - -const tokenkey = config.getFile().JENKINS_TOKEN - -module.exports.getAllPipelines = function() { - - return new Promise((resolve, reject) => { - - - fetch(`https://jenkins.raphix.fr/api/json`, { - method: "GET", - headers: { - "Accept": "application/json", - "Authorization": `Basic ${tokenkey}` - }, - credentials: "include" - }) - .then(res => res.json()) - .then(async list => { - - const pipelinesJobs = new Array() - - for(const job of list.jobs) { - await fetch(`${job.url}/api/json`, { - method: "GET", - headers: { - "Accept": "application/json", - "Authorization": `Basic ${tokenkey}` - }, - credentials: "include" - }) - .then(res => res.json()) - .then(async res => { - - if(res._class == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") { - await getJobMain(res).then(resJ => { - res.jobs[0] = resJ - pipelinesJobs.push(res) - }) - } else { - pipelinesJobs.push(res) - - } - - - }) - } - - list.jobs = pipelinesJobs - - resolve(list) - - - }) - .catch(err => { - resolve("UNAVAILABLE") - }) - }) - - -} - -module.exports.startPipeline = function(pipeline) { - - -// If it's a freestyle job, build with params - - if(pipeline.type == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") { - return new Promise((resolve, reject) => { - fetch(`${pipeline.url}/job/${pipeline.jobname}/build?delay=0sec`, { - method: "POST", - headers: { - "Authorization": `Basic ${tokenkey}` - }, - credentials: "include" - }) - .then(res => { - resolve("OK") - }) - }) - } else { - return new Promise((resolve, reject) => { - - const parameters = pipeline.fields - - const formatedParams = new URLSearchParams() - - for(const param of parameters) { - formatedParams.append(param.name, param.value) - } - - - - - fetch(`${pipeline.url}/buildWithParameters?delay=0sec`, { - method: "POST", - headers: { - "Authorization": `Basic ${tokenkey}`, - "Content-Type": "application/x-www-form-urlencoded" - }, - credentials: "include", - body: formatedParams - }) - .then(res => { - resolve("OK") - }) - }) - } - - - -} - -function getJobMain(res) { - - return new Promise(async (resolve, reject) => { - - await fetch(`${res.jobs[0].url}/api/json`, { - method: "GET", - headers: { - 'Accept': 'application/json', - 'Authorization': `Basic ${tokenkey}` - }, - credentials: 'include' - }).then(res => res.json()) - .then(res => { - resolve(res) - }) - - - }) - -} diff --git a/bin/server-metrics.js b/bin/server-metrics.js deleted file mode 100644 index 5ac68b9..0000000 --- a/bin/server-metrics.js +++ /dev/null @@ -1,74 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -const { __glob } = require("./global-variables") -const clog = new LogType("Serveur Metrics") -const osutils = require("os-utils") -const os = require("os") -const { statfs } = require("fs") -const config = require("./config") - - - -module.exports.getMetrics = async function(server) { - - return new Promise((resolve, reject) => { - if(server == "Alpha") { - var resp = "NULL" - const space = statfs("/", (err, stats) => { - if (err) { - throw err - } - - - - osutils.cpuUsage(function(cpuUsage) { - resp = { - cpu: Math.round(cpuUsage * 1000), - usedram: osutils.totalmem() - osutils.freemem(), - totalram: osutils.totalmem(), - usedisk: stats.blocks - stats.bfree, - totaldisk: stats.blocks, - name: server - } - - resolve(resp) - - - }) - - }) - - - } else if(server == "Omega") { - - const key = config.getFile().OMEGA_KEY; - - fetch("http://omega.raphix.fr:4000/metrics?key="+key, { - method: "GET", - headers: { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7", - "Cache-Control": "no-cache", - "Connection": "keep-alive" - } - }) - .then(response => response.json()) - .then(raw => { - raw.name = server; - resolve(raw); - }) - .catch(error => { - - reject(error); - }); - - - - } - - }) - - -} \ No newline at end of file diff --git a/bin/servers.js b/bin/servers.js deleted file mode 100644 index 54c0609..0000000 --- a/bin/servers.js +++ /dev/null @@ -1,296 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -const { __glob } = require("./global-variables.js") -const auth = require("./auth.js") -const users = require("./users.js") -const files = require("./files.js") -const config = require("./config.js") -const links = require("./links.js") -const service = require("./services.js") -const pipeline = require("./pipelines.js") -const plog = new LogType("Web") -const cook = require("cookie") -const http = require("http") -const servermetrics = require("./server-metrics.js") -const metrics = require("./metrics.js") -const pm2 = require('pm2'); - -/** - * NOTE INTERNE - * - * Changer les pictures de users autre part - */ - -/** - * - * @param {http.Server} server - */ - -module.exports.serverIO = function(server) { - - const io = require('socket.io')(server, { - maxHttpBufferSize: 1e8, - pingTimeout: 60000 - }) - - - io.on("connection", (socket) => { - - let token = cook.parse(socket.handshake.headers.cookie).token - var user = auth.getUserByToken(token) - - if(user) { - plog.log("Connexion au panel par '" + user.username + "' avec le socket : " + socket.id) - user.setLastLogin(new Date()) - /** - * GET REQUEST - */ - - // Get Users - GetRequest("USERINFO", () => { - user = auth.getUserByToken(token) - GetAnswer("USERINFO", {username: user.username, display_name: user.display_name ,picture: user.picture, permission: user.permission}) - }) - - /** - * POST REQUEST - */ - - PostRequest("US_EDIT_PERSONNAL", async (settings) => { - user = auth.getUserByToken(token) - PostAnswer("US_EDIT_PERSONNAL", await users.editMySelf(settings, user)) - }) - - if(user.checkPermission("FILES_EXPLORER")) { - - PostRequest("FX_GET", (root) => { - - PostAnswer("FX_GET", files.getFiles(root)) - }) - - PostRequest("FX_NEW_FOLDER", (root) => { - - PostAnswer("FX_NEW_FOLDER", files.createFolder(root)) - }) - - PostRequest("FX_DELETE", (root) => { - - PostAnswer("FX_DELETE", files.deleteFile(root)) - } ) - - PostRequest("FX_RENAME", (settings) => { - - PostAnswer("FX_RENAME", files.renameFile(settings)) - }) - - PostRequest("FX_SHARE", (settings) => { - - PostAnswer("FX_SHARE", files.shareFile(settings)) - }) - - PostRequest("FX_GETFILE", (root) => { - - PostAnswer("FX_GETFILE", files.getFile(root)) - }) - - PostRequest("FX_SAVEFILE", (settings) => { - - PostAnswer("FX_SAVEFILE", files.saveFile(settings)) - }) - - PostRequest("FX_NEW_FILE", (settings) => { - - PostAnswer("FX_NEW_FILE", files.newFile(settings)) - }) - - PostRequest("FX_UPLOAD", (settings) => { - - PostAnswer("FX_UPLOAD", files.uploadFile(settings)) - - }) - - PostRequest("FX_PASTE", (settings) => { - - PostAnswer("FX_PASTE", files.pasteFile(settings)) - }) - - } - - if(user.checkPermission("SERVICES")) { - - PostRequest("SV_GET_SERVICE_STATUS", async (sv) => { - PostAnswer("SV_GET_SERVICE_STATUS", {answer: await service.getServiceStatus(sv), name: sv}) - }) - - PostRequest("SV_START_SERVICE", async (sv) => { - PostAnswer("SV_START_SERVICE", {answer: await service.startService(sv), name: sv}) - }) - - PostRequest("SV_STOP_SERVICE", async (sv) => { - PostAnswer("SV_STOP_SERVICE", {answer: await service.stopService(sv), name: sv}) - }) - - PostRequest("SV_RESTART_SERVICE", async (sv) => { - PostAnswer("SV_RESTART_SERVICE", {answer: await service.restartService(sv), name: sv}) - }) - - } - - if(user.checkPermission("LINKS")) { - PostRequest("LINKS_GET_ALL", () => { - PostAnswer("LINKS_GET_ALL", {answer: "OK", links: links.getLinks()}) - }) - - PostRequest("LINKS_ADD", (settings) => { - PostAnswer("LINKS_ADD", {answer: links.addLink(settings)}) - }) - - PostRequest("LINKS_DELETE", (id) => { - PostAnswer("LINKS_DELETE", links.removeLink(id)) - }) - - PostRequest("LINKS_EDIT", (settings) => { - PostAnswer("LINKS_EDIT", links.updateLink(settings.id, settings)) - }) - - - } - - if(user.checkPermission("SERVERS")) { - PostRequest("SERVER_GET_METRICS_Alpha", async (settings) => { - PostAnswer("SERVER_GET_METRICS_Alpha", {answer: "OK", metrics: await servermetrics.getMetrics(settings), name: settings}); - }); - PostRequest("SERVER_GET_METRICS_Omega", async (settings) => { - PostAnswer("SERVER_GET_METRICS_Omega", {answer: "OK", metrics: await servermetrics.getMetrics(settings), name: settings}); - }); - } - - if(user.checkPermission("PIPELINES")) { - GetRequest("PL_GET_ALL", async () => { - GetAnswer("PL_GET_ALL", await pipeline.getAllPipelines()) - }) - - PostRequest("PL_START", async (settings) => { - PostAnswer("PL_START", await pipeline.startPipeline(settings)) - }) - - } - - if(user.checkPermission("USERS")) { - GetRequest("US_ALL", async () => { - GetAnswer("US_ALL", await users.getAllUsers()) - }) - - PostRequest("US_ADD", async (settings) => { - PostAnswer("US_ADD", await users.addUser(settings)) - }) - - PostRequest("US_DELETE", async (settings) => { - PostAnswer("US_DELETE", await users.deleteUser(settings)) - }) - - PostRequest("US_EDIT", async (settings) => { - PostAnswer("US_EDIT", await users.editUser(settings)) - }) - - PostRequest("US_CLEAR_TOKENS", async (settings) => { - - PostAnswer("US_CLEAR_TOKENS", await users.clearTokens(settings)) - }) - } - - if(user.checkPermission("SETTINGS")) { - PostRequest("SETTINGS_SAVE", async (settings) => { - PostAnswer("SETTINGS_SAVE", await config.saveSettings(settings)) - }) - PostRequest("SERVER_RESTART", async () => { - pm2.restart('Neutral') - }) - PostRequest("SERVER_STOP", async () => { - pm2.stop('Neutral') - }) - GetRequest("SERVER_GET_LOGS", async () => { - GetAnswer("SERVER_GET_LOGS", await fs.readdirSync(__glob.LOGS)) - }) - - PostRequest("SERVER_READ_LOG", async (logs) => { - PostAnswer("SERVER_READ_LOG", await fs.readFileSync(__glob.LOGS + path.sep + logs).toString()) - }) - - GetRequest("SETTINGS_GET", async () => { - GetAnswer("SETTINGS_GET", await config.getSettings()) - }) - } - - if(user.checkPermission("METRICS")) { - GetRequest("MT_ALL", async () => { - GetAnswer("MT_ALL", await metrics.getMetrics()) - }) - - PostRequest("MT_ADD", async (settings) => { - PostAnswer("MT_ADD", await metrics.addMetric(settings)) - }) - - PostRequest("MT_DELETE", async (settings) => { - PostAnswer("MT_DELETE", await metrics.deleteMetric(settings)) - }) - - - } - - - socket.on("disconnect", (reason) => { - plog.log("Déconnexion du panel par '" + user.username + "' avec le socket : " + socket.id) - }) - - socket.on("connect_error", (err) => { - console.log(err) - console.log(err.message); // prints the message associated with the error - }); - - function GetRequest(GQname, GQcallback) { - socket.on("GET/" + GQname, () => { - - plog.log(user.username + " - Socket : " + socket.id + " - GET/" + GQname + " - [RECIEVED]") - GQcallback() - }) - - } - - function GetAnswer(GRname, GRvalue) { - - plog.log(user.username + " - Socket : " + socket.id + " - GET/" + GRname + " - [ANSWERED]") - socket.emit("ANSWER/GET/" + GRname, GRvalue) - - } - - function PostRequest(GQname, GQcallback) { - socket.on("POST/" + GQname, (value) => { - plog.log(user.username + " - Socket : " + socket.id + " - POST/" + GQname + " - [RECIEVED]") - GQcallback(value) - }) - - } - - function PostAnswer(GRname, GRvalue) { - - plog.log(user.username + " - Socket : " + socket.id + " - POST/" + GRname + " - [ANSWERED]") - socket.emit("ANSWER/POST/" + GRname, GRvalue) - - } - - } else { - - socket.disconnect() - plog.warn("Connexion directe vers le panel avec un token inexistant : " + this.token) - } - - - - - - }) - - -} diff --git a/bin/services.js b/bin/services.js deleted file mode 100644 index 4449405..0000000 --- a/bin/services.js +++ /dev/null @@ -1,137 +0,0 @@ -const { LogType } = require("loguix") -const fs = require("fs") -const path = require("path") -const { __glob } = require("./global-variables") -const clog = new LogType("Services") - -const http = require('http'); -const https = require('https'); - -module.exports.getServiceStatus = function(service) { - const protocol = service.startsWith('https') ? https : http; - const url = new URL(service); - const options = { - method: 'HEAD', - host: url.hostname, - port: url.port, - path: url.pathname, - }; - - return new Promise((resolve, reject) => { - const req = protocol.request(options, (res) => { - if(res.statusCode !== 502) { - resolve("ONLINE"); - } else { - - resolve("OFFLINE"); - } - - }); - - req.on('error', (err) => { - resolve("OFFLINE"); - }); - - req.end(); - }); -} - -module.exports.stopService = function(service) { - - - return new Promise((resolve, reject) => { - - const child_process = require('child_process'); - if(service == `https://subsonics.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 stop "Subsonics"'`) - resolve("OK") - } else if(service == `https://git.raphix.fr` ) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl stop gitea`) - resolve("OK") - } else if(service == `https://jenkins.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl stop jenkins `) - resolve("OK") - - } else if(service == `https://raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 stop "Website - Raphix"'`) - resolve("OK") - } else if(service == `https://cv.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 stop "CV - Raphael"'`) - resolve("OK") - } else if(service == `http://omega.raphix.fr:2333`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl stop lavalink `) - resolve("OK") - } else { - resolve(false) - } - - }); - -} - -module.exports.startService = function(service) { - - - return new Promise((resolve, reject) => { - - const child_process = require('child_process'); - if(service == `https://subsonics.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 start /home/gitlab-ci/subsonic.config.js'`) - resolve("OK") - - } else if(service == `https://git.raphix.fr` ) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl start gitea`) - resolve("OK") - } else if(service == `https://jenkins.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl start jenkins `) - resolve("OK") - - } else if(service == `https://raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 start /home/gitlab-ci/website.config.js'`) - resolve("OK") - } else if(service == `https://cv.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 start /home/gitlab-ci/cv.config.js'`) - resolve("OK") - } else if(service == `http://omega.raphix.fr:2333`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl start lavalink `) - resolve("OK") - } else { - resolve(false) - } - - }); - -} - -module.exports.restartService = function(service) { - - - return new Promise((resolve, reject) => { - - const child_process = require('child_process'); - if(service == `https://subsonics.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 restart "Subsonics"'`) - resolve("OK") - } else if(service == `https://git.raphix.fr` ) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl restart gitea`) - resolve("OK") - } else if(service == `https://jenkins.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl restart jenkins `) - resolve("OK") - - } else if(service == `https://raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 restart "Website - Raphix"'`) - resolve("OK") - } else if(service == `https://cv.raphix.fr`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@alpha.raphix.fr sudo -S -u gitlab-ci 'pm2 restart "CV - Raphael"'`) - resolve("OK") - } else if(service == `http://omega.raphix.fr:2333`) { - let req = child_process.exec(`ssh -o StrictHostKeyChecking=no raphix@omega.raphix.fr sudo -S systemctl restart lavalink `) - resolve("OK") - } else { - resolve(false) - } - - }); - -} \ No newline at end of file diff --git a/bin/users.js b/bin/users.js index f45874d..65f22bc 100644 --- a/bin/users.js +++ b/bin/users.js @@ -50,10 +50,8 @@ module.exports.fetchUsers = function () { username: userFetched.username, password: userFetched.password, display_name: userFetched.display_name, - permission: userFetched.permission, tokens: userFetched.tokens, lastLogin: userFetched.lastLogin, - picture: userFetched.picture }) @@ -63,21 +61,10 @@ module.exports.fetchUsers = function () { if(usersList.size == 0) { const adminUser = new this.User({ "username": "admin", - "password": "neutral", + "password": "inventory", "display_name": "Administrateur", - "permission": [ - "FILES_EXPLORER", - "SERVICES", - "SERVERS", - "PIPELINES", - "METRICS", - "USERS", - "LINKS", - "SETTINGS" - ], "tokens": [], "lastLogin": "DEFAULT ACCOUNT", - "picture": "/images/default.jpg" }) @@ -94,16 +81,14 @@ module.exports.fetchUsers = function () { /** * User Class is used to access to default user's properties and methods - * @param {object} properties User properties with : username, password, display_name, permission... + * @param {object} properties User properties with : username, password, display_name */ module.exports.User = class { username = null password = null; display_name = null - permission = [] tokens = [] lastLogin = new Date() - picture = "/images/default.jpg" constructor(properties) { @@ -112,10 +97,8 @@ module.exports.User = class { this.username = properties.username this.password = keygen.encrypt(properties.password) this.display_name = properties.display_name - this.permission = properties.permission this.tokens = properties.tokens this.lastLogin = properties.lastLogin - this.picture = properties.picture const userFile = getFile() @@ -125,7 +108,6 @@ module.exports.User = class { this.username = userFetched.username this.password = userFetched.password this.display_name = userFetched.display_name - this.permission = userFetched.permission this.tokens = userFetched.tokens this.lastLogin = userFetched.lastLogin } @@ -150,22 +132,14 @@ module.exports.User = class { ulog.warn("'" + this.username + "' is without display name !") this.display_name = this.username } - if(this.permission == null) { - ulog.warn("'" + this.username + "' has no longer permission !") - } if(this.tokens == null) { this.tokens = [] } - if(this.permission == null) { - this.permission = [] - } if(this.lastLogin == null) { this.lastLogin = new Date() } - if(this.picture == null) { - this.picture = "/images/default.jpg" - } + } @@ -211,47 +185,7 @@ module.exports.User = class { usersList.delete(this.username) } - checkPermission(name) { - this.#sync() - if(this.permission.includes(name)) { - return true - } else { - return false - } - - } - - addPermission(name) { - this.#sync() - for(var perms of this.permission) { - if(name == perms) { - ulog.warn("'" + this.username + "' a déjà la permission : " + name) - return false - } - } - this.permission.push(name) - this.register() - } - - removePermission(name) { - this.#sync() - var havePermission = false - for(var perms of this.permission) { - if(name == perms) { - havePermission = true - } - } - if(havePermission) { - this.permission.splice(this.permission.indexOf(name), 1) - this.register() - } else { - - ulog.warn("'" + this.username + "' n'a pas la permission : " + name) - return false - } - - } setPassword(newPassword) { this.#sync() @@ -293,14 +227,6 @@ module.exports.User = class { } - setPicture(text) { - this.#sync() - this.picture = text - this.register() - ulog.log("La photo de l'utilisateur a été modifié : " + this.username) - - } - setDisplayName(text) { this.#sync() this.display_name = text @@ -325,24 +251,6 @@ module.exports.User = class { this.register() } - setPicture(file) { - this.#sync() - var pictureDir = __glob.USERS_IMAGES + path.sep + uuid.v4().toString() + ".png" - if(!fs.existsSync(__glob.USERS_IMAGES)) { - fs.mkdirSync(__glob.USERS_IMAGES) - } - fs.writeFileSync(pictureDir, file) - - this.picture = pictureDir.replace(__glob.USERS_IMAGES + path.sep, "/users/") - this.register() - } - - setPermissions(permissions) { - this.#sync() - this.permission = permissions - this.register() - } - clearTokens() { this.#sync() this.tokens = [] @@ -357,7 +265,6 @@ module.exports.User = class { this.username = userFetched.username this.password = userFetched.password this.display_name = userFetched.display_name - this.permission = userFetched.permission this.tokens = userFetched.tokens this.lastLogin = userFetched.lastLogin } @@ -382,23 +289,10 @@ module.exports.addUser = function(settings) { return "ALREADY_EXIST" } else { ulog.step.init("add_user", "Ajout d'un utilisateur dans la base de donnée : " + settings.username) - var pictureDir = null - - - if(settings.picture == null) { - pictureDir = "/images/default.jpg" - } else { - pictureDir = __glob.USERS_IMAGES + path.sep + uuid.v4().toString() + ".png" - fs.writeFileSync(pictureDir, settings.picture) - - - } const user = new this.User({ username: settings.username, - display_name: settings.display_name, - permission: settings.permissions, - picture: pictureDir.replace(__glob.USERS_IMAGES + path.sep, "/images/users/") + display_name: settings.display_name }) @@ -451,13 +345,8 @@ module.exports.editUser = function(settings) { user.setPassword(settings.password) } - if(settings.picture) { - user.setPicture(settings.picture) - } - if(settings.permissions) { - - user.setPermissions(settings.permissions) - } + + ulog.step.end("edit_user") return "OK" } else { @@ -497,10 +386,7 @@ module.exports.editMySelf = function (settings, user) { if(settings.password) { user.setPassword(settings.password) } - - if(settings.picture) { - user.setPicture(settings.picture) - } + ulog.step.end("edit_user") return "OK" } else { diff --git a/bin/www b/bin/www index aeb5560..2e472b8 100644 --- a/bin/www +++ b/bin/www @@ -20,13 +20,12 @@ wlog.step.init("start_server", "Démarrage du serveur Express JS") var app = require('../main'); var http = require('http'); var config = require("./config") -var serverIO = require("./servers") /** * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '3001'); +var port = normalizePort(process.env.PORT || '5005'); app.set('port', port); /** @@ -34,7 +33,6 @@ app.set('port', port); */ var server = http.createServer(app); -serverIO.serverIO(server) /** * Listen on provided port, on all network interfaces. diff --git a/main.js b/main.js index 5a258c0..4ed962d 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,7 @@ const createError = require('http-errors'); const express = require('express'); const path = require('path'); const cookieParser = require('cookie-parser'); -var favicon = require('serve-favicon'); +var favicon = require('express-favicon'); const app = express(); const fs = require("fs"); const log = require("loguix") @@ -47,8 +47,6 @@ function setup() { app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))) - app.use("/shared", express.static(__glob.SHARED)) - app.use("/users", express.static(__glob.USERS_IMAGES)) getRouters() diff --git a/package-lock.json b/package-lock.json index e358e81..ccc8599 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "neutral", - "version": "0.7.0", + "name": "inventory", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "neutral", - "version": "0.7.0", + "name": "inventory", + "version": "1.0.0", "license": "ISC", "dependencies": { "cookie-parser": "~1.4.4", @@ -14,14 +14,12 @@ "debug": "~2.6.9", "ejs": "~2.6.1", "express": "~4.16.1", + "express-favicon": "^2.0.4", "http-errors": "~1.6.3", - "install": "^0.13.0", "loguix": "^1.4.2", "nodemon": "^3.0.1", "os-utils": "^0.0.14", "pm2": "^5.3.0", - "serve-favicon": "^2.0.4", - "socket.io": "^4.7.2", "uuid": "^9.0.1" } }, @@ -294,32 +292,10 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/@socket.io/component-emitter": { - "version": "3.1.0", - "license": "MIT" - }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "license": "MIT" }, - "node_modules/@types/cookie": { - "version": "0.4.1", - "license": "MIT" - }, - "node_modules/@types/cors": { - "version": "2.8.15", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/node": { - "version": "20.8.10", - "license": "MIT", - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/abbrev": { "version": "1.1.1", "license": "ISC" @@ -468,13 +444,6 @@ "version": "1.0.2", "license": "MIT" }, - "node_modules/base64id": { - "version": "2.0.0", - "license": "MIT", - "engines": { - "node": "^4.5.0 || >= 5.9" - } - }, "node_modules/basic-ftp": { "version": "5.0.4", "license": "MIT", @@ -683,17 +652,6 @@ "version": "1.0.6", "license": "MIT" }, - "node_modules/cors": { - "version": "2.8.5", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/croner": { "version": "4.1.97", "license": "MIT" @@ -772,51 +730,6 @@ "node": ">= 0.8" } }, - "node_modules/engine.io": { - "version": "6.5.3", - "license": "MIT", - "dependencies": { - "@types/cookie": "^0.4.1", - "@types/cors": "^2.8.12", - "@types/node": ">=10.0.0", - "accepts": "~1.3.4", - "base64id": "2.0.0", - "cookie": "~0.4.1", - "cors": "~2.8.5", - "debug": "~4.3.1", - "engine.io-parser": "~5.2.1", - "ws": "~8.11.0" - }, - "engines": { - "node": ">=10.2.0" - } - }, - "node_modules/engine.io-parser": { - "version": "5.2.1", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/engine.io/node_modules/debug": { - "version": "4.3.4", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/engine.io/node_modules/ms": { - "version": "2.1.2", - "license": "MIT" - }, "node_modules/enquirer": { "version": "2.3.6", "license": "MIT", @@ -935,6 +848,15 @@ "node": ">= 0.10.0" } }, + "node_modules/express-favicon": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/express-favicon/-/express-favicon-2.0.4.tgz", + "integrity": "sha512-JDGzumJdwF+WcJf+qwyhdpF1yzducuMCxZa+G6hxR3hor7ae/1CqpAPj8FXCGaGtqBA6ExDMfeszjuYRw5GUuQ==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/express/node_modules/cookie": { "version": "0.3.1", "license": "MIT", @@ -1223,13 +1145,6 @@ "version": "1.3.8", "license": "ISC" }, - "node_modules/install": { - "version": "0.13.0", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/ip": { "version": "1.1.8", "license": "MIT" @@ -1523,13 +1438,6 @@ "version": "0.4.14", "license": "MIT" }, - "node_modules/object-assign": { - "version": "4.1.1", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/on-finished": { "version": "2.3.0", "license": "MIT", @@ -2099,28 +2007,6 @@ "node": ">= 0.8.0" } }, - "node_modules/serve-favicon": { - "version": "2.5.0", - "license": "MIT", - "dependencies": { - "etag": "~1.8.1", - "fresh": "0.5.2", - "ms": "2.1.1", - "parseurl": "~1.3.2", - "safe-buffer": "5.1.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/serve-favicon/node_modules/ms": { - "version": "2.1.1", - "license": "MIT" - }, - "node_modules/serve-favicon/node_modules/safe-buffer": { - "version": "5.1.1", - "license": "MIT" - }, "node_modules/serve-static": { "version": "1.13.2", "license": "MIT", @@ -2164,78 +2050,6 @@ "npm": ">= 3.0.0" } }, - "node_modules/socket.io": { - "version": "4.7.2", - "license": "MIT", - "dependencies": { - "accepts": "~1.3.4", - "base64id": "~2.0.0", - "cors": "~2.8.5", - "debug": "~4.3.2", - "engine.io": "~6.5.2", - "socket.io-adapter": "~2.5.2", - "socket.io-parser": "~4.2.4" - }, - "engines": { - "node": ">=10.2.0" - } - }, - "node_modules/socket.io-adapter": { - "version": "2.5.2", - "license": "MIT", - "dependencies": { - "ws": "~8.11.0" - } - }, - "node_modules/socket.io-parser": { - "version": "4.2.4", - "license": "MIT", - "dependencies": { - "@socket.io/component-emitter": "~3.1.0", - "debug": "~4.3.1" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/socket.io-parser/node_modules/debug": { - "version": "4.3.4", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/socket.io-parser/node_modules/ms": { - "version": "2.1.2", - "license": "MIT" - }, - "node_modules/socket.io/node_modules/debug": { - "version": "4.3.4", - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/socket.io/node_modules/ms": { - "version": "2.1.2", - "license": "MIT" - }, "node_modules/socks": { "version": "2.7.1", "license": "MIT", @@ -2417,10 +2231,6 @@ "version": "2.0.5", "license": "MIT" }, - "node_modules/undici-types": { - "version": "5.26.5", - "license": "MIT" - }, "node_modules/universalify": { "version": "0.1.2", "license": "MIT", @@ -2484,25 +2294,6 @@ "version": "1.0.2", "license": "ISC" }, - "node_modules/ws": { - "version": "8.11.0", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/yallist": { "version": "4.0.0", "license": "ISC" diff --git a/package.json b/package.json index 430c07d..7d3b34e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "neutral", - "version": "1.1.0", - "description": "Panel d'administration de Raphix", + "name": "inventory", + "version": "1.0.0", + "description": "Gestion de veteements", "main": "index.js", "scripts": { "start": "nodemon ./bin/www", @@ -9,7 +9,7 @@ }, "repository": { "type": "git", - "url": "https://git.raphix.fr/infrastructure/neutral.git" + "url": "https://git.raphix.fr/raphix/inventory.git" }, "nodemonConfig": { "ext": "js, html", @@ -26,13 +26,11 @@ "ejs": "~2.6.1", "express": "~4.16.1", "http-errors": "~1.6.3", - "install": "^0.13.0", "loguix": "^1.4.2", "nodemon": "^3.0.1", - "os-utils": "^0.0.14", + "os-utils": "^0.0.14" "pm2": "^5.3.0", - "serve-favicon": "^2.0.4", - "socket.io": "^4.7.2", + "express-favicon": "^2.0.4", "uuid": "^9.0.1" }, "author": "Raphix", diff --git a/public/images/FontLogo.png b/public/images/FontLogo.png deleted file mode 100644 index 4a93ad1..0000000 Binary files a/public/images/FontLogo.png and /dev/null differ diff --git a/public/images/FormatLogo_BLACK.png b/public/images/FormatLogo_BLACK.png deleted file mode 100644 index b78d4e2..0000000 Binary files a/public/images/FormatLogo_BLACK.png and /dev/null differ diff --git a/public/images/FormatLogo_BLACK.svg b/public/images/FormatLogo_BLACK.svg deleted file mode 100644 index dada85b..0000000 --- a/public/images/FormatLogo_BLACK.svg +++ /dev/null @@ -1,50 +0,0 @@ - - \ No newline at end of file diff --git a/public/images/FormatLogo_WHITE.ico b/public/images/FormatLogo_WHITE.ico deleted file mode 100644 index 87d1dc9..0000000 Binary files a/public/images/FormatLogo_WHITE.ico and /dev/null differ diff --git a/public/images/FormatLogo_WHITE.png b/public/images/FormatLogo_WHITE.png deleted file mode 100644 index 7c8d0bf..0000000 Binary files a/public/images/FormatLogo_WHITE.png and /dev/null differ diff --git a/public/images/FormatLogo_WHITE.svg b/public/images/FormatLogo_WHITE.svg deleted file mode 100644 index fca4d89..0000000 --- a/public/images/FormatLogo_WHITE.svg +++ /dev/null @@ -1,50 +0,0 @@ - - \ No newline at end of file diff --git a/public/images/default.jpg b/public/images/default.jpg deleted file mode 100644 index 4a93ad1..0000000 Binary files a/public/images/default.jpg and /dev/null differ diff --git a/public/images/services/cv.png b/public/images/services/cv.png deleted file mode 100644 index 0070038..0000000 Binary files a/public/images/services/cv.png and /dev/null differ diff --git a/public/images/services/gitea.svg b/public/images/services/gitea.svg deleted file mode 100644 index ae433ce..0000000 --- a/public/images/services/gitea.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/images/services/jenkins.svg b/public/images/services/jenkins.svg deleted file mode 100644 index 988991c..0000000 --- a/public/images/services/jenkins.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/images/services/lavalink.svg b/public/images/services/lavalink.svg deleted file mode 100644 index 63fa153..0000000 --- a/public/images/services/lavalink.svg +++ /dev/null @@ -1,48 +0,0 @@ - - diff --git a/public/images/services/raphix.png b/public/images/services/raphix.png deleted file mode 100644 index ca99963..0000000 Binary files a/public/images/services/raphix.png and /dev/null differ diff --git a/public/images/services/subsonics.png b/public/images/services/subsonics.png deleted file mode 100644 index 20cf698..0000000 Binary files a/public/images/services/subsonics.png and /dev/null differ diff --git a/public/javascripts/basics.js b/public/javascripts/basics.js deleted file mode 100644 index 37784f5..0000000 --- a/public/javascripts/basics.js +++ /dev/null @@ -1,1332 +0,0 @@ - -var xMousePos = null; -var yMousePos = null; - -document.onmousemove = function(e) { - xMousePos = e.clientX + window.scrollX; - yMousePos = e.clientY + window.scrollY; - -} - -document.oncontextmenu = function(e) { - - xMousePos = e.clientX + window.scrollX; - yMousePos = e.clientY + window.scrollY; - -} - -/** - * Récupère depuis le document l'identifiant de l'élément - * @param {string} id Identifiant de l'élément `id='identifiant'` - * @returns - */ -function getID(id) { - - return document.getElementById(id) -} - -/** - * - * @param {Date} GetDate - * @returns - */ -function getFormattedDate(GetDate) { - - const date = new Date(GetDate) - - var gmonth = date.getMonth() + 1 - var gday = date.getDate() - var gHour = date.getHours() - var gMinute = date.getMinutes() - var gSecondes = date.getSeconds() - - - if(date.getMonth() + 1 < 10) { - gmonth = "0" + (date.getMonth() + 1) - } - - if(date.getDate() + 1 <= 10) { - gday = "0" + date.getDate() - } - - if(date.getHours() + 1 <= 10) { - gHour = "0" + date.getHours() - } - - if(date.getMinutes() + 1 <= 10) { - gMinute = "0" + date.getMinutes() - } - - if(date.getSeconds() + 1 <= 10) { - gSecondes = "0" + date.getSeconds() - } - - return gday + "/" + gmonth + "/" + date.getFullYear() + " - " + gHour + ":" + gMinute -} - - -/** - * Permet de faire une pop-up automatique - */ -class TextResponse { - constructor(name) { - this.name = name - this.element = getID(this.name) - this.element.innerHTML = " " - this.element.style.fontSize = "14px" - this.element.style.textAlign = "center" - } - - clear() { - - this.element.innerHTML = " " - } - - err(text) { - - this.element.classList.add("yellow") - this.element.innerHTML = " " + text - - } - - info(text) { - - this.element.classList.remove("yellow") - - this.element.innerHTML = " " + text - } - - setSize(size) { - - this.element.style.fontSize = size - } - - setWidth(width) { - this.element.style.width = width - } - - -} - - -const AllViews = new Map() -var zIndex = 5 - - - -/** - * Permet de créer une fenêtre - * @param {object} properties Propriétés de la fenêtre - */ -class ViewWindow { - ViewHTML = null - ViewWindowDiv - ViewProperties = null - ViewSpanInteger = null - ViewPopupSpanInteger = null - ViewPopupHTML = null - ViewPopupTitle = null - ViewItem = new ViewItem(this) - constructor (properties) { - if(!AllViews.has(properties.title)) { - - this.ViewProperties = properties - AllViews.set(properties.title, true) - - - - this.ViewHTML = ` -
${properties.title}
-${this.name}
-${this.name}
- -${this.description}
-RAM
--- Mo / -- Mo
-CPU
----%
-DISK
--- Go / -- Go
-${this.description}
-Etat : Vérification en cours ...
-${this.name}
- -Construction en cours ... - N°${this.pipe.nextBuildNumber - 1}
` - if(this.pipe.lastSuccessfulBuild) { - if(this.pipe.lastSuccessfulBuild.number == this.pipe.nextBuildNumber - 1) { - lastBuildStatus = `Dernière construction réussie - N°${this.pipe.nextBuildNumber - 1}
` - } - - } - if(this.pipe.lastFailedBuild) { - if(this.pipe.lastFailedBuild.number == this.pipe.nextBuildNumber - 1) { - lastBuildStatus = `Dernière construction échouée - N°${this.pipe.nextBuildNumber - 1}
` - } - - } - - - } else { - lastBuildStatus = `Aucune construction
` - } - - - // TRUE : lastBuildStatus = `Dernière construction réussie - N°${this.pipe.jobs[0].lastSuccessfulBuild.number}
` - // BUILDING : lastBuildStatus = `Construction en cours ... - N°${this.pipe.nextBuildNumber - 1}
` - // FAILED : lastBuildStatus = `Dernière construction échouée - N°${this.pipe.jobs[0].nextBuildNumber - 1}
` - // NOITHING : lastBuildStatus = `Aucune construction
` - } else { - - image = `` - if(this.pipe.jobs[0].lastBuild) { - lastBuildStatus = `Construction en cours ... - N°${this.pipe.jobs[0].nextBuildNumber - 1}
` - if(this.pipe.jobs[0].lastSuccessfulBuild) { - if(this.pipe.jobs[0].lastSuccessfulBuild.number == this.pipe.jobs[0].nextBuildNumber - 1) { - lastBuildStatus = `Dernière construction réussie - N°${this.pipe.jobs[0].nextBuildNumber - 1}
` - } - - } - if(this.pipe.jobs[0].lastFailedBuild) { - if(this.pipe.jobs[0].lastFailedBuild.number == this.pipe.jobs[0].nextBuildNumber - 1) { - lastBuildStatus = `Dernière construction échouée - N°${this.pipe.jobs[0].nextBuildNumber - 1}
` - } - - } - - - } else { - lastBuildStatus = `Aucune construction
` - } - - - - } - - return ` - - ` - } - - - loadScript() { - - const powerButton = getID(`${this.name}_pipelinepower`) - - powerButton.addEventListener("click", () => { - if(this.class == "hudson.model.FreeStyleProject" && this.pipe.property[0].parameterDefinitions.length > 0) { - - var allProperties = new Array() - - for(const property of this.pipe.property[0].parameterDefinitions) { - console.log(property) - if(property.type == "StringParameterDefinition") { - allProperties.push("" + property.name + "
") - } - if(property.type == "ChoiceParameterDefinition") { - - var options = new Array() - for(const option of property.choices) { - options.push(``) - } - - allProperties.push("" + property.name + "
") - } - } - - - - this.View.createPopup({ - title: ` Démarrer la pipeline`, - content: ` - -${this.name}
- - - - ` - }) - - const startButton = getID(`${this.name}_start`) - const info = new TextResponse("pl-power-info") - - startButton.addEventListener("click", () => { - info.clear() - - - var allFields = new Array() - - for(const property of this.pipe.property[0].parameterDefinitions) { - - - if(getID(property.name).value == "") { - info.err("Veuillez remplir tous les champs") - return - } - allFields.push({name: property.name,value: getID(property.name).value} ) - - } - - const request = post(`PL_START`, {name: this.name, fields: allFields, url: this.url, type: this.class}) - - request.then((answer) => { - - if(answer == "OK") { - info.info("La pipeline a été démarrée avec succès") - this.View.destroyPopup() - - } else { - info.err("Impossible de démarrer la pipeline") - - } - }) - - }) - - - - } else { - - // Open a confirmation popup to start the pipeline - - this.View.createPopup({ - title: ` Démarrer la pipeline`, - content: ` - -${this.name}
- - - ` - }) - - const startButton = getID(`${this.name}_start`) - const info = new TextResponse("pl-power-info") - - startButton.addEventListener("click", () => { - info.clear() - const request = post(`PL_START`, {name: this.name, url: this.url, type: this.class, jobname: this.pipe.jobs[0].name}) - - request.then((answer) => { - console.log(answer) - if(answer == "OK") { - info.info("La pipeline a été démarrée avec succès") - this.View.destroyPopup() - - } else { - info.err("Impossible de démarrer la pipeline") - - } - }) - - }) - - } - }) - } - -} - -class User { - constructor(properties) { - this.username = properties.username - this.display_name = properties.display_name - this.picture = properties.picture - this.permission = properties.permission - this.View = properties.window - this.Component = properties.component - } - - generateHTML() { - return ` -${this.display_name}
- -${this.display_name}
- -Nom d'utilisateur
- -Nom d'affichage
- -Mot de passe
- -Permissions
- -Photo de profil
- -Voulez-vous vraiment supprimer l'utilisateur ${this.username} ?
- - - - ` - }) - - const deleteCButton = getID(`${this.username}_deleteconfirm`) - - deleteCButton.addEventListener("click", () => { - const request = post(`US_DELETE`, this.username) - request.then((answer) => { - if(answer == "OK") { - this.View.destroyPopup() - this.View.destroy() - this.Component.forceWindow() - } else { - console.log(answer) - } - }) - }) - }) - } - - } -} - -/** - * Permet de créer un composant de vue de type "Metrics" - */ -class Metric { - properties; - View; - Component; - data; - constructor(settings) { - this.properties = settings.properties - this.View = settings.View - this.Component = settings.Component - this.data = settings.properties.data - } - - generateHTML() { - return ` -${this.properties.name}
-${this.properties.id}
-Impossible de charger les données de la métrique
` - - } else { - for(const data of this.data) { - contentDiv.innerHTML += `${data.description}
${data.name}
Valeur : ${data.value}
Voulez-vous vraiment supprimer la métrique ${this.properties.name} ?
- - - - ` - }) - - const deleteCButton = getID(`${this.properties.id}_deleteconfirm`) - - deleteCButton.addEventListener("click", () => { - const request = post(`MT_DELETE`, this.properties.id) - request.then((answer) => { - if(answer == "OK") { - this.View.destroyPopup() - this.View.destroy() - this.Component.forceWindow() - - } else { - console.log(answer) - } - }) - }) - }) - } - - - -} - -/** - * Permet de créer un item de la barre des tâches - * @param {ViewWindow} window ViewWindow associé à l'item - */ -class ViewItem { - /** - * - * @param {ViewWindow} window - */ - constructor(window) { - this.window = window - } - - show() { - const viewItems = getID("views-items") - const item = document.createElement("div") - item.id = `${this.window.ViewProperties.title}_item` - item.classList.add("view-item") - item.innerHTML = this.window.ViewProperties.title - - viewItems.appendChild(item) - - item.addEventListener("click", () => { - zIndex+=1 - this.window.ViewWindowDiv.style.zIndex = zIndex + 1 - this.window.ViewWindowDiv.style.display = "unset" - }) - - item.addEventListener("contextmenu", () => { - const dp = new DroppableMenu() - - dp.add("index", ` Afficher`) - dp.add("close", ` `) - dp.show() - - const index = dp.get("index") - const close = dp.get("close") - - index.addEventListener("click", () => { - zIndex+=1 - this.window.ViewWindowDiv.style.display = "unset" - this.window.ViewWindowDiv.style.zIndex = zIndex + 1 - dp.hide() - }) - - close.addEventListener("click", () => { - this.window.destroy() - dp.hide() - }) - - }) - - } - - hide() { - const viewItems = getID("views-items") - const item = getID(`${this.window.ViewProperties.title}_item`) - - item.outerHTML = "" - } - -} - diff --git a/public/javascripts/filexplorer.js b/public/javascripts/filexplorer.js deleted file mode 100644 index bb3e59c..0000000 --- a/public/javascripts/filexplorer.js +++ /dev/null @@ -1,786 +0,0 @@ -document.addEventListener("contextmenu", (e) => { - - e.preventDefault() -}) - -explorer.createWindow(() => { - - var inCopyOrCut = null; - - const View = new ViewWindow({ - title: ` Gestionnaire de fichiers`, - width: "1000px", - height: "600px" - }) - - - - - - - goHomePath() - function goHomePath() { - const rFiles = post("FX_GET", "homepath") - - rFiles.then((result) => { - loadFiles(result) - }) - } - - function goSharePath() { - const rFiles = post("FX_GET", "sharepath") - - rFiles.then((result) => { - loadFiles(result) - }) - } - - - - - View.setContent(` -Chargement en cours ...
-Vous n'avez pas les permissions pour coller ce fichier.
` - }) - } else { - const reqFiles = post("FX_GET", rootInput.value) - reqFiles.then((result) => { - loadFiles(result) - }) - View.createPopup({ - title: ` Erreur`, - content: `Une erreur est survenue.
` - }) - } - }) - - inCopyOrCut = null - }) - } else { - console.log("LISTENER : " + rootInput.value) - - } - - }) - - home.addEventListener("click", () => { - - goHomePath() - - }) - - sharebtn.addEventListener("click", () => { - - goSharePath() - - }) - - - newFolder.addEventListener("click", () => { - - View.createPopup({ - title: ` Nouveau dossier`, - content: ` - - - - `}) - - const foldername = getID(View.getViewTitle() + "_foldername") - const foldercreate = getID(View.getViewTitle() + "_foldercreate") - const folderInfo = new TextResponse(View.getViewTitle() + "_folderInfo") - - folderInfo.setSize("13px") - - - foldercreate.addEventListener("click", () => { - folderInfo.clear() - if(foldername.value.length < 1) { - folderInfo.err("Le nom du dossier est trop court.") - return - } - - const regex = new RegExp(/^[a-zA-Z0-9-_]+$/) - - if(!regex.test(foldername.value) | foldername.value.replace(/\s/g, '').length < 1) { - folderInfo.err("Le nom du dossier est invalide.") - return - } - - const reqFiles = post("FX_NEW_FOLDER", rootInput.value + "/" + foldername.value) - reqFiles.then((result) => { - if(result == "OK") { - View.destroyPopup(` Nouveau dossier`) - const reqFiles = post("FX_GET", rootInput.value) - reqFiles.then((result) => { - loadFiles(result) - }) - } else if(result == "EXIST") { - folderInfo.err("Le dossier existe déjà.") - } else if(result == "NOT_PERMITTED") { - folderInfo.err("Vous n'avez pas les permissions pour créer un dossier ici.") - } else { - folderInfo.err("Une erreur est survenue.") - } - }) - - - }) - - - - }) - - - // Create a new file with a popup wth 2 options, upload or create, if create give a input name or if upload, upload a file - - newFile.addEventListener("click", () => { - - View.createPopup({ - title: ` Nouveau fichier`, - content: ` - - - - - `}) - - const filename = getID(View.getViewTitle() + "_filename") - const filecreate = getID(View.getViewTitle() + "_filecreate") - const fileupload = getID(View.getViewTitle() + "_fileupload") - const fileInfo = new TextResponse(View.getViewTitle() + "_fileInfo") - - fileInfo.setSize("13px") - - filecreate.addEventListener("click", () => { - - fileInfo.clear() - if(filename.value.length < 1) { - fileInfo.err("Le nom du fichier est trop court.") - return - } - - const regex = new RegExp(/^[a-zA-Z0-9-_.]+$/) - - if(!regex.test(filename.value) | filename.value.replace(/\s/g, '').length < 1) { - fileInfo.err("Le nom du fichier est invalide.") - return - } - - const reqFiles = post("FX_NEW_FILE", rootInput.value + "/" + filename.value) - reqFiles.then((result) => { - if(result == "OK") { - View.destroyPopup(` Nouveau fichier`) - const reqFiles = post("FX_GET", rootInput.value) - reqFiles.then((result) => { - loadFiles(result) - }) - } else if(result == "EXIST") { - fileInfo.err("Le fichier existe déjà.") - } else if(result == "NOT_PERMITTED") { - fileInfo.err("Vous n'avez pas les permissions pour créer un fichier ici.") - } else { - fileInfo.err("Une erreur est survenue.") - } - }) - - - }) - - fileupload.addEventListener("click", () => { - - fileInfo.clear() - View.destroyPopup(` Nouveau fichier`) - View.createPopup({ - title: ` Upload`, - content: ` - - - - `}) - - const fileuploadInput = getID(View.getViewTitle() + "_fileuploadInput") - const fileuploadBtn = getID(View.getViewTitle() + "_fileuploadBtn") - const fileuploadInfo = new TextResponse(View.getViewTitle() + "_fileuploadInfo") - - fileuploadBtn.addEventListener("click", () => { - - fileuploadInfo.clear() - if(fileuploadInput.files.length < 1) { - fileuploadInfo.err("Aucun fichier sélectionné.") - return - } - - const file = fileuploadInput.files[0] - console.log(file) - - const reqFiles = post("FX_UPLOAD", {name: file.name ,root: rootInput.value, file: file}) - - reqFiles.then((result) => { - - if(result == "OK") { - View.destroyPopup(` Upload`) - const reqFiles = post("FX_GET", rootInput.value) - reqFiles.then((result) => { - loadFiles(result) - }) - } - if(result == "EXIST") { - fileuploadInfo.err("Le fichier existe déjà.") - } - if(result == "NOT_PERMITTED") { - fileuploadInfo.err("Vous n'avez pas les permissions pour uploader un fichier ici.") - } - if(result == "NOT_FILE") { - fileuploadInfo.err("Le fichier n'est pas valide.") - } - if(result == "NOT_EXIST") { - fileuploadInfo.err("Le fichier n'existe pas.") - } - if(result == "TOO_BIG") { - fileuploadInfo.err("Le fichier est trop volumineux.") - } - if(result == "ERROR") { - fileuploadInfo.err("Une erreur est survenue.") - } - }) - }) - }) - }) - - - - rootInput.addEventListener("change", () => { - - const reqFiles = post("FX_GET", rootInput.value) - reqFiles.then((result) => { - loadFiles(result) - - }) - }) - - function loadFiles(files) { - - rootInput.value = files.root - var fileElements = new Array() - - if(files.content == "NOT_PERMITTED") { - fileElements.unshift(`Revenir au dossier parent
Vous n'avez pas les permissions pour accéder à ce dossier.
") - - } else if(files.content == "NOT_EXIST") { - fileElements.unshift(`Revenir au dossier parent
Ce dossier n'existe pas.
" - } else { - - - for(const file of files.content) { - - if(file.directory) { - file.size = "Dossier" - - } else { - console.log('------------') - console.log(file.size) - console.log(bytesToSize(file.size)) - console.log('------------') - file.size = bytesToSize(file.size) - } - - fileElements.push(`${file.name}
-Taille : ${file.size}
-Date de modification : ${getFormattedDate(file.lastedition)}
-Revenir au dossier parent
Vous n'avez pas les permissions pour supprimer ce fichier.
` - }) - } else { - const reqFiles = post("FX_GET", files.root) - reqFiles.then((result) => { - loadFiles(result) - }) - View.createPopup({ - title: ` Erreur`, - content: `Une erreur est survenue.
` - }) - - } - }) - }) - dropMenu.get("rename").addEventListener("click", () => { - - dropMenu.hide() - View.createPopup({ - title: ` Renommer`, - content: ` - - - - `}) - - const rename = getID(View.getViewTitle() + "_rename") - const renameBtn = getID(View.getViewTitle() + "_renameBtn") - const renameInfo = new TextResponse(View.getViewTitle() + "_renameInfo") - renameInfo.setSize("13px") - rename.value = file.name - rename.focus() - rename.select() - - renameBtn.addEventListener("click", () => { - renameInfo.clear() - if(rename.value.length < 1) { - renameInfo.err("Le nom du fichier / dossier est trop court.") - return - } - - const regex = new RegExp(/^[a-zA-Z0-9-_.]+$/) - - if(!regex.test(rename.value) | rename.value.replace(/\s/g, '').length < 1) { - renameInfo.err("Le nom du fichier / dossier est invalide.") - return - } - - const reqFiles = post("FX_RENAME", {root: files.root, oldName: file.name, newName: rename.value}) - reqFiles.then((result) => { - if(result == "OK") { - View.destroyPopup(` Renommer`) - const reqFiles = post("FX_GET", files.root) - reqFiles.then((result) => { - loadFiles(result) - }) - } else if(result == "EXIST") { - renameInfo.err("Le fichier / dossier existe déjà.") - } else if(result == "NOT_PERMITTED") { - renameInfo.err("Vous n'avez pas les permissions pour renommer ce fichier / dossier.") - } else { - renameInfo.err("Une erreur est survenue.") - } - }) - - }) - - }) - - if(!file.directory) { - dropMenu.get("share").addEventListener("click", () => { - dropMenu.hide() - const reqFiles = post("FX_SHARE", {root: files.root, name: file.name}) - reqFiles.then((result) => { - if(result == "NOT_PERMITTED") { - View.createPopup({ - title: ` Erreur`, - content: `Vous n'avez pas les permissions pour partager ce fichier.
` - }) - } else { - View.createPopup({ - title: ` Partager`, - content: ` - - - - `}) - - const sharelink = getID(View.getViewTitle() + "_sharelink") - const shareBtn = getID(View.getViewTitle() + "_shareBtn") - const shareInfo = new TextResponse(View.getViewTitle() + "_shareInfo") - shareInfo.setSize("13px") - sharelink.value = result - sharelink.focus() - sharelink.select() - - shareBtn.addEventListener("click", () => { - sharelink.focus() - sharelink.select() - window.navigator.clipboard.writeText(sharelink.value) - shareInfo.ok("Copié !") - }) - } - }) - }) - // Edit file with an ViewWindow with 2 options close & save and the name of the window is like File - Editor - - dropMenu.get("edit").addEventListener("click", () => { - dropMenu.hide() - - editFile() - - }) - - dropMenu.get("download").addEventListener("click", () => { - dropMenu.hide() - const reqFiles = post("FX_GETFILE", file.fileDirectory) - reqFiles.then((result) => { - if(result == "NOT_PERMITTED") { - View.createPopup({ - title: ` Erreur`, - content: `Vous n'avez pas les permissions pour télécharger ce fichier.
` - }) - } else { - // Make Download using result - - const element = document.createElement('a'); - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(result)); - element.setAttribute('download', file.name); - element.style.display = 'none'; - document.body.appendChild(element); - element.click(); - document.body.removeChild(element); - } - }) - }) - - - - } - - }) - - - - - - function editFile() { - const reqFiles = post("FX_GETFILE", file.fileDirectory) - //Create a popup for the loading - - View.createPopup({ - title: ` Editeur`, - content: `Chargement en cours ...
` - }) - - reqFiles.then((result) => { - View.destroyPopup(` Editeur}`) - if(result == "NOT_PERMITTED") { - View.createPopup({ - title: ` Erreur`, - content: `Vous n'avez pas les permissions pour éditer ce fichier.
` - }) - } else { - const editor = new ViewWindow({ - title: ` Editeur - ${file.fileDirectory}`, - width: "1000px", - height: "650px" - }) - - - if(file.type == "image/png" | file.type == "image/jpeg") { - editor.setContent(` -Vous n'avez pas les permissions pour éditer ce fichier.
` - }) - } else { - editor.createPopup({ - title: ` Erreur`, - content: `Une erreur est survenue.
` - }) - } - }) - }) - - - - //forbid textarea resize - editorContent.style.resize = "none" - - - } - - - } - - }) - } - - } - - - } - - } - - - -}) - - -function getIcon(file) { - if(file.type == "application/json") { - - return '' - } - if(file.type == "application/msword" | file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") { - - return '' - } - if(file.type == "application/vnd.ms-powerpoint") { - - return '' - } - if(file.type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | file.type == "application/vnd.ms-excel") { - - return '' - } - - if(file.type == "application/java-archive") { - - return '' - } - - if(file.type == "application/x-sh") { - - return '' - } - - if(file.type == "application/x-msdos-program" | file.type == "application/x-msdownload") { - - return'' - } - if(file.type == "application/javascript") { - - return '' - } - if(file.type == "image/png" | file.type == "image/jpeg") { - - return '' - } - if(file.type == "text/html") { - - return '' - } - if(file.type == "text/css") { - - return '' - } - if(file.type == "application/zip") { - - return '' - } - if(file.type == "audio/mpeg") { - - return '' - } - if(file.type == "application/pdf") { - - return '' - } - if(file.directory) { - - return '' - } else { - - return '' - } - -} - -function bytesToSize(bytes) { - var sizes = ['o', 'Ko', 'Mo', 'Go', 'To']; - if (bytes == 0) return '0 o'; - var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); - return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i]; -} \ No newline at end of file diff --git a/public/javascripts/indexscript.js b/public/javascripts/indexscript.js deleted file mode 100644 index 450226b..0000000 --- a/public/javascripts/indexscript.js +++ /dev/null @@ -1,68 +0,0 @@ - - - -// User Request - -loadUserInfo() - - -function loadUserInfo() { - - - const infoUsername = getID("infoUsername") - const infoUserimage = getID("infoUserimage") - const infoDisplayname = getID("infoDisplayname") - const views = getID("views") - const panelBox = getID("panel-box") - - const REQ_user = get("USERINFO") - - REQ_user.then((ANS_user) => { - console.log(ANS_user) - infoUserimage.src = ANS_user.picture - infoUsername.innerHTML = ANS_user.username - infoDisplayname.innerHTML = ANS_user.display_name - - const permissions = ANS_user.permission - - const AvailableViews = new Array() - // - permissions.forEach((permValue) => { - - AllComponents.forEach((component) => { - if(component.permission == permValue) { - component.inject(AvailableViews) - } - }) - - - }) - - - if(AvailableViews.join("") == "") { - - AvailableViews.push(" Aucune permission ne semble vous êtes accordée
Demandez à Raphix afin de résoudre ce problème
Chargement en cours ...
-Abstraire le lien :
- -Aucun lien disponible
` - } - - answer.links.forEach((link) => { - - links.push(link) - - }) - - links.forEach((link) => { - - linksDiv.innerHTML += ` -${link.title}
-Lien original : ${link.url}
-Lien modifié : https://neutral.raphix.fr/link/${link.dest}
-Impossible de supprimer le lien
- ` - }) - - - } else { - - getLinks() - } - - }) - - }) - }) - - } else { - - info.err("Impossible de récupérer les liens") - - } - - - - }) - } - - -}) \ No newline at end of file diff --git a/public/javascripts/loginscript.js b/public/javascripts/loginscript.js deleted file mode 100644 index 57b78e0..0000000 --- a/public/javascripts/loginscript.js +++ /dev/null @@ -1,67 +0,0 @@ -const username = getID("username") -const password = getID("password") -const submit = getID("submit") - -const loginInfo = new TextResponse("login-info") - -loginInfo.clear() - -submit.addEventListener("click", () => { - - if(!username.value) { - - loginInfo.err("Un nom d'utilisateur est nécéssaire pour se connecter !") - - } else if(!password.value) { - - loginInfo.err("Un mot de passe est nécéssaire pour se connecter !") - } else { - - - login() - } -}) - -password.addEventListener("keyup", (event) => { - if (event.key === "Enter") { - login() - } -}); - -function login() { - - loginInfo.clear() - - fetch('/login', { - method: 'POST', - redirect: 'follow', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - username: username.value, - password: password.value - }) - }) - .then(response => redirect(response)) - - async function redirect(response) { - - response = await response.text() - - if(response == "AUTH_FAILED") { - - - loginInfo.err("Le nom d'utilisateur et le mot de passe sont incorrects.") - - } else if(response == "AUTH_SUCCESS") { - - window.location.href = "/" - - } - - - - } -} diff --git a/public/javascripts/metric.js b/public/javascripts/metric.js deleted file mode 100644 index 1378214..0000000 --- a/public/javascripts/metric.js +++ /dev/null @@ -1,144 +0,0 @@ -metrics.createWindow(() => { - - const View = new ViewWindow({ - title: ` Web Metrik`, - width: "600px", - height: "600px", - }) - - loadMetrics() - - function loadMetrics() { - - View.setContent(` -Chargement en cours ...
-Aucune WebMetrik n'a été ajoutée
-Une erreur est survenue lors du chargement des WebMetrik
-Adresse
- -Port
- -Nom
- -Clé d'authentification
- - - -Une erreur est survenue lors de l'ajout de la WebMetrik
` - }) - } - }) - }) - - }) - - - } -}) - - - - /* -Chargement en cours ...
-Mes informations
-Nom d'utilisateur
- -Nom d'affichage
- -Mot de passe
- -Photo de profil
- - - - -Mes permissions
-" + permValue + "
") - - }) - - usSettingsPermissions.innerHTML = permValid.join("") - }) - - usSettingsSave.addEventListener("click", () => { - const request = post(`US_EDIT_PERSONNAL`, {username: actualUsername, newusername: usSettingsUsername.value, display_name: usSettingsDisplayname.value, password: usSettingsPassword.value, picture: usSettingsPicture.files[0]}) - request.then((answer) => { - if(answer == "ALREADY_EXIST") { - - returnInfo.err("L'utilisateur existe déjà !") - - } else if(answer == "USERNAME_MISSING") { - - returnInfo.err("Le nom d'utilisateur est manquant !") - } else if(answer == "DISPLAY_NAME_MISSING") { - - returnInfo.err("Le nom d'affichage est manquant !") - } else if(answer == "PASSWORD_MISSING") { - - returnInfo.err("Le mot de passe est manquant !") - } else { - - View.destroy() - loadUserInfo() - } - }) - }) - - -}) - -document.addEventListener("click", (e) => { - if(e.target != menulogo) { - menu.style.display = "none" - } -}) \ No newline at end of file diff --git a/public/javascripts/pipeline.js b/public/javascripts/pipeline.js deleted file mode 100644 index 2e9fbfd..0000000 --- a/public/javascripts/pipeline.js +++ /dev/null @@ -1,66 +0,0 @@ -pipelines.createWindow(() => { - - const View = new ViewWindow({ - title: ` Gestion des pipelines`, - width: "900px", - height: "600px" - }) - - const pipelinesList = new Array() - - View.setContent(`Chargement en cours ...
-Chargement en cours ...
-Une erreur est survenue lors du chargement des pipelines
-Alpha
-RAM
-1.5 Go / 2 Go
-CPU
-1.5 Go / 2 Go
-DISK
-1.5 Go / 2 Go
-Options d'alimentation
- -Configuration des Tokens
-Jenkins
- -Omega
- - -Accès aux logs
- - -${newLogLines.join("")}-
Chargement en cours ...
-Nom d'utilisateur
- -Nom d'affichage
- -Mot de passe
- -Permissions
- - -Photo de profil
- - - - -Neutral
Aucune permission ne semble vous êtes accordée
Demandez à Raphix afin de résoudre ce problème
Neutral
Nom d'utilisateur
- -Mot de passe
- -Version : <%- version %>
-Panel d'administration
- Revenir sur raphix.fr -