Skip to content

Commit

Permalink
Added reference view that uses GoldenLayout. All other views are brok…
Browse files Browse the repository at this point in the history
…en to varying degrees and search currently redirects to reference.
  • Loading branch information
alancleary committed Jun 3, 2019
1 parent 3af3853 commit 7d93946
Show file tree
Hide file tree
Showing 21 changed files with 354 additions and 111 deletions.
19 changes: 11 additions & 8 deletions client/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"node_modules/bootstrap-tour/build/css/bootstrap-tour.min.css",
"src/assets/css/gcv.css",
"src/assets/css/styles.css"
"node_modules/golden-layout/src/css/goldenlayout-base.css",
"node_modules/golden-layout/src/css/goldenlayout-light-theme.css",
"src/assets/css/styles.css",
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
"node_modules/golden-layout/dist/goldenlayout.min.js",
"node_modules/bootstrap-tour/build/js/bootstrap-tour.min.js",
"node_modules/golden-layout/dist/goldenlayout.min.js",
"src/assets/js/utils.js",
]
},
Expand Down Expand Up @@ -82,14 +83,16 @@
"karmaConfig": "src/karma.conf.js",
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"src/assets/css/gcv.css",
"src/assets/css/styles.css"
"node_modules/bootstrap-tour/build/css/bootstrap-tour.min.css",
"node_modules/golden-layout/src/css/goldenlayout-base.css",
"node_modules/golden-layout/src/css/goldenlayout-light-theme.css",
"src/assets/css/styles.css",
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
"node_modules/golden-layout/dist/goldenlayout.min.js",
"node_modules/bootstrap-tour/build/js/bootstrap-tour.min.js",
"node_modules/golden-layout/dist/goldenlayout.min.js",
"src/assets/js/utils.js",
],
"assets": [
Expand Down
8 changes: 8 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"circos": "^2.1.0",
"core-js": "^2.6.3",
"d3": "^5.8.2",
"golden-layout": "^1.5.9",
"jquery": "^3.3.1",
"rxjs": "^6.4.0",
"split.js": "^1.5.10",
Expand Down
46 changes: 31 additions & 15 deletions client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
// app
import { InstructionsComponent, MultiComponent, SearchComponent } from "./components";
import { InstructionsComponent, MultiComponent, ReferenceComponent, SearchComponent } from "./components";
import { DefaultSearchGuard, MultiGuard, SearchGuard, SpanSearchGuard } from "./guards";

const routes: Routes = [
Expand All @@ -11,37 +11,53 @@ const routes: Routes = [
pathMatch: "full",
redirectTo: "/instructions",
},
{
canActivate: [MultiGuard],
canDeactivate: [MultiGuard],
component: MultiComponent,
path: "multi/:genes",
},
{
path: "basic/:genes",
pathMatch: "full",
redirectTo: "multi/:genes",
},
{
component: InstructionsComponent,
path: "instructions",
},
{
canActivate: [DefaultSearchGuard], // use guard to redirect to default server in AppConfig
path: "search/:gene",
path: "reference/:gene",
pathMatch: "full",
component: SearchComponent,
},
{
canActivate: [SearchGuard],
canDeactivate: [SearchGuard],
component: SearchComponent,
path: "search/:source/:gene",
component: ReferenceComponent,
path: "reference/:source/:gene",
},
{
canActivate: [SpanSearchGuard],
component: SearchComponent,
path: "reference/:source/:chromosome/:span",
},
{
canActivate: [MultiGuard],
canDeactivate: [MultiGuard],
component: MultiComponent,
path: "multi/:genes",
},
// legacy
{
path: "search/:gene",
pathMatch: "full",
redirectTo: "reference/:gene",
},
{
path: "search/:source/:gene",
pathMatch: "full",
redirectTo: "reference/:source/:gene",
},
{
path: "search/:source/:chromosome/:span",
pathMatch: "full",
redirectTo: "reference/:source/:chromosome/:span",
},
{
path: "basic/:genes",
pathMatch: "full",
redirectTo: "multi/:genes",
},
];

Expand Down
12 changes: 8 additions & 4 deletions client/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Angular
import { HttpClientModule } from "@angular/common/http";
import { APP_INITIALIZER, NgModule } from "@angular/core";
import { APP_INITIALIZER, NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
Expand All @@ -9,7 +9,10 @@ import { AppConfig } from "./app.config";
import { AppRoutingModule } from "./app-routing.module";
// components
import * as fromComponents from "./components";
import { AlertComponent } from "./components";
import { AlertComponent, MacroComponent, MicroComponent, PlotComponent }
from "./components";
// directives
import * as fromDirectives from "./directives";
// services
import * as fromServices from "./services";
// route guards
Expand All @@ -23,8 +26,8 @@ import { CustomRouterStateSerializer } from "./utils";

@NgModule({
bootstrap: [ fromComponents.AppComponent ],
declarations: [ ...fromComponents.components ],
entryComponents: [ AlertComponent ],
declarations: [ ...fromComponents.components, ...fromDirectives.directives ],
entryComponents: [ AlertComponent, MacroComponent, MicroComponent, PlotComponent ],
imports: [
AppRoutingModule,
BrowserAnimationsModule,
Expand All @@ -47,5 +50,6 @@ import { CustomRouterStateSerializer } from "./utils";
...fromServices.services,
...fromGuards.guards
],
schemas: [ NO_ERRORS_SCHEMA ],
})
export class AppModule { }
19 changes: 18 additions & 1 deletion client/src/app/components/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,24 @@ declare var window: any;

@Component({
selector: "app-root",
template: "<router-outlet></router-outlet>",
template: `
<header>
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<!-- TODO: load image, title, and subtitle from config -->
<img src="https://getbootstrap.com/docs/4.3/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
LIS - Legume Information System
<!-- TODO: subtitle -->
</a>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-dark my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
</header>
<router-outlet></router-outlet>
`,
})
export class AppComponent implements OnInit {

Expand Down
3 changes: 3 additions & 0 deletions client/src/app/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AppComponent } from "./app.component";
import * as fromInstructions from "./instructions";
import * as fromMulti from "./multi";
import * as fromReference from "./reference";
import * as fromSearch from "./search";
import * as fromShared from "./shared";
import * as fromViewers from "./viewers";
Expand All @@ -9,6 +10,7 @@ export const components: any[] = [
AppComponent,
...fromInstructions.components,
...fromMulti.components,
...fromReference.components,
...fromSearch.components,
...fromShared.components,
...fromViewers.components,
Expand All @@ -17,6 +19,7 @@ export const components: any[] = [
export * from "./app.component";
export * from "./instructions";
export * from "./multi";
export * from "./reference";
export * from "./search";
export * from "./shared";
export * from "./viewers";
25 changes: 25 additions & 0 deletions client/src/app/components/reference/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//import { ScrollComponent } from "./scroll.component";
//import { SearchParamsComponent } from "./search-params.component";
import { MacroComponent } from "./macro.component";
import { MicroComponent } from "./micro.component";
import { PlotComponent } from "./plot.component";
import { ReferenceComponent } from "./reference.component";
//import { VisualizationComponent } from "./visualization.component";

export const components: any[] = [
//ScrollComponent,
//SearchParamsComponent,
MacroComponent,
MicroComponent,
PlotComponent,
ReferenceComponent,
//VisualizationComponent,
];

//export * from "./scroll.component";
//export * from "./search-params.component";
export * from "./macro.component";
export * from "./micro.component";
export * from "./plot.component";
export * from "./reference.component";
//export * from "./visualization.component";
23 changes: 23 additions & 0 deletions client/src/app/components/reference/macro.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Angular + dependencies
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild }
from "@angular/core";
import { GCV } from "../../../assets/js/gcv";

@Component({
selector: "macro",
styles: [],
template: "<div #container></div>",
})
export class MacroComponent implements AfterViewInit, OnDestroy {

@ViewChild("container") container: ElementRef;

ngAfterViewInit() {
//const viewer = new GCV.visualization.Micro(this.container.nativeElement);
this.container.nativeElement.innerHTML = "macro-synteny viewer";
}

ngOnDestroy() {
console.log('macro destroyed');
}
}
34 changes: 34 additions & 0 deletions client/src/app/components/reference/micro.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Angular + dependencies
import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, Output,
ViewChild } from "@angular/core";
import { GCV } from "../../../assets/js/gcv";

@Component({
selector: "micro",
styles: [],
template: `
<div #container>
micro-synteny viewer
<a class="btn btn-primary" (click)="spawnPlot()">Plot</a>
</div>
`,
})
export class MicroComponent implements AfterViewInit, OnDestroy {

@Output() plot = new EventEmitter();

@ViewChild("container") container: ElementRef;

ngAfterViewInit() {
//const viewer = new GCV.visualization.Micro(this.container.nativeElement);
//this.container.nativeElement.innerHTML = "micro-synteny viewer";
}

ngOnDestroy() {
//console.log('destroyed');
}

spawnPlot() {
this.plot.emit();
}
}
23 changes: 23 additions & 0 deletions client/src/app/components/reference/plot.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Angular + dependencies
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild }
from "@angular/core";
import { GCV } from "../../../assets/js/gcv";

@Component({
selector: "plot",
styles: [],
template: "<div #container></div>",
})
export class PlotComponent implements AfterViewInit, OnDestroy {

@ViewChild("container") container: ElementRef;

ngAfterViewInit() {
//const viewer = new GCV.visualization.Micro(this.container.nativeElement);
this.container.nativeElement.innerHTML = "plot viewer";
}

ngOnDestroy() {
console.log('plot destroyed');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="viewers" [gcvGoldenLayout]="layoutComponents" [config]="layoutConfig">
7 changes: 7 additions & 0 deletions client/src/app/components/reference/reference.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.viewers {
position: absolute;
top: 57px;
right: 0;
bottom: 0;
left: 0;
}
48 changes: 48 additions & 0 deletions client/src/app/components/reference/reference.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Angular
import { Component, ViewChild } from "@angular/core";
// app
import { GoldenLayoutDirective } from "../../directives";
import { MacroComponent } from "./macro.component";
import { MicroComponent } from "./micro.component";
import { PlotComponent } from "./plot.component";

@Component({
selector: "reference",
styleUrls: ["./reference.component.scss"],
templateUrl: "./reference.component.html",
})
export class ReferenceComponent {

@ViewChild(GoldenLayoutDirective) goldenLayoutDirective;

layoutComponents = [
{component: MacroComponent, name: "macro"},
{component: MicroComponent, name: "micro"},
{component: PlotComponent, name: "plot"}
];
layoutConfig = {
content: [{
type: "column",
content: [
{
type: "component",
componentName: "macro",
isClosable: false
},
{
type: "component",
componentName: "micro",
componentState: {
inputs: {key: "value"},
outputs: {
plot: (() => {
this.goldenLayoutDirective.addItem({type: "component", componentName: "plot"});
})
},
},
isClosable: false
}
]
}]
};
}
Loading

0 comments on commit 7d93946

Please sign in to comment.