From ed684a234959a278a115d4f1dc7b877e9ae9f650 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 18 May 2008 21:48:43 +0000 Subject: [PATCH] ADD avancement sur la page admin : listage des ips bannis (presque fini) --- css/1/euphorik.css | 15 +++--- css/1/pageAdmin.css | 27 +++++----- css/1/pageMinichat.css | 3 +- css/1/pageProfileRegister.css | 1 + doc/protocole3.txt | 6 +++ index.html | 4 +- js/euphorik.js | 5 +- js/pageAdmin.js | 79 ++++++++++++++++++++++++++++-- modules/erl/euphorik_protocole.erl | 2 +- 9 files changed, 115 insertions(+), 27 deletions(-) diff --git a/css/1/euphorik.css b/css/1/euphorik.css index e73c696..81f6a77 100755 --- a/css/1/euphorik.css +++ b/css/1/euphorik.css @@ -28,16 +28,19 @@ body { } #menu { - position: absolute; - z-index: 10; - top: 2px; + /* left: 300px; + top: 2px;*/ + padding-left: 300px; + /*position: absolute;*/ + height: 25px; font-size: 11px; background-color: #000000; } -#menu div { +#menu div { cursor: pointer; - display: inline; + z-index: 20; + float: left; padding: 2px; margin-left: 2px; background-color: #4f5519; @@ -61,7 +64,7 @@ body { position: relative; font-size: 12px; background-color: #000000; - padding: 30px 10px 15px 10px; + padding: 10px 10px 15px 10px; } #page > h1 { diff --git a/css/1/pageAdmin.css b/css/1/pageAdmin.css index 5ab8031..a945b7c 100644 --- a/css/1/pageAdmin.css +++ b/css/1/pageAdmin.css @@ -12,9 +12,10 @@ width: 80% } -#page.admin div.troll { +#page.admin div.troll, +#page.admin .ban { margin-top: 10px; - padding: 2px; + padding: 2px 10px 2px 10px; border: 1px solid; border-color: #253f18; background-color: #0c2003; @@ -41,26 +42,28 @@ #page.admin div.troll .editTroll, #page.admin div.troll .delTroll, #page.admin div.troll .modifier, -#page.admin div.troll .annuler +#page.admin div.troll .annuler, +#page.admin div.ban .deban { + font-size: 10px; margin-left: 10px; - font-size: 9px; - border: 1px solid; cursor: pointer; + padding-right: 5px; + padding-left: 5px; + background-color: #164200; + border: #2d8800 1px solid; + color: #EEEEEE; } -#page.admin #ips .ip { - margin-left : 10px; -} -#page.admin #ips .temps { - margin-left : 10px; +#page.admin #ips .ip { margin-right : 10px; } +#page.admin #ips .temps, #page.admin #ips .pseudo { - margin-left : 4px; - margin-right : 4px; + margin-left : 10px; + margin-right : 10px; } #page.admin #ips .login { diff --git a/css/1/pageMinichat.css b/css/1/pageMinichat.css index 35c7cde..27a0ef8 100755 --- a/css/1/pageMinichat.css +++ b/css/1/pageMinichat.css @@ -1,5 +1,6 @@ #page.minichat { - padding: 25px 0px 15px 0px; + padding-right: 0px; + padding-left: 0px } #page.minichat img { diff --git a/css/1/pageProfileRegister.css b/css/1/pageProfileRegister.css index 1b8b70a..5c262a0 100755 --- a/css/1/pageProfileRegister.css +++ b/css/1/pageProfileRegister.css @@ -2,4 +2,5 @@ #page.register, #page.profile { + padding-top: 20px } diff --git a/doc/protocole3.txt b/doc/protocole3.txt index f7fd6a5..faa7596 100644 --- a/doc/protocole3.txt +++ b/doc/protocole3.txt @@ -232,6 +232,12 @@ s -> c "reply" : "troll_deleted", "troll_id" : 2 } +ou +indique de mettre à jour la liste d'ips +s -> c + { + "reply" : "maj_banned_ips" + } === Envoie d'un troll === diff --git a/index.html b/index.html index 5b53b6a..54132c1 100755 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ -
+
diff --git a/js/euphorik.js b/js/euphorik.js index c9291a2..a19d33e 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -756,9 +756,10 @@ Client.prototype.flush = function(async) Client.prototype.majMenu = function() { // TODO : à virer : ne plus changer de style de display ... spa beau .. ou trouver une autre méthode - var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client + // var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client + displayType = "block" - $("#menu .admin").css("display", this.ekMaster ? "inline" : "none") + $("#menu .admin").css("display", this.ekMaster ? displayType : "none") // met à jour le menu if (this.statut == statutType.auth_registered) diff --git a/js/pageAdmin.js b/js/pageAdmin.js index d7d735a..9091d6d 100644 --- a/js/pageAdmin.js +++ b/js/pageAdmin.js @@ -7,6 +7,8 @@ function PageAdmin(client, formateur, util) this.client = client this.formateur = formateur this.util = util + + this.timeoutIDmajIPs = null } PageAdmin.prototype.contenu = function() @@ -102,6 +104,9 @@ PageAdmin.prototype.posterTroll = function() */ PageAdmin.prototype.majIPs = function() { + if (this.timeoutIDmajIPs) + clearTimeout(this.timeoutIDmajIPs) + var thisPageAdmin = this var dataToSend = @@ -128,10 +133,10 @@ PageAdmin.prototype.majIPs = function() for(var i = 0; i < data["list"].length; i++) { var ip = data["list"][i] - XHTML += '' + ip["ip"] + '' + + XHTML += '
' + ip["ip"] + '|' + '' + ip["remaining_time"] + - '[' + '|' for(var j = 0; j < ip["users"].length; j++) { var user = ip["users"][j] @@ -139,14 +144,78 @@ PageAdmin.prototype.majIPs = function() '' + thisPageAdmin.formateur.traitementComplet(user["nick"]) + '' + (user["login"] == "" ? "" : '') } - XHTML += ']' + XHTML += 'débannir
' } + + if (data["list"].length == 0) + XHTML += '

Aucune IP bannie

' + $("#ips").html(XHTML) + + $(".ban").each( + function() + { + var ip = $(".ip").html() + $(".deban", this).click( + function() + { + thisPageAdmin.util.messageDialogue("Êtes-vous sur de vouloir débannir l'IP " + ip + " ?", messageType.question, + {"Oui" : function() + { + thisPageAdmin.deban(ip) + }, + "Non" : function(){} + } + ) + } + ) + } + ) } else if (data["reply"] == "error") { thisPageAdmin.util.messageDialogue(data["error_message"]) } + + // rafraichissement toutes les minutes (je sais c'est mal) + // le problème est le rafraichissement des temps restant de bannissement qui doit êtrew fait du coté client + thisPageAdmin.timeoutIDmajIPs = setTimeout(function(){ thisPageAdmin.majIPs() }, 60 * 1000) + } + } + ) +} + +PageAdmin.prototype.deban = function(ip) +{ + var thisPageAdmin = this + + var dataToSend = + { + "action" : "unban", + "cookie" : this.client.cookie, + "ip" : ip + } + + ;;; dumpObj(dataToSend) + jQuery.ajax( + { + type: "POST", + url: "request", + dataType: "json", + data: this.util.jsonVersAction(dataToSend), + success: + function(data) + { + ;;; dumpObj(data) + switch(data["reply"]) + { + case "error" : + thisPageAdmin.util.messageDialogue(data["error_message"]) + break + case "ok" : + thisPageAdmin.majIPs() + break + } } } ) @@ -342,6 +411,10 @@ Trolls.prototype.rafraichirTrolls = function() case "troll_deleted" : $("#trolls #troll"+data["troll_id"]).remove() break + case "majIPs" : + // TODO : mettre l'attente au niveau de la page et pas au niveau des trolls + // thisPageAdmin.majIPs() + break case "error" : thisTrolls.util.messageDialogue(data["error_message"]) break diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index 8313484..cfb9df4 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -466,7 +466,7 @@ unban_ip( case euphorik_bd:user_by_cookie(Cookie) of {ok, #user{ek_master = true}} -> euphorik_bd:deban(unserialize_ip(IP)), - json_reponse_ok; + json_reponse_ok(); _ -> erreur("Seul les ekMaster peuvent connaitre la liste des ips bannies") end. -- 2.43.0