Commit 6eb72d64 by Johannes Zellner

Add basic admin ui

1 parent 0fd8904c
......@@ -25,3 +25,7 @@ pre {
text-align: left;
width: 400px;
}
[v-cloak] {
display: none;
}
......@@ -5,21 +5,97 @@
<link rel="stylesheet" href="/admin/css/bootstrap.min.css">
<link rel="stylesheet" href="/admin/css/style.css">
<script src="/admin/js/jquery-1.12.1.min.js"></script>
<script src="/admin/js/bootstrap.min.js"></script>
</head>
<body>
<body id="app">
<nav class="navbar navbar-default" v-cloak>
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Surfer</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li v-show="session.valid"><a href="#">Upload</a></li>
<li v-show="session.valid"><a href="#" ng-click="logout()">Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container" v-show="busy" v-cloak>
<div class="row">
<div class="col-lg-12">
<center>
Loading...
</center>
</div>
</div>
</div>
<div class="wrapper">
<div class="content">
<h1> Surfer Admin </h1>
<p>
Upload some files using the commandline tool.
<button class="btn btn-primary">Foobar</button>
</p>
<div class="container" v-show="!session.valid && !busy" v-cloak>
<div class="row">
<div class="col-lg-6 col-lg-offset-3">
<form v-on:submit.prevent="login()">
<div class="form-group">
<label for="inputUsername">Username</label>
<input type="text" class="form-control" id="inputUsername" v-model="loginData.username" placeholder="Username">
</div>
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" v-model="loginData.password" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
<div class="container" v-show="session.valid && !busy" v-cloak>
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Library</a></li>
<li class="active">Data</li>
</ol>
</div>
<div class="col-lg-12">
<table class="table table-hover">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Size</th>
<th>Modified</th>
</tr>
</thead>
<tbody>
<tr>
<th>Type</th>
<th>Name</th>
<th>Size</th>
<th>Modified</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="/admin/js/jquery-1.12.1.min.js"></script>
<script src="/admin/js/bootstrap.min.js"></script>
<script src="/admin/js/vue.min.js"></script>
<script src="/admin/js/superagent.js"></script>
<script src="/admin/js/app.js"></script>
</body>
</html>
(function () {
'use strict';
function login(username, password) {
username = username || app.loginData.username;
password = password || app.loginData.password;
app.busy = true;
superagent.get('/api/files/').query({ username: username, password: password }).end(function (error, result) {
app.busy = false;
if (error) return console.error(error);
if (result.statusCode === 401) return console.error('Invalid credentials');
app.session.valid = true;
app.session.username = username;
app.session.password = password;
// clearly not the best option
localStorage.username = username;
localStorage.password = password;
});
}
function logout() {
app.session.valid = false;
app.session.username = username;
app.session.password = password;
delete localStorage.username;
delete localStorage.password;
}
var app = new Vue({
el: '#app',
data: {
busy: true,
session: {
valid: false
},
loginData: {
}
},
methods: {
login: login,
logout: logout
}
});
window.app = app;
login(localStorage.username, localStorage.password);
})();
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!