diff --git a/bin/config.js b/bin/config.js index ef9e047..2e48d25 100644 --- a/bin/config.js +++ b/bin/config.js @@ -37,12 +37,11 @@ module.exports.updateFile = function (file) { module.exports.getSettings = function () { const file = this.getFile() - return {"jenkins_token": file.JENKINS_TOKEN, "omega_token": file.OMEGA_KEY} + return {"omega_token": file.OMEGA_KEY} } module.exports.saveSettings = function (settings) { const file = this.getFile() - file.JENKINS_TOKEN = settings.jenkins_token file.OMEGA_KEY = settings.omega_token this.updateFile(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/servers.js b/bin/servers.js index 54c0609..3bd519b 100644 --- a/bin/servers.js +++ b/bin/servers.js @@ -8,7 +8,6 @@ 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") @@ -166,16 +165,6 @@ module.exports.serverIO = function(server) { }); } - 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 () => { diff --git a/package.json b/package.json index 6471c9d..506a119 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neutral", - "version": "1.0.3", + "version": "1.0.4", "description": "Panel d'administration de Raphix", "main": "index.js", "scripts": { diff --git a/public/javascripts/pipeline.js b/public/javascripts/DEPREACTED-pipeline.js similarity index 100% rename from public/javascripts/pipeline.js rename to public/javascripts/DEPREACTED-pipeline.js diff --git a/public/javascripts/basics.js b/public/javascripts/basics.js index 37784f5..f2607e6 100644 --- a/public/javascripts/basics.js +++ b/public/javascripts/basics.js @@ -733,10 +733,12 @@ class Service { } -/** + +/* + * Permet de créer un composant de vue de type "Pipeline" * @param {object} properties Propriétés du composant de vue - */ + class Pipeline { name; @@ -954,6 +956,8 @@ class Pipeline { } +*/ + class User { constructor(properties) { this.username = properties.username @@ -1027,10 +1031,7 @@ class User { -
Configuration des Tokens
-Jenkins
-Omega
@@ -93,11 +91,9 @@ settings.createWindow(async () => { const restartButton = document.getElementById("st-restart") const stopButton = document.getElementById("st-stop") const saveButton = document.getElementById("st-save") - const jenkinsToken = document.getElementById("jenkins_token") const omegaToken = document.getElementById("omega_token") get("SETTINGS_GET").then((settings) => { - jenkinsToken.value = settings.jenkins_token omegaToken.value = settings.omega_token }) @@ -111,12 +107,11 @@ settings.createWindow(async () => { saveButton.addEventListener("click", () => { post("SETTINGS_SAVE", { - jenkins_token: jenkinsToken.value, omega_token: omegaToken.value }) get("SETTINGS_GET").then((settings) => { - jenkinsToken.value = settings.jenkins_token + omegaToken.value = settings.omega_token }) }) diff --git a/public/javascripts/user.js b/public/javascripts/user.js index 8a20bd8..0e9a100 100644 --- a/public/javascripts/user.js +++ b/public/javascripts/user.js @@ -61,10 +61,7 @@ users.createWindow(async () => {