Revue page accueil administrateur site : template wikilerni + optimisation script JS.
This commit is contained in:
parent
f72a7a4824
commit
0cf5a82418
@ -1,79 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Page d'accueil du gestionnaire.">
|
||||
<meta name="description" content="Page d'accueil pour les gestionnaires du site.">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>WikiLerni - gestion du site</title>
|
||||
<title>Mon WikiLerni</title>
|
||||
<!-- Version lisible des scripts : https://gitlab.com/lefablab/wikilerni/-/tree/master/front/src -->
|
||||
<script src="/JS/polyfill.app.js" defer></script>
|
||||
<script src="/JS/homeManager.app.js" defer></script>
|
||||
<link rel="shortcut icon" href="/img/favicon.ico">
|
||||
<link rel="stylesheet" href="/themes/default/CSS/pure-min.css">
|
||||
<link rel="stylesheet" href="/themes/default/CSS/grids-responsive-min.css">
|
||||
<link rel="stylesheet" href="/themes/default/CSS/wikilerni.css">
|
||||
<link rel="canonical" href="https://www.wililerni.com/gestion.html">
|
||||
</head>
|
||||
<link rel="stylesheet" href="/themes/wikilerni/css/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header class="pure-g menu">
|
||||
<div class="pure-u-1 pure-u-lg-1-8 menu-heading">
|
||||
<a class="pure-menu-heading" href="/">WikiLerni</a>
|
||||
</div>
|
||||
<div class="pure-u-1 pure-u-lg-7-8">
|
||||
<ul class="pure-g">
|
||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
||||
<a class="pure-menu-link" href="/">Accueil</a>
|
||||
</li>
|
||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
||||
<a class="pure-menu-link" href="/connexion.html" id="accountHeadLink">Mon compte</a>
|
||||
</li>
|
||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
||||
<a class="pure-menu-link" href="/a-propos.html">À propos</a>
|
||||
</li>
|
||||
<li class="pure-menu-item pure-u-1 pure-u-lg-1-4">
|
||||
<a class="pure-menu-link" href="/contact.html">Contact</a>
|
||||
</li>
|
||||
<body class="cardboard">
|
||||
<!-- En tête -->
|
||||
<header class="cardboard">
|
||||
<a href="/" title="Page d'accueil WikLerni"><img src="/themes/wikilerni/img/wikilerni-purple-2-128.png" alt="WikiLerni (logo)" title="Accéder à la page d'accueil de WikiLerni" /></a>
|
||||
<ul id="headLinks">
|
||||
<li><a href="/contact.html" rel="nofollow">Contact</a></li>
|
||||
<li><a href="/quizs/" id="indexHeadLink" title="Les derniers quizs">Parcourir</a></li>
|
||||
<li><a href="/connexion.html" id="accountHeadLink">Mon compte</a></li>
|
||||
<li><a href="/a-propos.html">À propos</a></li>
|
||||
<li><a href="/" title="Page d'accueil de WikiLerni">Accueil</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div id="crash"></div>
|
||||
|
||||
<section id="main-content" class="needJS">
|
||||
|
||||
<div class="pure-menu pure-menu-horizontal">
|
||||
<a href="/gestion.html" class="pure-menu-heading pure-menu-link">Gestion WikiLerni</a>
|
||||
<ul id="classement" class="pure-menu-list">
|
||||
<li class="pure-menu-item"><a href="/gestion-quizs.html" title="Publication des quizs" class="pure-menu-link" >Les quizs</a></li>
|
||||
<li class="pure-menu-item"><a href="/gestion-utilisateurs.html" title="Les comptes utilisateurs" class="pure-menu-link">Les abonné(e)s</a></li>
|
||||
<li class="pure-menu-item"><a href="/sortie.html" title="Sortie des artistes !" class="pure-menu-link">Me déconnecter</a></li>
|
||||
<ul id="menu" class="cardboard">
|
||||
<li><a href="/gestion.html">Gestion WikiLerni</a></li>
|
||||
<li><a href="/gestion-quizs.html" title="Publication des quizs">Les quizs</a></li>
|
||||
<li><a href="/gestion-utilisateurs.html" title="Les comptes utilisateurs">Les abonné(e)s</a></li>
|
||||
<li><a href="/sortie.html">Me déconnecter</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="home" class="cardboard">
|
||||
<img id="logo" src="/themes/wikilerni/img/wikilerni-purple-2-512.png" alt="Logo WikiLerni" />
|
||||
<div id="message" class="cardboard"></div>
|
||||
<p><a href="#" class="button cardboard" id="wantRegenerate">Régénérer le HTML.</a></p>
|
||||
<div id="questionnaires"></div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<h2 class="content-head is-center">WikiLerni</h2>
|
||||
<div class="pure-g">
|
||||
<div class="l-box-lrg pure-u-1" id="message"></div>
|
||||
<div class="l-box-lrg pure-u-1" id="questionnaires"></div>
|
||||
</div>
|
||||
<p><a href="#" class="pure-button pure-button-primary" id="wantRegenerate">Régénérer le HTML.</a></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer class="footer l-box is-center">
|
||||
<ul class="pure-g">
|
||||
<li class="pure-u-1 pure-u-lg-1-5">
|
||||
<a href="/mentions-legales.html">Crédits</a>
|
||||
</li>
|
||||
<li class="pure-u-1 pure-u-lg-1-5">
|
||||
<a href="/mentions-legales.html">Mentions légales</a>
|
||||
</li>
|
||||
<li class="pure-u-1 pure-u-lg-1-5">
|
||||
<a href="/donnees.html">Données personnelles</a>
|
||||
</li>
|
||||
<li><a href="/CGV-CGU.html">CGV & CGU</a></li>
|
||||
<footer class="cardboard">
|
||||
<ul id="footLinks">
|
||||
<li><a href="https://framasphere.org/people/7e54b7a0b53201389eef2a0000053625" title="Blog WikiLerni sur diaspora*">Blog</a></li>
|
||||
<li><a href="/credits.html">Crédits</a></li>
|
||||
<li><a href="/mentions-legales.html" rel="nofollow">Mentions légales</a></li>
|
||||
<li><a href="/donnees.html">Données personnelles</a></li>
|
||||
<li><a href="/CGV-CGU.html" rel="nofollow">CGV & CGU</a></li>
|
||||
</ul>
|
||||
</footer>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
@ -6,30 +6,41 @@
|
||||
/// Un menu permet à l'utilisateur d'accéder aux formulaires permettant de gérer les quizs et les comptes utilisateurs et abonnements
|
||||
/// Un message venant d'une autre page peut aussi être à afficher lors du premier chargement.
|
||||
|
||||
/// C'est ici aussi que l'on peut régénérer tout le HTML -> à terme dans homeAdmin !
|
||||
/// Temporairement, c'est ici aussi que l'on peut régénérer tout le HTML -> à terme dans homeAdmin !
|
||||
|
||||
// Fichier de configuration côté client :
|
||||
import { apiUrl, availableLangs, theme } from "../../config/instance.js";
|
||||
const lang=availableLangs[0];
|
||||
const configFrontEnd = require("../../views/"+theme+"/config/"+lang+".js");
|
||||
|
||||
import { getAdminStats, userRoutes } from "../../config/users.js";
|
||||
import { getListNextQuestionnaires, questionnaireRoutes, regenerateHTML } from "../../config/questionnaires.js";
|
||||
const configTemplate = require("../../views/"+theme+"/config/"+lang+".js");
|
||||
|
||||
// Fonctions utiles au script :
|
||||
import { getLocaly, removeLocaly } from "./tools/clientstorage.js";
|
||||
import { addElement } from "./tools/dom.js";
|
||||
import { helloDev, updateAccountLink } from "./tools/everywhere.js";
|
||||
import { dateFormat, isEmpty, replaceAll } from "../../tools/main";
|
||||
import { checkSession, getConfig } from "./tools/users.js";
|
||||
import { checkSession } from "./tools/users.js";
|
||||
|
||||
// Dictionnaires :
|
||||
// Dictionnaires : revoir pour ne prendre que les variables utilisées
|
||||
const txt = require("../../lang/"+lang+"/general");
|
||||
const txtUsers = require("../../lang/"+lang+"/user");
|
||||
|
||||
const txtNotAllowed = require("../../lang/"+lang+"/general").notAllowed;
|
||||
const txtServerError = require("../../lang/"+lang+"/general").serverError;
|
||||
const txtStatsAdmin = require("../../lang/"+lang+"/general").statsAdmin;
|
||||
const txtNeedBeCompleted = require("../../lang/"+lang+"/questionnaire").needBeCompleted;
|
||||
const txtNextDateWithoutQuestionnaire = require("../../lang/"+lang+"/questionnaire").nextDateWithoutQuestionnaire;
|
||||
const txtNextQuestionnairesList = require("../../lang/"+lang+"/questionnaire").nextQuestionnairesList;
|
||||
const txtWelcome = require("../../lang/"+lang+"/user").welcomeMessage;
|
||||
|
||||
const txtQuestionnaire = require("../../lang/"+lang+"/questionnaire");
|
||||
|
||||
// Principaux éléments du DOM manipulés :
|
||||
const divMain = document.getElementById("main-content");
|
||||
const divCrash = document.getElementById("crash");
|
||||
const divMessage = document.getElementById("message");
|
||||
const divQuestionnaires = document.getElementById("questionnaires");
|
||||
|
||||
const btnRegenerate = document.getElementById("wantRegenerate");
|
||||
|
||||
helloDev();
|
||||
@ -38,26 +49,21 @@ const initialise = async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
const config = await getConfig();
|
||||
if(!config)
|
||||
addElement(divResponse, "p", txt.serverError, "", ["error"]);
|
||||
else
|
||||
{
|
||||
const isConnected=await checkSession(["manager", "admin"], "/"+configFrontEnd.connectionPage, { message: txt.notAllowed, color:"error" });
|
||||
const isConnected=await checkSession(["manager", "admin"], "/"+configTemplate.connectionPage, { message: txtNotAllowed, color:"error" });
|
||||
if(isConnected)
|
||||
{
|
||||
const user=getLocaly("user", true);
|
||||
updateAccountLink(user.status, configFrontEnd);
|
||||
addElement(divMessage, "h4", txtUsers.welcomeMessage.replace("#NAME", user.name));
|
||||
updateAccountLink(user.status, configTemplate);
|
||||
addElement(divMessage, "h2", txtWelcome.replace("#NAME", user.name));
|
||||
divMain.style.display="block";
|
||||
if(!isEmpty(getLocaly("message")))
|
||||
{
|
||||
addElement(divMessage, "p", getLocaly("message", true).message, "", [getLocaly("message", true).color], "", false);
|
||||
removeLocaly("message");
|
||||
}
|
||||
// Les stats :
|
||||
// Les stats sur les comptes utilisateurs :
|
||||
const xhrStats = new XMLHttpRequest();
|
||||
xhrStats.open("GET", apiUrl+config.userRoutes+config.getAdminStats);
|
||||
xhrStats.open("GET", apiUrl+userRoutes+getAdminStats);
|
||||
xhrStats.onreadystatechange = function()
|
||||
{
|
||||
if (this.readyState == XMLHttpRequest.DONE)
|
||||
@ -79,7 +85,7 @@ const initialise = async () =>
|
||||
NB_USERS_DELETED_VALIDED : response.nbDeletedUsersWasValided,
|
||||
NB_USERS_DELETED_PREMIUM : response.nbDeletedUsersTotWasPremium
|
||||
};
|
||||
addElement(divMessage, "p", replaceAll(txt.statsAdmin, mapText), "", "", "", false);
|
||||
addElement(divMessage, "p", replaceAll(txtStatsAdmin, mapText), "", "", "", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +94,7 @@ const initialise = async () =>
|
||||
|
||||
// Les questionnaires bientôt publiés :
|
||||
const xhrNextQuestionnaires = new XMLHttpRequest();
|
||||
xhrNextQuestionnaires.open("GET", apiUrl+config.questionnaireRoutes+config.getListNextQuestionnaires);
|
||||
xhrNextQuestionnaires.open("GET", apiUrl+questionnaireRoutes+getListNextQuestionnaires);
|
||||
xhrNextQuestionnaires.onreadystatechange = function()
|
||||
{
|
||||
if (this.readyState == XMLHttpRequest.DONE)
|
||||
@ -100,14 +106,14 @@ const initialise = async () =>
|
||||
for(let i in response.questionnaires)
|
||||
{
|
||||
dayStr=new Intl.DateTimeFormat(lang, optionsDayStr).format(new Date(response.questionnaires[i].datePublishing));
|
||||
listHTML+="<li>"+dayStr+" "+dateFormat(response.questionnaires[i].datePublishing, "fr")+": <a href='"+configFrontEnd.questionnairesManagementPage+"?id="+response.questionnaires[i].id+"'>"+response.questionnaires[i].title+"</a>";
|
||||
listHTML+="<li>"+dayStr+" "+dateFormat(response.questionnaires[i].datePublishing, availableLangs[0])+": <a href='"+configTemplate.questionnairesManagementPage+"?id="+response.questionnaires[i].id+"'>"+response.questionnaires[i].title+"</a>";
|
||||
if(response.questionnaires[i].isPublishable===false)
|
||||
listHTML+=" <span class='error'>("+txtQuestionnaire.needBeCompleted+")</li>";
|
||||
listHTML+=" <span class='error'>("+txtNeedBeCompleted+")</li>";
|
||||
listHTML+="</li>";
|
||||
}
|
||||
if(response.questionnaires.length!==0)
|
||||
addElement(divQuestionnaires, "h3", txtQuestionnaire.nextQuestionnairesList.replace("#NB", response.questionnaires.length));
|
||||
addElement(divQuestionnaires, "h4", txtQuestionnaire.nextDateWithoutQuestionnaire+dateFormat(response.dateNeeded, "fr"), "", ["information"], "", false);
|
||||
addElement(divQuestionnaires, "h2", txtNextQuestionnairesList.replace("#NB", response.questionnaires.length));
|
||||
addElement(divQuestionnaires, "h4", txtNextDateWithoutQuestionnaire+dateFormat(response.dateNeeded, availableLangs[0]), "", ["info"], "", false);
|
||||
addElement(divQuestionnaires, "ul", listHTML, "", "", "", false);
|
||||
}
|
||||
}
|
||||
@ -120,7 +126,7 @@ const initialise = async () =>
|
||||
{
|
||||
e.preventDefault();
|
||||
const xhrRegenerate = new XMLHttpRequest();
|
||||
xhrRegenerate.open("GET", apiUrl+config.questionnaireRoutes+"/htmlregenerated");
|
||||
xhrRegenerate.open("GET", apiUrl+questionnaireRoutes+regenerateHTML);
|
||||
xhrRegenerate.onreadystatechange = function()
|
||||
{
|
||||
if (this.readyState == XMLHttpRequest.DONE)
|
||||
@ -137,11 +143,11 @@ const initialise = async () =>
|
||||
xhrRegenerate.send();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
addElement(divMessage, "p", txt.serverError, "", ["error"]);
|
||||
addElement(divCrash, "p", txtServerError, "", ["error"]);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user