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
|
||||
|
||||
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 res = await fetch(url, {
|
||||
const fet = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
@ -46,23 +50,35 @@ module.exports.getMetrics = function() {
|
||||
if(res) {
|
||||
metric.data = res
|
||||
metricsToReturn.push(metric)
|
||||
processed++
|
||||
} else {
|
||||
metric.data = "ERROR"
|
||||
metricsToReturn.push(metric)
|
||||
}
|
||||
})
|
||||
|
||||
processed++
|
||||
|
||||
if(processed == metrics.length) {
|
||||
resolve(metricsToReturn)
|
||||
}
|
||||
|
||||
}).catch((err) => {
|
||||
metric.data = "ERROR"
|
||||
metricsToReturn.push(metric)
|
||||
processed++
|
||||
if(processed == metrics.length) {
|
||||
resolve(metricsToReturn)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -328,6 +328,9 @@ module.exports.User = class {
|
||||
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/")
|
||||
@ -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)
|
||||
const user = this.fetchUsers().get(settings.username)
|
||||
if(user) {
|
||||
console.log(settings)
|
||||
|
||||
if(settings.newusername && settings.newusername != settings.username) {
|
||||
if(this.getUser(settings.newusername)) {
|
||||
ulog.error("L'utilisateur existe déjà : " + settings.username)
|
||||
@ -466,7 +469,7 @@ module.exports.editUser = function(settings) {
|
||||
}
|
||||
|
||||
module.exports.editMySelf = function (settings, user) {
|
||||
if(user.username == settings.actualUsername) {
|
||||
if(user.username == settings.username) {
|
||||
if(settings.username == '') {
|
||||
ulog.error("Le nom d'utilisateur est manquant")
|
||||
return "USERNAME_MISSING"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "neutral",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Panel d'administration de Raphix",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -1221,10 +1221,16 @@ class Metric {
|
||||
|
||||
const contentDiv = getID(`${this.properties.id}_content`)
|
||||
|
||||
if(this.data == "ERROR") {
|
||||
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`)
|
||||
|
||||
|
@ -42,8 +42,14 @@ metrics.createWindow(() => {
|
||||
})
|
||||
|
||||
metricsReq.then((ANS_metrics) => {
|
||||
console.log(ANS_metrics)
|
||||
if(ANS_metrics != "UNAVAILABLE") {
|
||||
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) => {
|
||||
const metricComponent = new Metric({
|
||||
properties: metric,
|
||||
|
@ -1360,3 +1360,8 @@ a {
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.metric-error {
|
||||
|
||||
color: yellow;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user