Seperate electron and web target building
This commit is contained in:
committed by
József Farkas
parent
517aed1b1c
commit
983eb72892
2
shared/src/components/macro/not-found/index.ts
Normal file
2
shared/src/components/macro/not-found/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { MacroNotFoundComponent } from './macro-not-found.component';
|
||||
export { MacroNotFoundGuard } from './macro-not-found-guard.service';
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanActivate, Router } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import 'rxjs/add/operator/let';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { AppState } from '../../../store/index';
|
||||
import { getMacroEntities } from '../../../store/reducers';
|
||||
|
||||
@Injectable()
|
||||
export class MacroNotFoundGuard implements CanActivate {
|
||||
|
||||
constructor(private store: Store<AppState>, private router: Router) { }
|
||||
|
||||
canActivate(): Observable<boolean> {
|
||||
return this.store
|
||||
.let(getMacroEntities())
|
||||
.map(macros => {
|
||||
const hasMacros = macros.length > 0;
|
||||
if (hasMacros) {
|
||||
this.router.navigate(['/macro', macros[0].id]);
|
||||
}
|
||||
return !hasMacros;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="not-found">
|
||||
You don't have any macros. Try to add one!
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
.not-found {
|
||||
margin-top: 30px;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'macro-not-found',
|
||||
template: require('./macro-not-found.component.html'),
|
||||
styles: [require('./macro-not-found.component.scss')]
|
||||
})
|
||||
export class MacroNotFoundComponent { }
|
||||
Reference in New Issue
Block a user