Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

lab #115

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
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
22 changes: 22 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Created by https://www.gitignore.io/api/node,vim,osx,macos,linux

*node_modules
.env
build
### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity



### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### macOS ###
# Icon must end with two \r
# Thumbnails
# Files that might appear in the root of a volume
# Directories potentially created on remote AFP share


### Linux ###

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# End of https://www.gitignore.io/api/node,vim,osx,macos,linux
l
Empty file added app/component/login/_login.scss
Empty file.
32 changes: 32 additions & 0 deletions app/component/login/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<section class="login-form">
<form
name="loginForm"
ng-submit="loginCtrl.login()" novalidate>
<div
ng-class="{
'error': loginForm.username.$invalid,
'success': loginForm.username.$valid
}">
<input type="text"
name="username"
placeholder="username"
ng-minlength="4"
ng-model="loginCtrl.user.username" required>
</div>

<div
ng-class="{
'error': loginForm.password.$invalid && loginForm.$submitted,
'success': loginForm.password.$valid
}">
<input type="password" name="password"
ng-disabled="loginForm.username.$invalid"
placeholder="password"
ng-minlength="3"
ng-model="loginCtrl.user.password" required>
</div>

<button class="btn-std">sign in</button>
</form>
</section>

27 changes: 27 additions & 0 deletions app/component/login/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

require('./_login.scss');

module.exports = {
template: require('./login.html'),
controller: ['$log', '$location', 'authService', LoginController],
controllerAs: 'loginCtrl'
};

function LoginController($log, $location, authService) {
$log.debug('LoginController');

authService.getToken()
.then( () => {
$location.url('/home');
});

this.login = function() {
$log.debug('loginCtrl.login');

authService.login(this.user)
.then( () => {
$location.url('/home');
});
};
}
Empty file.
39 changes: 39 additions & 0 deletions app/component/signup/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html ng-app="routesApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>routes app</title>
</head>
<body>
<header>
<h1>cfgram</h1>
</header>
<section class="signup">
<form class="signup-form"
ng-submit="signupCtrl.signup(signupCtrl.user)"
novalidate>
<input class="input-std"
type="text"
placeholder="name"
ng-minlength="4"
ng-model="signupCtrl.user.username" required>

<input class="input-std"
type="email"
placeholder="email"
ng-model="signupCtrl.user.email">

<input class="input-std"
type="password"
placeholder="password"
ng-minlength="3"
ng-model="signupCtrl.user.password" required>

<input type="submit" class="btn-std" value="sign up">
</form>
</section>
<footer></footer>
</body>
</html>
</html>
25 changes: 25 additions & 0 deletions app/component/signup/signup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

module.exports = {
template: require('./signup.html'),
controller: ['$log', '$location', 'authService', SignupController],
controllerAs: 'signupCtrl'
};

function SignupController($log, $location, authService) {
$log.debug('SignupController');

authService.getToken()
.then( () => {
$location.url('/home');
});

this.signup = function(user) {
$log.debug('signupCtrl.signup');

authService.signup(user)
.then( () => {
$location.url('/home');
});
};
}
31 changes: 31 additions & 0 deletions app/config/router-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

module.exports = ['$stateProvider', '$urlRouterProvider', routerConfig];

function routerConfig($stateProvider, $urlRouterProvider) {
$urlRouterProvider.when('', '/join#signup');
$urlRouterProvider.when('/', '/join#signup');
$urlRouterProvider.when('/signup', '/join#signup');
$urlRouterProvider.when('/login', '/join#login');

let states = [
{
name: 'home',
url: '/home',
template: require('../view/home/home.html'),
controller: 'HomeController',
controllerAs: 'homeCtrl'
},
{
name: 'landing',
url: '/join',
template: require('../view/landing/landing.html'),
controller: 'LandingController',
controllerAs: 'landingCtrl'
}
];

states.forEach( state => {
$stateProvider.state(state);
});
}
39 changes: 39 additions & 0 deletions app/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

require('./scss/main.scss');

const path = require('path');
const angular = require('angular');
const camelcase = require('camelcase');
const pascalcase = require('pascalcase');
const uiRouter = require('angular-ui-router');
const ngTouch = require('angular-touch');
const ngAnimate = require('angular-animate');

const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter]);

let context = require.context('./config/', true, /\.js$/);
context.keys().forEach( key => {
cfgram.config(context(key));
});

context = require.context('./view/', true, /\.js$/);
context.keys().forEach( key => {
let name = pascalcase(path.basename(key, '.js'));
let module = context(key);
cfgram.controller(name, module);
});

context = require.context('./service/', true, /\.js$/);
context.keys().forEach( key => {
let name = camelcase(path.basename(key, '.js'));
let module = context(key);
cfgram.service(name, module);
});

context = require.context('./component/', true, /\.js$/);
context.keys().forEach( key => {
let name = camelcase(path.basename(key, '.js'));
let module = context(key);
cfgram.component(name, module);
});
12 changes: 12 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html ng-app="cfgram">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>cfgram.</title>
</head>
<body>
<ui-view></ui-view>
</body>
</html>

3 changes: 3 additions & 0 deletions app/scss/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: lightgrey;
}
Loading