Skip to content

Commit

Permalink
Bug fxbox#13 - Add very basic FTU, r=ferjm
Browse files Browse the repository at this point in the history
  • Loading branch information
Michiel de Jong committed Feb 5, 2016
1 parent 69675e4 commit 1855da2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ before_script:
- nvm install 4.2
- nvm use 4.2
- npm install selenium-webdriver
- hostname foxbox

script:
- cargo build # Linter is also executed here
Expand Down
5 changes: 5 additions & 0 deletions docs/user-manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Setting up your FoxBox

* Connect your FoxBox to your internet router, using the ethernet cable provided.
* Browse to [http://foxbox.local/](http://foxbox.local/).
* Follow the instructions there.
49 changes: 48 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,55 @@
<html>
<head>
<title>FoxBox</title>
<meta charset="utf-8">
</head>
<body>
<h1>Welcome To FoxBox!</h1>
<h1>Welcome to your FoxBox!</h1>
<p>
<label for="pwd1">Please choose an admin password (8 characters minimal):</label>
<input type="password" id="pwd1">
</p>
<p>
<label for="pwd1">Please repeat your admin password:</label>
<input type="password" id="pwd2">
</p>
<p>
<input type="submit" value="Set" onclick="setPassword();">
</p>
</body>
<script>
function success() {
document.body.innerHTML =
'<h1>Thank you!</h1>' +
'<p>Now please us an app like <a href="http://example.com/">http://example.com/</a> to connect your IoT '+
'devices and set everything up. Please write down the following information:</p>' +
'<ul><li>FoxBox location (\'' +
window.location.href +
'\')</li>' +
'<li>Your username (\'admin\')</li>' +
'<li>Your password (the one you just created).</li></ul></p>';
}
function setPassword() {
var pwd = document.getElementById('pwd1').value;
if (document.getElementById('pwd2').value != pwd) {
window.alert('Passwords don\'t match! Please try again.');
return;
}
if (pwd.length < 8) {
window.alert('Please use a password of at least 8 characters.');
return;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', '/v1/users/admin', true);
xhr.onload = function() {
if (xhr.status != 201) {
console.log('TO DO: Deal with unsuccessful API response', xhr.status, xhr.responseText);
}
success();
}
xhr.send(JSON.stringify({
password: pwd
}));
}
</script>
</html>

0 comments on commit 1855da2

Please sign in to comment.