Zuletzt geändert: 2020-01-26

Das Webinterface zum Esp8266 IPv6 Admin Tab.

admin.html

<!-- For more information visit: https://fipsok.de -->
<!DOCTYPE HTML>
<html lang="de">
   <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="style.css">
      <title>ESP8266 Admin</title>
	  <style>
	  @media only screen and (max-width: 500px) {
	    .ip {
	      right: 6em;
		  position: relative;
	    }
	    aside {
	      max-width: 50vw;
	    }
	  }
	  </style>
      <script>
        window.addEventListener('load', () => {
		  renew(),once();
		  let output = document.querySelector('#note');
		  let button = document.querySelectorAll('button');
		  let span = document.querySelectorAll('#right span'); 
          button[0].addEventListener('click', () => {
            window.location = '/spiffs.html';
          });
          button[1].addEventListener('click', () => {
            window.location = '/';
          });
          button[2].addEventListener('click', check.bind(this, document.querySelector('input')));
		  button[3].addEventListener('click', re.bind(this, 'reconnect'));
		  button[4].addEventListener('click', () => {
            if (confirm('Bist du sicher!')) re('restart');
          });
          function once(arg1,arg2) {
            fetch('/admin/once', {
              method: 'POST',
              body: arg1
            }).then( (resp) => {
              return resp.json();
            }).then( (obj) => {
              output.innerHTML = '';
              output.classList.remove('note');
              document.querySelector('form').reset();
              if (arg1 == undefined) myIv = window.setInterval(renew, 1000);
              if (arg2 == 'reconnect') re(arg2);
			  span[3].innerHTML = obj['File'];
              span[4].innerHTML = obj['Build'];
              span[5].innerHTML = obj['SketchSize'];
              span[6].innerHTML = obj['SketchSpace'];
              span[7].innerHTML = obj['LocalIP'];
              span[8].innerHTML = obj['IPv6l'] ? obj['IPv6l'] : 'inaktiv';
              span[9].innerHTML = obj['IPv6g'] ? obj['IPv6g'] : 'inaktiv';			  
			  span[10].innerHTML = obj['Hostname'];
              span[11].innerHTML = obj['SSID'];
              span[12].innerHTML = obj['GatewayIP'];
              span[13].innerHTML = obj['Channel'];
              span[14].innerHTML = obj['MacAddress'];
              span[15].innerHTML = obj['SubnetMask'];
              span[16].innerHTML = obj['BSSID'];
              span[17].innerHTML = obj['ClientIP'];
              span[18].innerHTML = obj['DnsIP'];
              span[19].innerHTML = obj['ResetReason'];
              span[20].innerHTML = obj['CpuFreqMHz'] + " MHz";
			  span[21].innerHTML = obj['FreeHeap'];
              span[22].innerHTML = obj['ChipSize'];
              span[23].innerHTML = obj['ChipSpeed'] + " MHz";
              span[24].innerHTML = obj['ChipMode'];
			  span[25].innerHTML = obj['IdeVersion'].replace(/(\d)(\d)(\d)(\d)/,obj['IdeVersion'][3]!=0 ? '$1.$3.$4' : '$1.$3.');
              span[26].innerHTML = obj['CoreVersion'].replace(/_/g,'.');
              span[27].innerHTML = obj['SdkVersion'];
            }).catch(function(err) {
              re();
            });   
          }
          function renew() {
            fetch('admin/renew').then( (resp) => {
              return resp.json();
            }).then( (array) => {
			  array.forEach((x, i) => {
                span[i].innerHTML = x
              });
            }); 
          }
          function check(inObj) {
            !inObj.checkValidity() ? (output.innerHTML = inObj.validationMessage, output.classList.add('note')) : (once(inObj.value, 'reconnect'));
          }
          function re(arg) {
            clearInterval(myIv);
            fetch(arg);
            output.classList.add('note');
            if (arg == 'restart') {
              output.innerHTML = 'Der Server wird neu gestartet. Die Daten werden in 15 Sekunden neu geladen.';
              setTimeout(once, 15000);
            } 
            else if (arg == 'reconnect'){
              output.innerHTML = 'Die WiFi Verbindung wird neu gestartet. Daten werden in 10 Sekunden neu geladen.';
              setTimeout(once, 10000);
            }
            else {
              output.innerHTML = 'Es ist ein Verbindungfehler aufgetreten. Es wird versucht neu zu verbinden.';
              setTimeout(once, 3000);
            }
          }
        });
      </script>
    </head>
    <body>
      <h1>ESP8266 Admin Page</h1>
      <main>
         <aside id=left>
            <span>Runtime ESP:</span>
            <span>WiFi RSSI:</span>
            <span>ADC/VCC:</span>
            <span>Sketch Name:</span>
            <span>Sketch Build:</span>
            <span>SketchSize:</span>
            <span>FreeSketchSpace:</span>
            <span>IPv4 Address:</span>
			<span>Link-Local:</span>
			<span class=ip>IPv6:</span>
            <span>Hostname:</span>
            <span>Connected to:</span>
            <span>Gateway IP:</span>
            <span>Channel:</span>
            <span>MacAddress:</span>
            <span>SubnetMask:</span>
            <span>BSSID:</span>	  
            <span>Client IP:</span>
            <span>DnsIP:</span>
            <span>Reset Ground:</span>
            <span>CPU Freq:</span>
            <span>FreeHeap:</span>	   
            <span>FlashSize:</span>
            <span>FlashSpeed:</span>
            <span>FlashMode:</span>
			<span>IDE Version:</span>
            <span>Esp Core Version:</span>
            <span>SDK Version:</span>
         </aside>
         <aside id=right>
            <span>0</span>
            <div>
               <span></span>
               dBm
            </div>
            <span>0</span>
            <span>?</span>
            <span>0</span>
            <span>0</span>
			<span>0</span>
            <span>0</span>
            <span>0</span>
            <span class=ip>0</span>
            <span>?</span>
            <span>?</span>
            <span>0</span>
            <span>0</span>
            <span>0</span>
            <span>0</span>
            <span>0</span>
            <span>?</span>
            <span>0</span>
            <span>0</span>
            <span>0</span>
            <span>0</span>
			<span>0</span>
			<span>0</span>
            <span>0</span>
            <span>0</span>
			<span>0</span>
			<span>0</span>
         </aside>
      </main>
      <div>
         <button>Spiffs</button>
         <button>Startseite</button>
      </div>
      <div id=note></div>
      <div>
         <form>
		   <input placeholder=" neuer Hostname" pattern=([A-Za-z0-9-]{1,32}) title="Es dürfen nur Buchstaben 
		   (a-z, A-Z), Ziffern (0-9) und Bindestriche (-) enthalten sein. Maximal 32 Zeichen" required>
           <button type=button>Name Senden</button>
         </form>
      </div>
      <div>
         <button>WiFi Reconnect</button>
         <button>ESP Restart</button>
      </div>
   </body>
</html>

Zurück