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

test project #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .eslintignore
100644 → 100755
Empty file.
Empty file modified .eslintrc
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified gulpfile.js/config/index.js
100644 → 100755
Empty file.
Empty file modified gulpfile.js/error/index.js
100644 → 100755
Empty file.
Empty file modified gulpfile.js/index.js
100644 → 100755
Empty file.
Empty file modified gulpfile.js/server/index.js
100644 → 100755
Empty file.
210 changes: 210 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@
"license": "UNLICENSED",
"private": true,
"authors": "Anid Monsur <[email protected]>",
"repository": "bookbottles/showcase"
"repository": "bookbottles/showcase",
"dependencies": {
"angular-validation-match": "^1.9.0",
"angularfire": "^2.0.2",
"firebase": "^3.4.1"
}
}
30 changes: 30 additions & 0 deletions src/app/login/controllers/LoginCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

module.exports = LoginCtrl;

/**
* @ngInject
*/
function LoginCtrl($state, UserService) {
var vm = this;

vm.login = function(form) {
vm.submitted = true;

if (form.$valid) {
UserService.login({
name: vm.user.name,
password: vm.user.password
})
.then(function(){
// Account validated, redirect to dashboard
$state.go('dashboard');
})
.catch(function(err){
vm.errors = {};

vm.errors.other = err.message;
});
}
};
}
9 changes: 9 additions & 0 deletions src/app/login/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = require('angular')
.module('bookbottles.showcase.login', [
require('angular-ui-router')
])
.config(require('./route'))
.controller('LoginCtrl', require('./controllers/LoginCtrl'))
.name;
16 changes: 16 additions & 0 deletions src/app/login/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

module.exports = route;

/**
* @ngInject
*/
function route($stateProvider) {
// Configure states here
$stateProvider
.state('login', {
url: '/login',
template: require('./templates/login.tpl.jade'),
controller: 'LoginCtrl as vm'
});
}
26 changes: 26 additions & 0 deletions src/app/login/templates/login.tpl.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.container
.row
.col-sm-12
h1 Login
p
| Default Test User account is
code bookbottles
| /
code showcase
.col-sm-12
form.form(name='form', ng-submit='vm.login(form)', novalidate='')
.form-group
label Name
input.form-control(type='name', name='name', ng-model='vm.user.name', required='')
.form-group
label Password
input.form-control(type='password', name='password', ng-model='vm.user.password', required='')
.form-group.has-error
p.help-block(ng-show='form.name.$error.required && form.password.$error.required && vm.submitted')
| Please enter your name and password.
p.help-block(ng-show='vm.submitted') {{ vm.errors.other }}
div
button.btn.btn-inverse.btn-lg.btn-login(type='submit')
| Login
a.btn.btn-default.btn-lg.btn-register(ui-sref='signup')
| Register
25 changes: 25 additions & 0 deletions src/app/showcase/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

module.exports = auth;

/**
* @ngInject
*/
function auth($rootScope, $state, UserService) {
// Redirect to login if route requires auth and the user is not logged in, or doesn't have required role
$rootScope.$on('$stateChangeStart', function(event, next) {
if (!next.authenticate) {
return;
}

UserService.isLoggedIn()
.then(function(is) {
if (is) {
return;
}

event.preventDefault();
$state.go('login');
});
});
}
Empty file modified src/app/showcase/config.js
100644 → 100755
Empty file.
20 changes: 20 additions & 0 deletions src/app/showcase/controllers/DashboardCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

module.exports = DashboardCtrl;

/**
* @ngInject
*/
function DashboardCtrl($state, $scope, DataService) {
var vm = this;

vm.data = [];

DataService.fetchData($scope);

$scope.$on('DATA_LOADED', function(event, data){
$scope.$apply(function(){
vm.data = data;
});
});
}
20 changes: 20 additions & 0 deletions src/app/showcase/directives/DashboardDirective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

module.exports = DashboardDirective;

/**
* @ngInject
*/
function DashboardDirective() {
return {
template: require('./DashboardDirective.tpl.jade'),
restrict: 'E',
scope: {
data: '='
},
controller: function(){
},
controllerAs: 'ctrl',
bindToController: true
};
}
2 changes: 2 additions & 0 deletions src/app/showcase/directives/DashboardDirective.tpl.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
div(ng-repeat="item in ctrl.data")
p {{item.headline}}
Loading