Browse Source

add a basic website

boyska 2 years ago
parent
commit
d12d7b87ec
6 changed files with 125 additions and 0 deletions
  1. 35 0
      static/change.html
  2. 0 0
      static/css/mini-default.min.css
  3. 35 0
      static/js/change.js
  4. 0 0
      static/js/general.js
  5. 19 0
      static/js/login.js
  6. 36 0
      static/login.html

+ 35 - 0
static/change.html

@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+    <head>
+        <title>tResetter - cambio password</title>
+        <link rel="stylesheet" href="css/mini-default.min.css">
+    </head>
+
+    <body>
+
+        <h1>tResette - Cambia password</h1>
+        <h2>Cambia password</h2>
+
+        <div class="container">
+            <div class="row">
+                <div class="col-sm-3"></div>
+            <div class="col-sm-6">
+                <input id="generate-label" readonly name="candidate-password" value="" />
+                <button id="generate-btn">Genera</button>
+            </div> <!-- col -->
+            <div class="col-sm-3"></div>
+            </div> <!-- row -->
+
+            <div class="row">
+                <div class="col-sm-4"></div>
+                <div class="col-sm-4">
+                <button id="accept-btn" disabled class="primary button">Accetta</button>
+                </div>
+                <div class="col-sm-4"></div>
+            </div>
+        </div><!-- container -->
+        <script src="js/general.js" type="application/javascript"></script>
+        <script src="js/change.js" type="application/javascript"></script>
+    </body>
+</html>
+

File diff suppressed because it is too large
+ 0 - 0
static/css/mini-default.min.css


+ 35 - 0
static/js/change.js

@@ -0,0 +1,35 @@
+async function onGenerate(evt) {
+    let resp = await fetch('../generate', {
+        method: 'POST',
+    })
+    console.log('ok', resp)
+    data = await resp.json()
+    console.log('got', data)
+    document.getElementById("generate-label").value = data.password
+    document.getElementById("accept-btn").removeAttribute('disabled')
+}
+async function onAccept(evt) {
+    document.getElementById("generate-btn").setAttribute('disabled', 'disabled')
+    let resp = await fetch('../change', {
+        method: 'POST',
+        body: JSON.stringify({
+            password: document.getElementById("generate-label").value
+        })
+    })
+    data = await resp.json()
+    if(data.success === true) {
+        // window.location.href = '../logout'
+        true
+    } else {
+        document.getElementById("generate-btn").removeAttribute('disabled')
+        document.getElementById("accept-btn").setAttribute('disabled', 'disabled')
+    }
+}
+function initChange() {
+    document.getElementById("generate-label").value = ""
+    document.getElementById("accept-btn").setAttribute('disabled', 'disabled')
+    document.getElementById("generate-btn").addEventListener('click', onGenerate, false)
+    document.getElementById("accept-btn").addEventListener('click', onAccept, false)
+}
+document.addEventListener('DOMContentLoaded', initChange)
+

+ 0 - 0
static/js/general.js


+ 19 - 0
static/js/login.js

@@ -0,0 +1,19 @@
+async function onSubmit(evt) {
+    evt.preventDefault()
+
+    let resp = await fetch('../login', {
+        method: 'POST',
+        body: JSON.stringify({
+            username: document.querySelector('#login-form input[name=username]').value,
+            password: document.querySelector('#login-form input[name=password]').value,
+        })
+    })
+    console.log('ok', resp)
+    document.location.href = '../'
+
+}
+
+function initLogin() {
+    document.getElementById("login-form").addEventListener('submit', onSubmit, false)
+}
+document.addEventListener('DOMContentLoaded', initLogin)

+ 36 - 0
static/login.html

@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+    <head>
+        <title>tResetter - cambio password</title>
+        <link rel="stylesheet" href="css/mini-default.min.css">
+    </head>
+
+    <body>
+        <div class="container">
+            <h1>tResette <small>Login</small></h1>
+
+            <form id="login-form">
+                <div class="row">
+                    <div class="col-sm-12 col-md-3"> <label for="username">Nome utente</label>
+                    </div>
+                    <div class="col-sm-12 col-md-9"> <input name="username" placeholder="utente@ondarossa.info" />
+                    </div>
+                </div> <!-- row -->
+                <div class="row">
+                    <div class="col-sm-12 col-md-3"> <label for="password">Password attuale</label>
+                    </div>
+                    <div class="col-sm-12 col-md-9"> <input name="password"  type="password" />
+                    </div>
+                </div> <!-- row -->
+
+                <button id="login-btn" class="primary button">Login</button><br/>
+            </form>
+            </div> <!-- row -->
+            </div> <!-- col-sm-6 -->
+        </div><!-- container -->
+
+
+        <script src="js/general.js" type="application/javascript"></script>
+        <script src="js/login.js" type="application/javascript"></script>
+    </body>
+</html>

Some files were not shown because too many files changed in this diff