Changeset 1512
- Timestamp:
- May 13, 2016, 10:04:12 AM (5 years ago)
- Location:
- admin-center/trunk/fuentes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
admin-center/trunk/fuentes/admin-center.install/usr/share/admin-center/css/main.css
r1312 r1512 142 142 background-color: #ffffee; 143 143 font-family: monospace; 144 min-height: 400px;144 height: 400px; 145 145 overflow-y: auto; 146 146 overflow-x: hidden; -
admin-center/trunk/fuentes/admin-center.install/usr/share/admin-center/i18n/en-US/messages.json
r1055 r1512 6 6 "plural_forms" : "nplurals=2; plural=(n != 1);" 7 7 }, 8 "Unauthenticated":["Unauthenticaded"], 9 "main.Authentication":["Authentication"], 10 "main.Username":["Username"], 11 "main.Password":["Password"], 8 12 "Server Admin" : [ "Server Adminisration"], 9 13 "Server Info" : [ "Server Info"], … … 25 29 "Proxy status" : [ "Proxy status"], 26 30 "Proxy name" : [ "Proxy name"], 27 "Proxy port" : [ "Proxy port"] 31 "Proxy port" : [ "Proxy port"], 32 "N4d.Error.Connection" : ["N4d Error Connection"], 33 "main_confirm_cancel_task" : ["Are you sure to cancel this task?"], 34 "main_task_cancelled": ["Task cancelled"], 35 "main_log_connected_message": ["Connected to server logging..."], 36 "log_connection_error": ["Log connection error"], 37 "log_connection_closed": ["Log connection closed"] 28 38 } 29 39 } -
admin-center/trunk/fuentes/admin-center.install/usr/share/admin-center/lib/utils.js
r1312 r1512 8 8 // Utilities collection 9 9 this.activeWebSockets=[]; 10 } 11 12 UtilsClass.prototype._=function _(text){ 13 return ( i18n.gettext("main", text)); 10 14 } 11 15 … … 65 69 }; 66 70 67 UtilsClass.prototype.showWSListener=function showWSListener(port ){71 UtilsClass.prototype.showWSListener=function showWSListener(port, sport){ 68 72 var self=this; 69 73 // 1st Preparing log window 70 74 71 var logJobId="job1"; 75 //var logJobId="job1"; 76 var logJobId="job_port"+sport; 72 77 73 78 var modaldiv=$(document.createElement("div")).attr("id", logJobId).addClass("modal"); … … 84 89 85 90 var modalfooter=$(document.createElement("div")).addClass("modal-footer"); 86 var bt1=$(document.createElement("button")).addClass("btn btn-primary").attr("id", " bt1").attr("targetjob", logJobId).html(("Close log"))87 var bt2=$(document.createElement("button")).addClass("btn btn-primary").attr("id", " bt2").attr("targetjob", logJobId).html(("Cancel task"));91 var bt1=$(document.createElement("button")).addClass("btn btn-primary").attr("id", "logviewer_bt1").attr("targetjob", logJobId).html(("Close log")) 92 var bt2=$(document.createElement("button")).addClass("btn btn-primary").attr("id", "logviewer_bt2").attr("targetjob", logJobId).html(("Cancel task")); 88 93 $(modalfooter).append(bt1).append(bt2); 89 94 … … 119 124 }) 120 125 121 $(bt2).on("click", function(){ 122 alert("cancel"); 123 }) 126 $(bt2).on("click", function(event){ 127 128 var text=self._("main_confirm_cancel_task"); 129 130 bootbox.confirm(text, function(res){ 131 if (res) { 132 var jobid=$(event.target).attr("targetjob"); 133 var srv_port=jobid.substring(8, jobid.length); 134 //alert("cancel "+port); 135 136 var credentials=[sessionStorage.username , sessionStorage.password]; 137 var n4dclass="LogManager"; 138 var n4dmethod="cancelJob"; 139 var arglist=[srv_port]; 140 try { 141 Utils.n4d(credentials, n4dclass, n4dmethod, arglist, function(response){ 142 self.msg(_("main_task_cancelled"), MSG_SUCCESS); 143 }); 144 }catch(error){ 145 self.msg("Error: "+error, MSG_ERROR); 146 }; 147 148 $("#logviewer_bt1").trigger("click"); 149 } 150 }); 151 }); 124 152 125 153 // 2nd Prepare Listener through websocket … … 127 155 websocket = new WebSocket(wsUri); 128 156 websocket.onopen = function(ev) { // connection is open 129 $(modallog).append("<div> Connected!</div>"); //notify user157 $(modallog).append("<div>"+_("main_log_connected_message")+"</div>"); //notify user 130 158 } 131 159 … … 142 170 143 171 var msg = JSON.parse(sub); //PHP sends Json data 172 // /^\[[^]*%$/ 173 //console.log("!!!!!!!!!·$$$$$ª!!!!!!!!!!!!!!!"); 174 msgtext=atob(msg.msg); 175 console.log(msgtext); 176 console.log(/^\[[^]*%$/.test(msgtext) ); 177 if ( /^\[[^]*%$/.test(msgtext) ) console.log("MATCHES *****"); 178 //console.log("#################################"); 179 144 180 $(modallog).append("<div>"+atob(msg.msg)+"</div>"); 145 146 181 147 182 if (typeof(msg.type)!="undefined" && msg.type==="end_signal") { … … 153 188 self.activeWebSockets.push({job:logJobId, ws:websocket}); 154 189 155 websocket.onerror = function(ev){self.msg(" Log connectionerror", MSG_ERROR);}156 websocket.onclose = function(ev){self.msg(" Log connectionclosed", MSG_INFO);}190 websocket.onerror = function(ev){self.msg("log_connection_error", MSG_ERROR);} 191 websocket.onclose = function(ev){self.msg("log_connection_closed", MSG_INFO);} 157 192 158 193 … … 165 200 var n4dargs=[]; 166 201 167 console.log("Getting into n4d: ");202 //console.log("Getting into n4d: "); 168 203 console.log(credentials); 169 204 console.log(n4dclass); … … 171 206 console.log(arglist); 172 207 console.log(callback); 173 console.log("**********************************");208 //console.log("**********************************"); 174 209 // Building credentials 175 210 if(credentials===null) … … 183 218 // Adding argument list 184 219 220 for (i in arglist) n4dargs.push(arglist[i]); 221 222 //console.log(n4dargs); 223 // Calling method 224 console.log("-----------------------------1"); 225 console.log(JSON.stringify(n4dargs)); 226 console.log("-----------------------------2"); 227 228 //$.post('n4d.php', 229 $.ajax( 230 {url:'n4d.php', 231 method: 'POST', 232 async: true, 233 data: { 234 method: n4dmethod, 235 args: JSON.stringify(n4dargs)}, 236 //args: n4dargs}, 237 success: function(args){ 238 callback(args); 239 },error(){ 240 msg=_("N4d.Error.Connection"); 241 self.msg(msg, MSG_ERROR); 242 } 243 }); // End $post 244 245 }; 246 247 248 UtilsClass.prototype.n4dWithExtraParams=function n4dWithExtraParams(credentials, n4dclass, n4dmethod, ip, port, arglist, callback){ 249 var self=this; 250 251 var n4dargs=[]; 252 253 //console.log("Getting into n4d: "); 254 console.log(credentials); 255 console.log(n4dclass); 256 console.log(n4dmethod); 257 console.log(arglist); 258 console.log(callback); 259 //console.log("**********************************"); 260 // Building credentials 261 if(credentials===null) 262 n4dargs.push(""); 263 else if (n4dmethod!="validate_user") n4dargs[0]=credentials; 264 else n4dargs=credentials; 265 266 // Adding Class 267 n4dargs.push(n4dclass); 268 269 // Add Extra info: info + port 270 n4dargs.push(ip); 271 n4dargs.push(port); 272 273 // Adding argument list 274 185 275 //console.log(arglist); -> Deprecated, 186 276 //alert(typeof(arglist)+ " has " +arglist.length); … … 199 289 200 290 201 if (n4dmethod=="getBootList") { 202 console.log("*****!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*"+n4dargs); 203 alert("*****!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*"+n4dargs); 204 } 205 206 $.post('n4d.php', 207 { 208 method: n4dmethod, 209 args: JSON.stringify(n4dargs)}, 210 //args: n4dargs}, 211 function(args){ 212 if (n4dmethod=="getBootList") { 213 console.log("*****!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*"+args); 214 alert("*****!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*"+args); 215 } 216 //console.log("AAAAA"); 217 console.log(args); 218 219 //console.log("BBBBB"); 220 callback(args); 221 }); // End $post 222 223 /* DEPRECATED! 224 225 $.xmlrpc({ 226 url: 'https://'+sessionStorage.server+':9779', 227 methodName: n4dmethod, 228 params: n4dargs, 229 success: function(response,status,jqXHR){ 230 callback(response,status,jqXHR); 231 }, 232 error: function(jqXHR, status, error) { 291 $.ajax( 292 {url: 'n4d.php', 293 method: 'POST', 294 async: true, 295 data:{ method: n4dmethod, 296 args: JSON.stringify(n4dargs)}, 297 success: function(args){ 298 callback(args); 299 }, 300 error: function(jqXHR, status, error) { 233 301 self.msg(i18n.gettext("main", "N4d.Error.Connection")); 234 } 235 });*/ 236 }; 237 238 239 UtilsClass.prototype.n4dWithExtraParams=function n4dWithExtraParams(credentials, n4dclass, n4dmethod, ip, port, arglist, callback){ 240 var self=this; 241 242 var n4dargs=[]; 243 244 console.log("Getting into n4d: "); 245 console.log(credentials); 246 console.log(n4dclass); 247 console.log(n4dmethod); 248 console.log(arglist); 249 console.log(callback); 250 console.log("**********************************"); 251 // Building credentials 252 if(credentials===null) 253 n4dargs.push(""); 254 else if (n4dmethod!="validate_user") n4dargs[0]=credentials; 255 else n4dargs=credentials; 256 257 // Adding Class 258 n4dargs.push(n4dclass); 259 260 // Add Extra info: info + port 261 n4dargs.push(ip); 262 n4dargs.push(port); 263 264 // Adding argument list 265 266 //console.log(arglist); -> Deprecated, 267 //alert(typeof(arglist)+ " has " +arglist.length); 268 /*if (Object.keys(arglist).length>0) { 269 n4dargs.push(arglist); 270 };*/ 271 272 273 for (i in arglist) n4dargs.push(arglist[i]); 274 275 //console.log(n4dargs); 276 // Calling method 277 console.log("-----------------------------1"); 278 console.log(JSON.stringify(n4dargs)); 279 console.log("-----------------------------2"); 280 281 282 $.post('n4d.php', 283 { 284 method: n4dmethod, 285 args: JSON.stringify(n4dargs)}, 286 //args: n4dargs}, 287 function(args){ 288 callback(args); 289 }); // End $post 290 302 } 303 }); 291 304 292 305 } … … 296 309 297 310 // 1srt... call to acquire a websocket on 311 //console.log("1111111111111111111"); 298 312 299 313 self.n4d([sessionStorage.username , sessionStorage.password], "LogManager", "prepareConnection", [], function(response){ 314 //console.log("222222222222222222222222222222222"); 300 315 // response has socket port 301 316 var port=response["wsport"]; 302 317 var sport=response["sport"]; 303 318 console.log("Port is: "+port+" srv_port is: "+sport); 304 self.showWSListener(port); 319 //console.log("3333333333333333333333333333333333"); 320 self.showWSListener(port, sport); 321 //console.log("44444444444444444444444444444444444"); 305 322 306 323 307 324 Utils.n4dWithExtraParams(credentials, n4dclass, n4dmethod, "", sport, arglist, function(response){ 325 //console.log("55555555555555555555555555555555555555"); 308 326 console.log(response); 327 //console.log("666666666666666666666666666"); 309 328 }); 310 329 … … 312 331 313 332 }); 314 /* 315 316 var n4dargs=[]; 317 console.log("Getting into n4d with Log: "); 318 319 // Building credentials 320 if(credentials===null) 321 n4dargs.push(""); 322 else if (n4dmethod!="validate_user") n4dargs[0]=credentials; 323 else n4dargs=credentials; 324 325 // Adding Class 326 n4dargs.push(n4dclass); 327 328 for (i in arglist) n4dargs.push(arglist[i]); 329 330 //console.log(n4dargs); 331 // Calling method 332 console.log("-----------------------------1"); 333 console.log(JSON.stringify(n4dargs)); 334 console.log("-----------------------------2"); 335 $.post('n4d.php', 336 { 337 log: "true", 338 method: n4dmethod, 339 args: JSON.stringify(n4dargs)}, 340 //args: n4dargs}, 341 function(args){ 342 console.log("AAAAA"); 343 console.log(args); 344 console.log("BBBBB"); 345 callback(args); 346 }); // End $post 347 348 */ 333 349 334 }; 350 335 -
admin-center/trunk/fuentes/admin-center.install/usr/share/admin-center/login.php
r1055 r1512 38 38 </head> 39 39 <body> 40 41 <?php 42 function gt($text){ 43 $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); 44 switch ($lang){ 45 case "en": 46 if ($text=="Authentication") return "Authentication"; 47 else if ($text=="Username") return "Username"; 48 else if ($text=="login") return "Login"; 49 else return "Password"; 50 break; 51 case "es": 52 if ($text=="Authentication") return "Autenticación"; 53 else if ($text=="Username") return "Usuario"; 54 else if ($text=="login") return "Entrar"; 55 else return "Contraseña"; 56 break; 57 default: 58 if ($text=="Authentication") return "Autenticació"; 59 else if ($text=="Username") return "Usuari"; 60 else if ($text=="login") return "Entra"; 61 else return "Contrassenya"; 62 break; 63 } 64 } 65 ?> 40 66 41 67 <div id="login" class="jumbotron col-lg-4 col-lg-offset-4" style="margin-top: 200px;"> 42 <h3> Authentication</h3>68 <h3><?php echo (gt("Authentication")); ?></h3> 43 69 <div id="loginform" class="form-group"> 44 70 45 <label for="input_username" class="control-label" i18n>Usuari</label>46 <input type="text" id="input_username" class="form-control" i18n></input>47 <label for="input_username" class="control-label"> Password</label>71 <label for="input_username" class="control-label"><?php echo (gt("Username")); ?></label> 72 <input type="text" id="input_username" class="form-control"></input> 73 <label for="input_username" class="control-label"><?php echo (gt("Password")); ?></label> 48 74 <input type="password" id="input_password" class="form-control"></input> 49 75 50 76 51 77 <div style="margin-top: 10px; margin-left: 100px;"> 52 <button id="LoginButton" class="btn btn-primary btn-lg" value=" login"></button>78 <button id="LoginButton" class="btn btn-primary btn-lg" value="<?php gt("login");?>"></button> 53 79 </div> 54 80 </div></div> -
admin-center/trunk/fuentes/admin-center.install/usr/share/admin-center/n4d.php
r1312 r1512 7 7 // require_once('php_lib/logListener.php'); -> S'utilitza? 8 8 // use logListener; -> S'utilitza? 9 10 11 // Class for make n4d calls asyncronous 12 /*class n4dAsync extends Thread { 13 public function run($method, $args) { 14 n4d($method, $args); 15 } 16 }*/ 17 // End async 18 9 19 10 20 if(!session_id()) session_start(); … … 34 44 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 35 45 curl_setopt($ch, CURLOPT_POSTFIELDS, $request); 46 47 curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); // async 48 curl_setopt($ch, CURLOPT_TIMEOUT, 1); // async 36 49 37 50 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); … … 41 54 42 55 $data = curl_exec($ch); 56 curl_close($ch); 57 43 58 error_log(curl_errno($ch)); 44 59 if (curl_errno($ch)) { … … 86 101 87 102 n4d($method, $args); 103 //$n4d_async = new n4dAsync(); 104 //$n4d_async ->start($method, $args); 88 105 89 106 } catch(Exception $e){ -
admin-center/trunk/fuentes/debian/changelog
r1346 r1512 1 admin-center (0.4.5) xenial; urgency=high 2 3 * fixed some logging issues and asyncronous curl 4 5 -- joamuran <joamuran@xen> Fri, 13 May 2016 10:02:58 +0200 6 1 7 admin-center (0.4.4) xenial; urgency=high 2 8
Note: See TracChangeset
for help on using the changeset viewer.