mirror of
https://github.com/shouptech/tempgopher.git
synced 2026-02-03 08:39:43 +00:00
Add login UI
This commit is contained in:
parent
89657c381b
commit
6790b94b80
5 changed files with 62 additions and 22 deletions
|
|
@ -9,12 +9,9 @@
|
|||
<link rel="stylesheet" href="css/skeleton.css">
|
||||
<link rel="icon" type="image/png" href="img/favicon.png">
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<!--
|
||||
TODO: Fix this. I don't like service /jsconfig.js out of the root.
|
||||
This is a work-around due to the way HttpRouter handles wildcard routes.
|
||||
-->
|
||||
<script src="/jsconfig.js"></script>
|
||||
<script src="js/thermostat.js"></script>
|
||||
<script src="js/version.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
|
|
|||
|
|
@ -114,15 +114,5 @@ function renderThermostats() {
|
|||
});
|
||||
};
|
||||
|
||||
function renderVersion() {
|
||||
$.ajax({
|
||||
url: jsconfig.baseurl + "/api/version"
|
||||
}).then(function(data) {
|
||||
var versionText = "TempGopher © 2018 Mike Shoup | Version: " + data.version;
|
||||
$("#version").text(versionText);
|
||||
});
|
||||
};
|
||||
$(document).ready(renderVersion);
|
||||
|
||||
$(document).ready(renderThermostats);
|
||||
var rtHandle = window.setInterval(renderThermostats, 60000);
|
||||
|
|
|
|||
9
html/js/version.js
Normal file
9
html/js/version.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function renderVersion() {
|
||||
$.ajax({
|
||||
url: jsconfig.baseurl + "/api/version"
|
||||
}).then(function(data) {
|
||||
var versionText = "TempGopher © 2018 Mike Shoup | Version: " + data.version;
|
||||
$("#version").text(versionText);
|
||||
});
|
||||
};
|
||||
$(document).ready(renderVersion);
|
||||
40
html/login.html
Normal file
40
html/login.html
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Temp Gopher</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/skeleton.css">
|
||||
<link rel="icon" type="image/png" href="img/favicon.png">
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="/jsconfig.js"></script>
|
||||
<script src="js/version.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row" style="margin-top: 5%">
|
||||
<div class="four columns offset-by-four"><h3 style="text-align: center">Login</h3></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="two columns offset-by-two" style="text-align: right">Username:</div>
|
||||
<div class="four columns"><input type="text" style="width: 100%" id="loginName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="two columns offset-by-two" style="text-align: right">Password:</div>
|
||||
<div class="four columns"><input type="password" style="width: 100%" id="loginPassword" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="four columns offset-by-four"><button type="submit" style="width: 100%" class="button button-primary">Login</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row" style="margin-top: 10rem">
|
||||
<h6 id="version"></h6>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
10
web.go
10
web.go
|
|
@ -126,15 +126,19 @@ func SetupRouter(config *Config, states *map[string]State) *gin.Engine {
|
|||
r.GET("/ping", PingHandler)
|
||||
|
||||
// API Endpoints
|
||||
api := r.Group("/api", gin.BasicAuth(GetGinAccounts(config)))
|
||||
{
|
||||
var api *gin.RouterGroup
|
||||
if len(config.Users) == 0 {
|
||||
api = r.Group("/api")
|
||||
} else {
|
||||
api = r.Group("/api", gin.BasicAuth(GetGinAccounts(config)))
|
||||
}
|
||||
|
||||
api.GET("/status", StatusHandler(states))
|
||||
api.GET("/status/*alias", StatusHandler(states))
|
||||
api.GET("/version", VersionHandler)
|
||||
api.GET("/config", ConfigHandler(config))
|
||||
api.GET("/config/sensors/*alias", ConfigHandler(config))
|
||||
api.POST("/config/sensors", UpdateSensorsHandler)
|
||||
}
|
||||
|
||||
// App
|
||||
r.GET("/jsconfig.js", JSConfigHandler(config))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue