mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-12 11:15:22 +02:00
history navigation i,proved
This commit is contained in:
parent
f8db033c56
commit
5ce3f0bcb8
@ -18,7 +18,7 @@ import {GeneratedUrl} from "angular2/src/router/rules/route_paths/route_path";
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'pi-gallery2-app',
|
selector: 'pi-gallery2-app',
|
||||||
template: `<router-outlet></router-outlet>`,
|
template: `<router-outlet></router-outlet>`,
|
||||||
directives: [ROUTER_DIRECTIVES],
|
directives: [ROUTER_DIRECTIVES, RouterLink],
|
||||||
providers: [
|
providers: [
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
ROUTER_PROVIDERS,
|
ROUTER_PROVIDERS,
|
||||||
@ -33,12 +33,17 @@ import {GeneratedUrl} from "angular2/src/router/rules/route_paths/route_path";
|
|||||||
name: 'Login',
|
name: 'Login',
|
||||||
component: LoginComponent,
|
component: LoginComponent,
|
||||||
useAsDefault: true
|
useAsDefault: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
regex: '/gallery(/([\S]*))?',
|
path: '/gallery',
|
||||||
|
name: 'GalleryBase',
|
||||||
|
component: GalleryComponent
|
||||||
|
},
|
||||||
|
{
|
||||||
|
regex: 'gallery/([\w]*)',
|
||||||
name: 'Gallery',
|
name: 'Gallery',
|
||||||
serializer: (params): GeneratedUrl => {
|
serializer: (params): GeneratedUrl => {
|
||||||
return new GeneratedUrl(`/gallery/${params['directory']}`, {})
|
return new GeneratedUrl(`gallery/${params['directory']}`, {})
|
||||||
},
|
},
|
||||||
component: GalleryComponent
|
component: GalleryComponent
|
||||||
}
|
}
|
||||||
@ -46,13 +51,14 @@ import {GeneratedUrl} from "angular2/src/router/rules/route_paths/route_path";
|
|||||||
export class AppComponent implements OnInit{
|
export class AppComponent implements OnInit{
|
||||||
|
|
||||||
constructor(private _router: Router, private _location:Location, private _authenticationService: AuthenticationService){
|
constructor(private _router: Router, private _location:Location, private _authenticationService: AuthenticationService){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._authenticationService.OnAuthenticated.on((user:User) =>
|
this._authenticationService.OnAuthenticated.on((user:User) =>
|
||||||
{
|
{
|
||||||
this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
// this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
||||||
this._router.navigate(["Gallery",{directory:"/"}]);
|
this._router.navigate(["GalleryBase"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
<a [routerLink]="['Gallery',{directory: getDirectoryPath()}]">{{directory.name}}</a>
|
<a [routerLink]="['/Gallery',{directory: getDirectoryPath()}]">{{directory.name}}</a>
|
@ -23,18 +23,17 @@ export class GalleryComponent implements OnInit{
|
|||||||
private _params: RouteParams,
|
private _params: RouteParams,
|
||||||
private _authService: AuthenticationService,
|
private _authService: AuthenticationService,
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private _location:Location) {
|
private _location:Location) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(){
|
ngOnInit(){
|
||||||
if (!this._authService.isAuthenticated()) {
|
if (!this._authService.isAuthenticated()) {
|
||||||
this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
// this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
||||||
this._router.navigate(['Login']);
|
this._router.navigate(['Login']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(this._params.get('directory'));
|
|
||||||
let directoryName = this._params.get('directory');
|
let directoryName = this._params.get('directory');
|
||||||
directoryName = directoryName ? directoryName : "";
|
directoryName = directoryName ? directoryName : "";
|
||||||
this._galleryService.getDirectory(directoryName).then(( message:Message<Directory>) => {
|
this._galleryService.getDirectory(directoryName).then(( message:Message<Directory>) => {
|
||||||
if(message.error){
|
if(message.error){
|
||||||
|
@ -18,7 +18,7 @@ export class LoginComponent implements OnInit{
|
|||||||
|
|
||||||
ngOnInit(){
|
ngOnInit(){
|
||||||
if (this._authService.isAuthenticated()) {
|
if (this._authService.isAuthenticated()) {
|
||||||
this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
// this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
||||||
this._router.navigate(['Gallery']);
|
this._router.navigate(['Gallery']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<pi-gallery2-app>Loading...</pi-gallery2-app>
|
<pi-gallery2-app>Loading...</pi-gallery2-app>
|
||||||
</body>
|
</body>
|
||||||
<script src="https://code.angularjs.org/2.0.0-beta.10/angular2-polyfills.js"></script>
|
<script src="https://code.angularjs.org/2.0.0-beta.12/angular2-polyfills.js"></script>
|
||||||
<script src="dist/app-bundle.js"></script>
|
<script src="dist/app-bundle.js"></script>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user