2017-03-01 14:30:25 +00:00
|
|
|
import { Component, ViewChild, OnInit } from '@angular/core';
|
|
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
import { DocumentService, DocumentContents } from 'app/documents/document.service';
|
2017-03-05 21:25:41 +00:00
|
|
|
import { NavigationService, NavigationViews, NavigationNode } from 'app/navigation/navigation.service';
|
2017-03-01 23:05:16 +00:00
|
|
|
import { SearchService, QueryResults } from 'app/search/search.service';
|
2017-02-02 23:02:23 -08:00
|
|
|
|
2017-01-27 00:20:51 -08:00
|
|
|
@Component({
|
2017-02-02 12:10:47 -08:00
|
|
|
selector: 'aio-shell',
|
2017-03-01 14:30:25 +00:00
|
|
|
template: `
|
|
|
|
<md-toolbar color="primary" class="app-toolbar">
|
|
|
|
<button *ngIf="isHamburgerVisible" class="hamburger" md-button (click)="sidenav.toggle()"><md-icon>menu</md-icon></button>
|
|
|
|
<aio-top-menu [nodes]="(navigationViews | async)?.TopBar"></aio-top-menu>
|
|
|
|
<md-input-container >
|
2017-03-02 13:28:28 +00:00
|
|
|
<input mdInput placeholder="Search" (keyup)="onSearch($event.target.value)">
|
2017-03-01 14:30:25 +00:00
|
|
|
</md-input-container>
|
|
|
|
<span class="fill-remaining-space"></span>
|
|
|
|
</md-toolbar>
|
|
|
|
|
|
|
|
<md-sidenav-container class="sidenav-container" (window:resize)="onResize($event.target.innerWidth)">
|
|
|
|
|
|
|
|
<md-sidenav #sidenav class="sidenav" [opened]="isSideBySide" [mode] = "this.isSideBySide ? 'side' : 'over'">
|
2017-03-05 21:25:41 +00:00
|
|
|
<aio-nav-menu [nodes]="(navigationViews | async)?.SideNav" [selectedNodes]="selectedNodes | async"></aio-nav-menu>
|
2017-03-01 14:30:25 +00:00
|
|
|
</md-sidenav>
|
|
|
|
|
|
|
|
<section class="sidenav-content">
|
|
|
|
<div class="search-results">
|
|
|
|
<div *ngFor="let result of (searchResults | async)?.results">
|
|
|
|
<a href="{{ result.path }}">{{ result.title }}</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<aio-doc-viewer [doc]="currentDocument | async"></aio-doc-viewer>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
</md-sidenav-container>`,
|
|
|
|
styles: [
|
|
|
|
`.fill-remaining-space {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
md-input-container {
|
|
|
|
margin-left: 10px;
|
|
|
|
input {
|
|
|
|
min-width:200px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.md-input-element {
|
|
|
|
font-size: 70%;
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 600px) {
|
|
|
|
aio-menu {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.sidenav-container {
|
|
|
|
width: 100%;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
.sidenav-content {
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
margin: auto;
|
|
|
|
padding: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.sidenav-content button {
|
|
|
|
min-width: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.sidenav {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// md-toolbar {
|
|
|
|
// display: none;
|
|
|
|
// padding-left: 10px !important;
|
|
|
|
// }
|
|
|
|
// md-toolbar.active {
|
|
|
|
// display: block;
|
|
|
|
// }`
|
|
|
|
]
|
2017-01-27 00:20:51 -08:00
|
|
|
})
|
2017-03-01 14:30:25 +00:00
|
|
|
export class AppComponent implements OnInit {
|
2017-03-02 13:28:28 +00:00
|
|
|
readonly sideBySideWidth = 600;
|
|
|
|
|
2017-02-15 11:22:37 -08:00
|
|
|
isHamburgerVisible = true; // always ... for now
|
2017-03-01 14:30:25 +00:00
|
|
|
isSideBySide = false;
|
|
|
|
|
|
|
|
currentDocument: Observable<DocumentContents>;
|
|
|
|
navigationViews: Observable<NavigationViews>;
|
2017-03-05 21:25:41 +00:00
|
|
|
selectedNodes: Observable<NavigationNode[]>;
|
2017-03-01 23:05:16 +00:00
|
|
|
searchResults: Observable<QueryResults>;
|
2017-03-01 14:30:25 +00:00
|
|
|
|
2017-03-01 23:05:16 +00:00
|
|
|
constructor(documentService: DocumentService, navigationService: NavigationService, private searchService: SearchService) {
|
2017-03-01 14:30:25 +00:00
|
|
|
this.currentDocument = documentService.currentDocument;
|
|
|
|
this.navigationViews = navigationService.navigationViews;
|
2017-03-06 10:13:49 +00:00
|
|
|
this.selectedNodes = navigationService.selectedNodes;
|
2017-03-01 23:05:16 +00:00
|
|
|
this.searchResults = searchService.searchResults;
|
2017-03-01 14:30:25 +00:00
|
|
|
}
|
2017-02-15 11:22:37 -08:00
|
|
|
|
2017-03-01 14:30:25 +00:00
|
|
|
ngOnInit() {
|
2017-03-02 12:20:26 +00:00
|
|
|
this.searchService.initWorker('app/search/search-worker.js');
|
|
|
|
this.searchService.loadIndex();
|
|
|
|
|
2017-03-01 14:30:25 +00:00
|
|
|
this.onResize(window.innerWidth);
|
|
|
|
}
|
2017-02-15 11:22:37 -08:00
|
|
|
|
2017-03-01 14:30:25 +00:00
|
|
|
onResize(width) {
|
|
|
|
this.isSideBySide = width > this.sideBySideWidth;
|
|
|
|
}
|
2017-03-01 23:05:16 +00:00
|
|
|
|
2017-03-02 13:28:28 +00:00
|
|
|
onSearch(query: string) {
|
2017-03-01 23:05:16 +00:00
|
|
|
this.searchService.search(query);
|
|
|
|
}
|
2017-01-27 00:20:51 -08:00
|
|
|
}
|