mirror of
https://github.com/sascha-hemi/homeassistant-desktop.git
synced 2026-03-21 04:06:06 +01:00
release v1.3.0
fixes #4 fixes #5 fixes #6 fixes #7 may fix #3 added: - availability check / error page - auto switching to next available instance for multiple instances + linting / formatting
This commit is contained in:
136
web/index.html
136
web/index.html
@@ -1,79 +1,93 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<title>Home Assistant</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no">
|
||||
<link href="assets/style.css" rel="stylesheet">
|
||||
<link href="assets/checkmark.css" rel="stylesheet">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no" />
|
||||
<link href="assets/style.css" rel="stylesheet" />
|
||||
<link href="assets/checkmark.css" rel="stylesheet" />
|
||||
<script>
|
||||
const {ipcRenderer} = require('electron');
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
ipcRenderer.send('ha-instance');
|
||||
ipcRenderer.send("ha-instance");
|
||||
|
||||
ipcRenderer.on('ha-instance', function (event, url) {
|
||||
window.location.href = url
|
||||
});
|
||||
let showCheckmark = false;
|
||||
|
||||
function isValidUrl(string) {
|
||||
try {
|
||||
new URL(string);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
ipcRenderer.on("ha-instance", function (event, url) {
|
||||
if (showCheckmark) {
|
||||
document
|
||||
.getElementById("check-wrapper")
|
||||
.addEventListener(
|
||||
"animationend",
|
||||
() => (window.location.href = url)
|
||||
);
|
||||
} else window.location.href = url;
|
||||
});
|
||||
|
||||
function isValidUrl(string) {
|
||||
try {
|
||||
new URL(string);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkUrl() {
|
||||
const url = document.getElementById("url").value;
|
||||
|
||||
if (!isValidUrl(url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
function checkUrl() {
|
||||
let url = document.getElementById('url').value;
|
||||
if (!isValidUrl(url)) {
|
||||
return
|
||||
fetch(url + "/auth/providers")
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
document.getElementById("url").value = url;
|
||||
document.getElementById("url").disabled = true;
|
||||
document.getElementById("check-wrapper").style.display = "block";
|
||||
document.getElementById("url-wrapper").style.display = "none";
|
||||
showCheckmark = true;
|
||||
ipcRenderer.send("ha-instance", url);
|
||||
}
|
||||
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
request.open('GET', url + '/auth/providers', true);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.status === 200) {
|
||||
document.getElementById('check-wrapper').style.display = 'block';
|
||||
document.getElementById('url-wrapper').style.display = 'none';
|
||||
ipcRenderer.send('ha-instance', {url: url, name: JSON.parse(request.responseText)[0].name});
|
||||
setTimeout(function () {
|
||||
window.location.href = url
|
||||
}, 1000)
|
||||
}
|
||||
};
|
||||
request.send();
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<div class="center header"><img src="assets/favicon.png" height="52"> Home Assistant</div>
|
||||
<div class="center">
|
||||
<p>Please enter your Home Assistant URL in the field below:</p></div>
|
||||
<div class="center">
|
||||
<body>
|
||||
<div class="content">
|
||||
<div class="center header">
|
||||
<img src="assets/favicon.png" height="52" /> Home Assistant
|
||||
</div>
|
||||
<div class="center">
|
||||
<p>Please enter your Home Assistant URL in the field below:</p>
|
||||
</div>
|
||||
<div class="center">
|
||||
<div id="check-wrapper" class="success-checkmark">
|
||||
<div class="check-icon">
|
||||
<span class="icon-line line-tip"></span>
|
||||
<span class="icon-line line-long"></span>
|
||||
<div class="icon-circle"></div>
|
||||
<div class="icon-fix"></div>
|
||||
</div>
|
||||
<div class="check-icon">
|
||||
<span class="icon-line line-tip"></span>
|
||||
<span class="icon-line line-long"></span>
|
||||
<div class="icon-circle"></div>
|
||||
<div class="icon-fix"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="url-wrapper" class="group">
|
||||
<input type="url" required="required" id="url" onkeyup="checkUrl()"/>
|
||||
<span class="highlight"></span>
|
||||
<span class="bar"></span>
|
||||
<label>Home Assistant URL</label>
|
||||
<input type="url" required="required" id="url" onkeyup="checkUrl()" />
|
||||
<span class="highlight"></span>
|
||||
<span class="bar"></span>
|
||||
<label>Home Assistant URL</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="center">
|
||||
<p>
|
||||
<small class="grey"
|
||||
>If the entered URL directs to a working Home Assistant instance,
|
||||
you will be forwarded to the login page automatically.</small
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="center">
|
||||
<p><small class="grey">If the entered URL directs to a working Home Assistant instance, you will be forwarded to the login page automatically.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user