-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathapp.module.ts
More file actions
81 lines (75 loc) · 2.77 KB
/
Copy pathapp.module.ts
File metadata and controls
81 lines (75 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClient, provideHttpClient } from '@angular/common/http';
import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // <-- NgModel lives here
import { NGXLogger } from 'ngx-logger';
import { CookieService } from 'ngx-cookie-service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { CodeEditorModule } from '@acrodata/code-editor';
// service
import { AllServices } from '@app/services';
// Angular split
import { AppRouterModule } from './router.module';
import { SharedPipeModule } from './pipes/pipes';
import { AppComponent } from './pages/app.component';
import { ElementComponents } from './elements/elements.component';
import { PluginModules } from './plugins/plugins';
import { ClipboardService } from 'ngx-clipboard';
import { version } from '../environments/environment';
import { BehaviorSubject, forkJoin, Observable, of } from 'rxjs';
import { FileInputAccessorModule } from 'file-input-accessor';
import { catchError, mergeMap } from 'rxjs/operators';
import { PagesComponents } from './pages/pages.component';
import { getAppBasePath, withAppBase, withSitePrefix } from '@app/utils/path';
export class CustomLoader implements TranslateLoader {
constructor(private http: HttpClient) {}
public getTranslation(lang: String): Observable<any> {
const remote = withSitePrefix('/api/v1/settings/i18n/luna/?lang=' + lang + '&v=' + version);
const local = withAppBase('/assets/i18n/' + lang + '.json');
return forkJoin([
this.http.get(remote).pipe(catchError(() => of({}))),
this.http.get(local).pipe(catchError(() => of({})))
]).pipe(
mergeMap(res => {
const finalRes = Object.assign({}, res[1], res[0]);
return new BehaviorSubject(finalRes);
})
);
}
}
@NgModule({
imports: [
DragDropModule,
BrowserModule,
CommonModule,
FormsModule,
AppRouterModule,
SharedPipeModule,
ReactiveFormsModule,
FileInputAccessorModule,
BrowserAnimationsModule,
CodeEditorModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: CustomLoader,
deps: [HttpClient]
}
}),
...PluginModules
],
declarations: [AppComponent, ...ElementComponents, ...PagesComponents] as any[],
bootstrap: [AppComponent],
providers: [
...AllServices,
{ provide: APP_BASE_HREF, useFactory: getAppBasePath },
CookieService,
NGXLogger,
ClipboardService,
provideHttpClient()
]
})
export class AppModule {}