Skip to content

Commit 02a2ab4

Browse files
committed
Initial commit
0 parents  commit 02a2ab4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1505
-0
lines changed

.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
typings
33+
34+
# Optional npm cache directory
35+
.npm
36+
37+
# Optional REPL history
38+
.node_repl_history
39+
40+
# Generated files
41+
dist

.idea/catalog-ui.iml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+592
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Jason Watmore
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Tallerify Catalog UI

config/helpers.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var path = require('path');
2+
3+
var _root = path.resolve(__dirname, '..');
4+
5+
function root(args) {
6+
args = Array.prototype.slice.call(arguments, 0);
7+
return path.join.apply(path, [_root].concat(args));
8+
}
9+
10+
exports.root = root;

config/webpack.common.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
var webpack = require('webpack');
2+
var HtmlWebpackPlugin = require('html-webpack-plugin');
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
var helpers = require('./helpers');
5+
6+
module.exports = {
7+
entry: {
8+
'polyfills': './src/polyfills.ts',
9+
'vendor': './src/vendor.ts',
10+
'app': './src/main.ts'
11+
},
12+
13+
resolve: {
14+
extensions: ['.ts', '.js']
15+
},
16+
17+
module: {
18+
rules: [
19+
{
20+
test: /\.ts$/,
21+
loaders: [
22+
{
23+
loader: 'awesome-typescript-loader',
24+
options: { configFileName: helpers.root('src', 'tsconfig.json') }
25+
}, 'angular2-template-loader'
26+
]
27+
},
28+
{
29+
test: /\.html$/,
30+
loader: 'html-loader'
31+
},
32+
{
33+
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
34+
loader: 'file-loader?name=assets/[name].[hash].[ext]'
35+
},
36+
{
37+
test: /\.css$/,
38+
exclude: helpers.root('src', 'app'),
39+
loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' })
40+
},
41+
{
42+
test: /\.css$/,
43+
include: helpers.root('src', 'app'),
44+
loader: 'raw-loader'
45+
}
46+
]
47+
},
48+
49+
plugins: [
50+
// Workaround for angular/angular#11580
51+
new webpack.ContextReplacementPlugin(
52+
// The (\\|\/) piece accounts for path separators in *nix and Windows
53+
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
54+
helpers.root('./src'), // location of your src
55+
{} // a map of your routes
56+
),
57+
58+
new webpack.optimize.CommonsChunkPlugin({
59+
name: ['app', 'vendor', 'polyfills']
60+
}),
61+
62+
new HtmlWebpackPlugin({
63+
template: 'src/index.html'
64+
})
65+
]
66+
};

config/webpack.dev.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var webpackMerge = require('webpack-merge');
2+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
3+
var commonConfig = require('./webpack.common.js');
4+
var helpers = require('./helpers');
5+
6+
module.exports = webpackMerge(commonConfig, {
7+
devtool: 'cheap-module-eval-source-map',
8+
9+
output: {
10+
path: helpers.root('dist'),
11+
publicPath: 'http://localhost:8080/',
12+
filename: '[name].js',
13+
chunkFilename: '[id].chunk.js'
14+
},
15+
16+
plugins: [
17+
new ExtractTextPlugin('[name].css')
18+
],
19+
20+
devServer: {
21+
historyApiFallback: true,
22+
stats: 'minimal'
23+
}
24+
});

config/webpack.prod.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var webpack = require('webpack');
2+
var webpackMerge = require('webpack-merge');
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
var commonConfig = require('./webpack.common.js');
5+
var helpers = require('./helpers');
6+
7+
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
8+
9+
module.exports = webpackMerge(commonConfig, {
10+
devtool: 'source-map',
11+
12+
output: {
13+
path: helpers.root('dist'),
14+
publicPath: '/',
15+
filename: '[name].[hash].js',
16+
chunkFilename: '[id].[hash].chunk.js'
17+
},
18+
19+
plugins: [
20+
new webpack.NoEmitOnErrorsPlugin(),
21+
new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
22+
mangle: {
23+
keep_fnames: true
24+
}
25+
}),
26+
new ExtractTextPlugin('[name].[hash].css'),
27+
new webpack.DefinePlugin({
28+
'process.env': {
29+
'ENV': JSON.stringify(ENV)
30+
}
31+
}),
32+
new webpack.LoaderOptionsPlugin({
33+
htmlLoader: {
34+
minimize: false // workaround for ng2
35+
}
36+
})
37+
]
38+
});
39+

package.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "tallerify-catalog-ui",
3+
"version": "1.0.0",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/tallerify/catalog-ui.git"
7+
},
8+
"scripts": {
9+
"start": "webpack-dev-server --inline --progress --port 8080",
10+
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
11+
},
12+
"license": "MIT",
13+
"dependencies": {
14+
"@angular/common": "~2.4.0",
15+
"@angular/compiler": "~2.4.0",
16+
"@angular/core": "~2.4.0",
17+
"@angular/forms": "~2.4.0",
18+
"@angular/http": "~2.4.0",
19+
"@angular/platform-browser": "~2.4.0",
20+
"@angular/platform-browser-dynamic": "~2.4.0",
21+
"@angular/router": "~3.4.0",
22+
"core-js": "^2.4.1",
23+
"rxjs": "5.0.1",
24+
"zone.js": "^0.7.4"
25+
},
26+
"devDependencies": {
27+
"@types/node": "^6.0.45",
28+
"angular2-template-loader": "^0.6.0",
29+
"awesome-typescript-loader": "^3.0.4",
30+
"css-loader": "^0.26.1",
31+
"extract-text-webpack-plugin": "2.0.0-beta.5",
32+
"file-loader": "^0.9.0",
33+
"html-loader": "^0.4.3",
34+
"html-webpack-plugin": "^2.16.1",
35+
"jasmine-core": "^2.4.1",
36+
"null-loader": "^0.1.1",
37+
"raw-loader": "^0.5.1",
38+
"rimraf": "^2.5.2",
39+
"style-loader": "^0.13.1",
40+
"typescript": "~2.0.10",
41+
"webpack": "2.2.1",
42+
"webpack-dev-server": "2.4.1",
43+
"webpack-merge": "^3.0.0"
44+
}
45+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div *ngIf="message" [ngClass]="{ 'alert': message, 'alert-success': message.type === 'success', 'alert-danger': message.type === 'error' }">{{message.text}}</div>
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
import { AlertService } from '../_services/index';
4+
5+
@Component({
6+
moduleId: module.id.toString(),
7+
selector: 'alert',
8+
templateUrl: 'alert.component.html'
9+
})
10+
11+
export class AlertComponent {
12+
message: any;
13+
14+
constructor(private alertService: AlertService) { }
15+
16+
ngOnInit() {
17+
this.alertService.getMessage().subscribe(message => { this.message = message; });
18+
}
19+
}

src/app/_directives/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './alert.component';

src/app/_guards/auth.guard.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Injectable } from '@angular/core';
2+
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
3+
4+
@Injectable()
5+
export class AuthGuard implements CanActivate {
6+
7+
constructor(private router: Router) { }
8+
9+
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
10+
if (localStorage.getItem('currentUser')) {
11+
// logged in so return true
12+
return true;
13+
}
14+
15+
// not logged in so redirect to login page with the return url
16+
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
17+
return false;
18+
}
19+
}

src/app/_guards/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './auth.guard';

0 commit comments

Comments
 (0)