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:
@ -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,21 +50,33 @@ module.exports.getMetrics = function() {
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
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"
|
||||
|
Reference in New Issue
Block a user