app.module.ts 4.69 KB
Newer Older
1
2
3
4
5
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FormComponent } from './form/form.component';
6
import { ResultPageComponent } from './result-page/result-page.component';
7
import { GermplasmCardComponent } from './germplasm-card/germplasm-card.component';
8
import { GermplasmResultPageComponent } from './germplasm-result-page/germplasm-result-page.component';
9
10
import { StudyCardComponent } from './study-card/study-card.component';
import { SiteCardComponent } from './site-card/site-card.component';
11
import { HTTP_INTERCEPTORS, HttpClient, HttpClientModule } from '@angular/common/http';
12
import { NavbarComponent } from './navbar/navbar.component';
13
import { MapComponent } from './map/map.component';
14
import { NgbAlertModule, NgbDropdownModule, NgbPaginationModule, NgbPopoverModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
15
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
16
import { SuggestionFieldComponent } from './form/suggestion-field/suggestion-field.component';
17
import { DocumentComponent } from './result-page/document/document.component';
18
19
import { ErrorComponent } from './error/error.component';
import { ErrorInterceptorService } from './error-interceptor.service';
20
import { TraitOntologyWidgetComponent } from './form/trait-ontology-widget/trait-ontology-widget.component';
21
import { FacetsComponent } from './result-page/facets/facets.component';
22
import { CardRowComponent } from './card-row/card-row.component';
23
import { CardSectionComponent } from './card-section/card-section.component';
24
import { LoadingSpinnerComponent } from './loading-spinner/loading-spinner.component';
25
import { CardTableComponent } from './card-table/card-table.component';
26
import { CardSortableTableComponent } from './card-sortable-table/card-sortable-table.component';
27
import { MomentModule } from 'ngx-moment';
Thomas Letellier's avatar
Thomas Letellier committed
28
import { XrefsComponent } from './xrefs/xrefs.component';
29
import { CoordinatesModule } from 'angular-coordinates';
30
import { CardGenericDocumentComponent } from './card-generic-document/card-generic-document.component';
31
32
import { MarkdownModule, MarkedOptions, MarkedRenderer } from 'ngx-markdown';
import { MarkdownPageComponent } from './markdown-page/markdown-page.component';
33
34
import { NgbdSortableHeader } from './card-sortable-table/sortable.directive';
import { DecimalPipe } from '@angular/common';
35
36

@NgModule({
37
38
39
    declarations: [
        AppComponent,
        FormComponent,
40
        ResultPageComponent,
41
        GermplasmCardComponent,
42
        GermplasmResultPageComponent,
43
        GermplasmResultPageComponent,
44
        NgbdSortableHeader,
45
46
        StudyCardComponent,
        SiteCardComponent,
47
        NavbarComponent,
48
        MapComponent,
49
        SuggestionFieldComponent,
50
        DocumentComponent,
51
        ErrorComponent,
52
        TraitOntologyWidgetComponent,
53
        FacetsComponent,
54
55
        CardRowComponent,
        CardSectionComponent,
56
        LoadingSpinnerComponent,
57
        CardTableComponent,
58
        CardSortableTableComponent,
59
        XrefsComponent,
60
61
        CardGenericDocumentComponent,
        MarkdownPageComponent
62
63
64
65
    ],
    imports: [
        BrowserModule,
        AppRoutingModule,
66
        HttpClientModule,
67
        NgbTypeaheadModule,
68
        NgbPaginationModule,
69
        NgbAlertModule,
70
        NgbDropdownModule,
71
        NgbPopoverModule,
72
        FormsModule,
73
        ReactiveFormsModule,
74
        MomentModule,
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
        CoordinatesModule,
        MarkdownModule.forRoot({
            loader: HttpClient, // optional, only if you use [src] attribute
            markedOptions: {
                provide: MarkedOptions,
                useFactory: markedOptionsFactory,
                useValue: {
                    gfm: true, // default
                    tables: true,
                    breaks: false,
                    pedantic: false,
                    sanitize: false,
                    smartLists: true,
                    smartypants: false
                },
            }
        }),

93
    ],
94
    providers: [
95
96
        { provide: HTTP_INTERCEPTORS, useExisting: ErrorInterceptorService, multi: true },
        DecimalPipe
97
    ],
98
    bootstrap: [AppComponent]
99
})
100
101
export class AppModule {
}
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

export function markedOptionsFactory(): MarkedOptions {

    const renderer = new MarkedRenderer();

    renderer.link = (href: string, title: string, text: string) => {
        if (href.startsWith('#')) {
            const fragment = href.split('#')[1];
            return `<a href='${location.pathname}#${fragment}'>${text}</a>`;
        }
        return `<a href="${href}" target="_blank" >${text}</a>`;
    };
    return {
        renderer: renderer
    };
}