Commit b7f980d6 authored by Claes Sjofors's avatar Claes Sjofors

js operator window login

parent 2b3d801a
...@@ -1975,23 +1975,64 @@ function OpWindMenu() { ...@@ -1975,23 +1975,64 @@ function OpWindMenu() {
console.log( "Menu received", sts, data, result.buttons.length); console.log( "Menu received", sts, data, result.buttons.length);
var context = document.getElementById("opwindmenu"); var context = document.getElementById("opwindmenu");
var header = document.createElement("H1"); document.getElementById("opwind_title").innerHTML = result.title;
var title = document.createTextNode( result.title); document.getElementById("opwind_text").innerHTML = result.text;
header.appendChild( title);
context.appendChild( header);
var text = document.createTextNode( result.text);
context.appendChild( text);
context.appendChild( document.createElement( "hr"));
if ( result.enable_login) {
self.user_text = document.createTextNode( self.user + " on " + self.host); self.user_text = document.createTextNode( self.user + " on " + self.host);
context.appendChild( self.user_text); context.appendChild( self.user_text);
context.appendChild( document.createElement( "hr")); context.appendChild( document.createElement( "hr"));
document.getElementById("login_button").addEventListener( "click", function( event) {
if ( document.getElementById("login_frame").style.visibility == 'hidden') {
document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = "";
document.getElementById("login_frame").style.visibility='visible';
document.getElementById("login_frame").style.height='120px';
document.getElementById("login_user").focus();
}
else {
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
}
});
document.getElementById("apply_button").addEventListener( "click", function( event) {
var user = document.getElementById("login_user").value;
var passwd = document.getElementById("login_passw").value;
if ( user.trim() == "")
return;
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
var c = new JopCrypt();
passwd = c.crypt( "aa", passwd);
self.user = user;
self.gdh.login( user, passwd, self.login_cb, self);
});
document.getElementById("cancel_button").addEventListener( "click", function( event) {
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
});
document.getElementById("logout_button").addEventListener( "click", function( event) {
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
self.priv = 0;
self.user = "Default";
self.gdh.login( "", "", self.login_cb, self);
});
document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = "";
//document.getElementById("login_frame").setAttribute("style", "visibility:hidden;height:10px";
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
}
else {
document.getElementById("login_button").remove();
document.getElementById("login_frame").remove();
}
if ( result.enable_language) if ( result.enable_language)
self.add_menu_button( context, "Language"); self.add_menu_button( context, "Language");
if ( result.enable_login)
self.add_menu_button( context, "Login");
if ( result.enable_alarmlist) if ( result.enable_alarmlist)
self.add_menu_button( context, "AlarmList"); self.add_menu_button( context, "AlarmList");
if ( result.enable_eventlog) if ( result.enable_eventlog)
...@@ -2008,8 +2049,6 @@ function OpWindMenu() { ...@@ -2008,8 +2049,6 @@ function OpWindMenu() {
var button; var button;
for ( var i = 0; i < result.buttons.length; i++) { for ( var i = 0; i < result.buttons.length; i++) {
console.log( "Child", result.buttons[i].name);
self.add_menu_button( context, result.buttons[i].text); self.add_menu_button( context, result.buttons[i].text);
} }
}; };
...@@ -2019,18 +2058,6 @@ function OpWindMenu() { ...@@ -2019,18 +2058,6 @@ function OpWindMenu() {
if ( self.info.enable_language && text == "Language") { if ( self.info.enable_language && text == "Language") {
console.log("Language activated"); console.log("Language activated");
} }
else if ( self.info.enable_login && text == "Login") {
console.log("Login activated");
var user = prompt( "Username");
var passwd = prompt( "Password");
var c = new JopCrypt();
passwd = c.crypt( "aa", passwd);
console.log( "Login", user, passwd);
self.user = user;
self.gdh.login( user, passwd, self.login_cb, self);
}
else if ( self.info.enable_alarmlist && text == "AlarmList") { else if ( self.info.enable_alarmlist && text == "AlarmList") {
console.log("AlarmList activated"); console.log("AlarmList activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite | if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
...@@ -2101,14 +2128,15 @@ function OpWindMenu() { ...@@ -2101,14 +2128,15 @@ function OpWindMenu() {
if ( self.user_text != null) if ( self.user_text != null)
self.user_text.textContent = self.user + " on " + self.host; self.user_text.textContent = self.user + " on " + self.host;
console.log( "sessionStorage set"); console.log( "Login", self.user, "Priv", self.priv);
} }
else { else {
self.priv = 0; self.priv = 0;
self.user = "none"; self.user = "none";
console.log("user_text", self.user_text); sessionStorage.setItem("pwr_privilege", self.priv);
if ( self.user_text != null) if ( self.user_text != null)
self.user_text.textContent = "None on " + self.host; self.user_text.textContent = "None on " + self.host;
console.log( "Login failure", "Priv", self.priv);
} }
}; };
} }
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<title>Xtt</title> <title>Operator Menu</title>
<link rel="stylesheet" type="text/css" href="toolbar.css"> <link rel="stylesheet" type="text/css" href="toolbar.css">
</head> </head>
<body> <body>
<div id="opwindmenu" width="120" height="800"></div> <div id="opwindmenu" width="120" height="800">
<h1 id="opwind_title"></h1>
<p id="opwind_text"></p>
<hr>
<button id="login_button" type="button" class="leftmenu-button">Login</button>
<div id="login_frame" class="login-frame">
Username<br>
<input id="login_user" name="username" class="login-field" /><br>
Password<br>
<input id="login_passw" name="password" type="password" class="login-field" /><br>
<button id="apply_button" type="button" style="flex-grow:1">Apply</button>
<button id="cancel_button" type="button" style="float:right">Cancel</button><br>
<button id="logout_button" type="button" class="leftmenu-button">Logout</button>
</div>
</div>
<script src=opwind.js></script> <script src=opwind.js></script>
<hr> <hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address> <address><a href="mailto:claes@debian86.ssab.com"></a></address>
......
...@@ -52,3 +52,14 @@ ...@@ -52,3 +52,14 @@
.leftmenu-button { .leftmenu-button {
width:100%; width:100%;
} }
.login-frame {
background-color: #ddeeff;
padding: 10px;
display: block;
overflow: hidden;
}
.login-field {
width:100%;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment