Version 1.0.1 - Fix de WebMetrics et de l'édit utilisateur
All checks were successful
Neutral/pipeline/head This commit looks good
All checks were successful
Neutral/pipeline/head This commit looks good
This commit is contained in:
parent
3484ff9ff7
commit
377c3310e4
@ -28,13 +28,17 @@ module.exports.getMetrics = function() {
|
|||||||
|
|
||||||
var processed = 0
|
var processed = 0
|
||||||
|
|
||||||
|
if(metrics.length == 0) {
|
||||||
|
resolve(metricsToReturn)
|
||||||
|
}
|
||||||
|
|
||||||
await metrics.forEach(async (metric) => {
|
await metrics.forEach(async (metric) => {
|
||||||
|
|
||||||
// Try to connect to the metric server with the key in query params named "privatekey"
|
// 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
|
// 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 url = `http://${metric.address}:${metric.port}/metrics?privatekey=${metric.key}`
|
||||||
const res = await fetch(url, {
|
const fet = await fetch(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
@ -46,23 +50,35 @@ module.exports.getMetrics = function() {
|
|||||||
if(res) {
|
if(res) {
|
||||||
metric.data = res
|
metric.data = res
|
||||||
metricsToReturn.push(metric)
|
metricsToReturn.push(metric)
|
||||||
|
processed++
|
||||||
} else {
|
} else {
|
||||||
metric.data = "ERROR"
|
metric.data = "ERROR"
|
||||||
metricsToReturn.push(metric)
|
metricsToReturn.push(metric)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(processed == metrics.length) {
|
||||||
|
resolve(metricsToReturn)
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch((err) => {
|
||||||
|
metric.data = "ERROR"
|
||||||
|
metricsToReturn.push(metric)
|
||||||
|
processed++
|
||||||
|
if(processed == metrics.length) {
|
||||||
|
resolve(metricsToReturn)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
processed++
|
|
||||||
|
|
||||||
if(processed == metrics.length) {
|
|
||||||
resolve(metricsToReturn)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,9 @@ module.exports.User = class {
|
|||||||
setPicture(file) {
|
setPicture(file) {
|
||||||
this.#sync()
|
this.#sync()
|
||||||
var pictureDir = __glob.USERS_IMAGES + path.sep + uuid.v4().toString() + ".png"
|
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)
|
fs.writeFileSync(pictureDir, file)
|
||||||
|
|
||||||
this.picture = pictureDir.replace(__glob.USERS_IMAGES + path.sep, "/users/")
|
this.picture = pictureDir.replace(__glob.USERS_IMAGES + path.sep, "/users/")
|
||||||
@ -430,7 +433,7 @@ module.exports.editUser = function(settings) {
|
|||||||
ulog.step.init("edit_user", "Modification d'un utilisateur dans la base de donnée : " + settings.username)
|
ulog.step.init("edit_user", "Modification d'un utilisateur dans la base de donnée : " + settings.username)
|
||||||
const user = this.fetchUsers().get(settings.username)
|
const user = this.fetchUsers().get(settings.username)
|
||||||
if(user) {
|
if(user) {
|
||||||
console.log(settings)
|
|
||||||
if(settings.newusername && settings.newusername != settings.username) {
|
if(settings.newusername && settings.newusername != settings.username) {
|
||||||
if(this.getUser(settings.newusername)) {
|
if(this.getUser(settings.newusername)) {
|
||||||
ulog.error("L'utilisateur existe déjà : " + settings.username)
|
ulog.error("L'utilisateur existe déjà : " + settings.username)
|
||||||
@ -466,7 +469,7 @@ module.exports.editUser = function(settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports.editMySelf = function (settings, user) {
|
module.exports.editMySelf = function (settings, user) {
|
||||||
if(user.username == settings.actualUsername) {
|
if(user.username == settings.username) {
|
||||||
if(settings.username == '') {
|
if(settings.username == '') {
|
||||||
ulog.error("Le nom d'utilisateur est manquant")
|
ulog.error("Le nom d'utilisateur est manquant")
|
||||||
return "USERNAME_MISSING"
|
return "USERNAME_MISSING"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "neutral",
|
"name": "neutral",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "Panel d'administration de Raphix",
|
"description": "Panel d'administration de Raphix",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1221,11 +1221,17 @@ class Metric {
|
|||||||
|
|
||||||
const contentDiv = getID(`${this.properties.id}_content`)
|
const contentDiv = getID(`${this.properties.id}_content`)
|
||||||
|
|
||||||
for(const data of this.data) {
|
if(this.data == "ERROR") {
|
||||||
contentDiv.innerHTML += `<div class='metric-data'><div class='metric-data-div'><p class='metric-data-title'>${data.description}</p><p class='metric-data-id'>${data.name}</p></div><p class='metric-data-value'>Valeur : <span>${data.value}<span></p></div>`
|
contentDiv.innerHTML += `<p class='metric-error'>Impossible de charger les données de la métrique</p>`
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for(const data of this.data) {
|
||||||
|
contentDiv.innerHTML += `<div class='metric-data'><div class='metric-data-div'><p class='metric-data-title'>${data.description}</p><p class='metric-data-id'>${data.name}</p></div><p class='metric-data-value'>Valeur : <span>${data.value}<span></p></div>`
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const deleteButton = getID(`${this.properties.id}_metricpower`)
|
const deleteButton = getID(`${this.properties.id}_metricpower`)
|
||||||
|
|
||||||
deleteButton.addEventListener("click", () => {
|
deleteButton.addEventListener("click", () => {
|
||||||
|
@ -42,8 +42,14 @@ metrics.createWindow(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
metricsReq.then((ANS_metrics) => {
|
metricsReq.then((ANS_metrics) => {
|
||||||
|
console.log(ANS_metrics)
|
||||||
if(ANS_metrics != "UNAVAILABLE") {
|
if(ANS_metrics != "UNAVAILABLE") {
|
||||||
metricsList.length = 0
|
metricsList.length = 0
|
||||||
|
if(ANS_metrics.length == 0) {
|
||||||
|
metricsList.push(`<div style='font-size: 24px; margin-top: 180px;' class='yellow t-center'>
|
||||||
|
<p><i class="fa-solid fa-warning"></i> Aucune WebMetrik n'a été ajoutée</p>
|
||||||
|
</div>`)
|
||||||
|
}
|
||||||
ANS_metrics.forEach((metric) => {
|
ANS_metrics.forEach((metric) => {
|
||||||
const metricComponent = new Metric({
|
const metricComponent = new Metric({
|
||||||
properties: metric,
|
properties: metric,
|
||||||
|
@ -1360,3 +1360,8 @@ a {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.metric-error {
|
||||||
|
|
||||||
|
color: yellow;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user