Skip to content
This repository has been archived by the owner on Nov 16, 2019. It is now read-only.

Commit

Permalink
Added log-in view
Browse files Browse the repository at this point in the history
  • Loading branch information
martincarrera committed May 30, 2016
1 parent 18c5a1d commit 174aac0
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 44 deletions.
20 changes: 2 additions & 18 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<base href="/">
<title>Clash Royale CMS</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="style/styles.css">
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="bower_components/api-check/dist/api-check.min.js"></script>
Expand All @@ -28,23 +29,6 @@

</head>
<body ng-app="clash-royale-api">
<div class="container">
<nav class="navbar navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="/">
Clash Royale API
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a ui-sref="arenas">Arenas</a></li>
<li><a ui-sref="cards">Cards</a></li>
<li><a ui-sref="chests">Chests</a></li>
<li><a ui-sref="players">Players</a></li>
</ul>
</div>
</nav>
<div ui-view></div>
</div>
<div ui-view></div>
</body>
</html>
36 changes: 31 additions & 5 deletions public/js/controllers/LoginController.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
(function () {

function LoginController() {
angular
.module('clash-royale-api')
.controller('LoginController', LoginController);

LoginController.$inject = ['LoginService'];

function LoginController(LoginService) {
var vm = this;
vm.title = 'Log In';
}
vm.model = {};
vm.fields = [
{
key: 'user',
type: 'input',
templateOptions: {
label: 'User',
required: true
}
},
{
key: 'password',
type: 'input',
templateOptions: {
label: 'Password',
required: true,
type: 'password',
}
},
];

angular
.module('clash-royale-api')
.controller('LoginController', LoginController);
vm.submit = function(model) {
LoginService.authenticate(model);
}
}

})();
12 changes: 2 additions & 10 deletions public/js/services/LoginService.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
angular.module('clash-royale-api').factory('LoginService', function($http) {

return {
get : function() {
return $http.get('/api/authentication');
},

create : function(userData) {
return $http.post('/api/authentication', cardData);
},

delete : function(id) {
return $http.delete('/api/authentication/' + id);
authenticate : function(userData) {
return $http.post('/api/authenticate', userData);
}
}

Expand Down
7 changes: 7 additions & 0 deletions public/style/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.form-signin {
min-height: 100vh;
padding: 15px;
display: flex;
align-items: center;
justify-content: center;
}
37 changes: 27 additions & 10 deletions public/views/genericTemplate.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
<div>
<div class="jumbotron text-center">
<h1>{{ vm.title }}</h1>
<div class="container">
<nav class="navbar navbar-inverse">
<div class="navbar-header">
<a class="navbar-brand" href="/">
Clash Royale API
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a ui-sref="arenas">Arenas</a></li>
<li><a ui-sref="cards">Cards</a></li>
<li><a ui-sref="chests">Chests</a></li>
<li><a ui-sref="players">Players</a></li>
</ul>
</div>
</nav>
<div>
<div class="jumbotron text-center">
<h1>{{ vm.title }}</h1>
</div>
<form ng-submit="vm.submit(vm.model)" novalidate>
<formly-form model="vm.model" fields="vm.fields" form="vm.form">
<button type="submit" ng-disabled="vm.form.$invalid" class="btn btn-default">Submit</button>
</formly-form>
</form>
<h2>{{ vm.previewTitle }}</h2>
<pre>{{ vm.model | json }}</pre>
</div>
<form ng-submit="vm.submit(vm.model)" novalidate>
<formly-form model="vm.model" fields="vm.fields" form="vm.form">
<button type="submit" ng-disabled="vm.form.$invalid" class="btn btn-default">Submit</button>
</formly-form>
</form>
<h2>{{ vm.previewTitle }}</h2>
<pre>{{ vm.model | json }}</pre>
</div>
7 changes: 7 additions & 0 deletions public/views/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="container">
<form class="form-signin" ng-submit="vm.submit(vm.model)" novalidate>
<formly-form model="vm.model" fields="vm.fields" form="vm.form">
<button type="submit" ng-disabled="vm.form.$invalid" class="btn btn-default">Submit</button>
</formly-form>
</form>
</div>
2 changes: 1 addition & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const authMiddleware = require('./middlewares/auth-middleware');
module.exports = (req, res, next) => {
req.app.use('/', mainRoute);
req.app.use('/api/authenticate', authRoute);
req.app.use('/cms/', cmsRoute);
if (!config.DISABLE_AUTH) {
req.app.use(authMiddleware);
}
req.app.use('/cms', cmsRoute);
req.app.use('/api/arenas', arenaRoute);
req.app.use('/api/cards', cardRoute);
req.app.use('/api/chests', chestRoute);
Expand Down

0 comments on commit 174aac0

Please sign in to comment.