Skip to content

Commit e76d0a8

Browse files
committed
Merge branch 'master' of github.com:aniknafs/generator-angular-fullstack
2 parents c262211 + 73d15dd commit e76d0a8

File tree

10 files changed

+130
-7
lines changed

10 files changed

+130
-7
lines changed

Diff for: daux/templates/layout/00_layout.php

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
echo "<link href='$css' rel='stylesheet' type='text/css'>";
2626
} ?>
2727

28+
<link href="<?= $base_url; ?>docs.css" rel="stylesheet" type="text/css">
29+
2830
<?php if ($params['html']['search']) {
2931
?>
3032
<!-- Tipue Search -->

Diff for: docs/02_Developing/00_Starting_Up.md

+22-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ webpack: bundle is now VALID.
8080
And then our default browser should open up to the app:
8181

8282

83-
<img src="/images/afs-screenshot.png" style="max-width: 800px; box-shadow: 0px 6px 6px -3px rgba(0, 0, 0, 0.2), 0px 10px 14px 1px rgba(0, 0, 0, 0.14), 0px 4px 18px 3px rgba(0, 0, 0, 0.12);" alt="App Screenshot">
83+
<img src="../images/afs-screenshot.png" alt="App Screenshot">
8484

8585

8686
Fantastic! We're now up and running with our Full-Stack Angular web application! So what can it do?
@@ -90,11 +90,29 @@ Fantastic! We're now up and running with our Full-Stack Angular web application!
9090
Assuming you scaffolded with a back-end database, you should see some 'features'. If you scaffolded with socket.io, you should see 'x' buttons next to each, and an input box. Try opening two browser windows to the same page side-by-side, and hitting the 'x' on one of the features. You should see the feature get removed on both web pages. Neat! This is because these database object changes are communicated to clients using socket.io.
9191

9292

93-
<img src="/images/socket.io-demo.gif" style="max-width: 800px; box-shadow: 0px 6px 6px -3px rgba(0, 0, 0, 0.2), 0px 10px 14px 1px rgba(0, 0, 0, 0.14), 0px 4px 18px 3px rgba(0, 0, 0, 0.12);" alt="Socket.io demo">
93+
<img src="../images/socket.io-demo.gif" alt="Socket.io demo screenshot">
9494

9595

9696
Neat. Let's see what else we can do.
9797

98-
### Sign Up
98+
### Auth
9999

100-
[TODO]
100+
Assuming you scaffolded with auth support, you should see a 'Sign Up' and a 'Log In' button at the top-right of your page. Let's go to the Log In page.
101+
102+
You should see inputs for an email address and a password. When running your project in a devlopment environment, you'll get two user accounts automatically generated:
103+
104+
* Test User
105+
106+
* password: test
107+
* role: user
108+
* Admin
109+
110+
* password: admin
111+
* role: admin
112+
113+
Go ahead and log in with the admin account, so we can see the extra admin bits too. You should then get sent back to the home page, but should notice that the navbar looks a bit different:
114+
115+
<img src="../images/logged-in.jpg" alt="Logged in as admin screenshot">
116+
117+
118+
First, at the top right, we see a greeting for our username, a cog icon (for user settings), and a logout button. Then, since we're an admin, we see a new 'Admin' state on the navbar. The admin section lists users and allows you to delete them. The user settings page allows you to change your password.

Diff for: docs/02_Developing/01_Adding_a_Route.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Adding a Route
2+
3+
Alright, now let's add another route to our app. We'll call it 'foo'. We can easily do this with the `yo angular-fullstack:route` subgenerator command:
4+
5+
```bash
6+
$ yo angular-fullstack:route foo
7+
? What module name would you like to use? (aftestApp.foo)
8+
? What module name would you like to use? aftestApp.foo
9+
? Where would you like to create this route? (client/app/)
10+
? Where would you like to create this route? client/app/
11+
? What will the url of your route be? (/foo)
12+
? What will the url of your route be? /foo
13+
identical client\app\foo\foo.routes.js
14+
identical client\app\foo\foo.component.js
15+
identical client\app\foo\foo.component.spec.js
16+
identical client\app\foo\foo.html
17+
identical client\app\foo\foo.scss
18+
19+
In the parent of this component, you should now import this component and add it as a dependency:
20+
21+
import FooComponent from './foo/foo.component';
22+
...
23+
export angular.module('myParentModule', [FooComponent]);
24+
```
25+
26+
We give it our route name ('foo'), and a few more details: the name of the Angular module to create ('myApp.foo'), which folder to put the route under ('client/app/foo/'), and the URL of the route ('localhost:3000/foo').
27+
28+
This will create an Angular 1.5 component with an Angular module (`foo.component.js`), a template file (`foo.html`), a CSS file (`foo.scss`), a unit test file (`foo.component.spec.js`), and a routing file (`foo.routes.js`).
29+
30+
Since we're using Webpack, We'll need to import our component somewhere. Since this is a generic app route (and for simplicity), we'll import it in `app.js`, under our root Angular module, like so:
31+
32+
`client/app/app.js`
33+
```js
34+
...
35+
import FooModule from './foo/foo.component';
36+
angular.module('aftestApp', [
37+
...
38+
main,
39+
FooModule,
40+
])
41+
.config(routeConfig)
42+
.run(...);
43+
44+
angular.element(document)
45+
.ready(() => {
46+
angular.bootstrap(document, ['aftestApp'], {
47+
strictDi: true
48+
});
49+
});
50+
```
51+
52+
Now that we've imported our new Angular module and added it to the dependency list of our root Angular module, we should be able to navigate to `http://localhost:3000/foo` and see our new route:
53+
54+
<img src="../images/foo-route.jpg" alt="Foo route screenshot">
55+
56+
It's not a very impressive page right now, but it works.
57+
58+
Now, our user's aren't going to know to go to the `/foo` route. Let's add a navbar entry for it.
59+
60+
`client/components/navbar/navbar.component.js`
61+
```js
62+
import angular from 'angular';
63+
64+
export class NavbarComponent {
65+
menu = [{
66+
title: 'Home',
67+
state: 'main'
68+
}, {
69+
title: 'Foo',
70+
state: 'foo'
71+
}];
72+
isCollapsed = true;
73+
74+
constructor(Auth) {
75+
'ngInject';
76+
this.isLoggedIn = Auth.isLoggedInSync;
77+
this.isAdmin = Auth.isAdminSync;
78+
this.getCurrentUser = Auth.getCurrentUserSync;
79+
}
80+
}
81+
82+
export default angular.module('directives.navbar', [])
83+
.component('navbar', {
84+
template: require('./navbar.html'),
85+
controller: NavbarComponent
86+
})
87+
.name;
88+
```
89+
90+
Easy enough. Now we should see our entry for 'Foo' in our navbar. It should also be highlighted if you're still on the '/foo' route.
91+
92+
<img src="../images/foo-route-navbar.jpg" alt="Foo route screenshot">
93+
94+
You can read about all the other subgenerators that are available in the [Generators](../Generators) section of the docs.

Diff for: docs/docs.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.s-content img {
2+
max-width: 800px;
3+
width: 100%;
4+
margin-bottom: 20px;
5+
box-shadow: 0px 6px 6px -3px rgba(0, 0, 0, 0.2),
6+
0px 10px 14px 1px rgba(0, 0, 0, 0.14),
7+
0px 4px 18px 3px rgba(0, 0, 0, 0.12);
8+
}

Diff for: docs/generators/app.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Sets up a new AngularJS + Express app, generating all the boilerplate you need t
44
Usage:
55
```bash
66
Usage:
7+
yo angular-fullstack [options] [<name>]
78
yo angular-fullstack:app [options] [<name>]
89

910
Options:

Diff for: docs/generators/route.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Produces:
2020
Your new `myroute.component.js` will contain Angular code registering a new module, defaulting to `myApp.myRoute`. The default export of the component will be this name. Make sure to import this name in a parent Angular module, and add it as a dependency like so:
2121

2222
```js
23-
import myRouteComponent from './myroute/myroute.component';
23+
import MyRouteModule from './myroute/myroute.component';
2424

2525
...
2626

27-
angular.module('myApp.myParent', [myRouteComponent]);
27+
angular.module('myApp.myParent', [MyRouteModule]);
2828
```

Diff for: docs/images/foo-route-navbar.jpg

59.5 KB
Loading

Diff for: docs/images/foo-route.jpg

60.4 KB
Loading

Diff for: docs/images/logged-in.jpg

228 KB
Loading

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"babel-plugin-transform-flow-strip-types": "^6.14.0",
4444
"bluebird": "^3.4.5",
4545
"chalk": "^1.1.0",
46-
"generator-ng-component": "~1.0.3",
46+
"generator-ng-component": "~1.0.4",
4747
"glob": "^7.0.5",
4848
"gulp-babel": "^6.1.2",
4949
"gulp-beautify": "^2.0.0",

0 commit comments

Comments
 (0)