Some refactoring
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// angular modules
|
||||
import { NgModule, APP_INITIALIZER, ModuleWithProviders, Injector } from '@angular/core';
|
||||
import { NgModule, APP_INITIALIZER, ModuleWithProviders, Injector,Optional,SkipSelf } from '@angular/core';
|
||||
import { CommonModule, DatePipe } from '@angular/common';
|
||||
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
@@ -137,6 +137,12 @@ export {FolderService,
|
||||
]
|
||||
})
|
||||
export class AppCommonModule {
|
||||
constructor (@Optional() @SkipSelf() parentModule: AppCommonModule) {
|
||||
if (parentModule) {
|
||||
throw new Error(
|
||||
'AppCommonModule is already loaded. Import it in the AppModule only');
|
||||
}
|
||||
}
|
||||
static forRoot(): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: AppCommonModule,
|
||||
@@ -152,19 +158,7 @@ export class AppCommonModule {
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: AccessTokenInterceptor,
|
||||
multi: true
|
||||
},
|
||||
ResumableFileUploadService,
|
||||
EventService,
|
||||
FolderService,
|
||||
UserService,
|
||||
ItemService,
|
||||
TypeaheadService,
|
||||
AuthCallbackGuard,
|
||||
AuthGuard,
|
||||
NavBarGuard,
|
||||
FullScreenGuard,
|
||||
TimespanService,
|
||||
ItemTypeService
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
@@ -13,7 +13,9 @@ import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import * as appCommonActions from '../actions/app-common.actions';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
|
||||
|
||||
private loginDispatched = false;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { Component, Injectable } from '@angular/core';
|
||||
import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NgbDateNativeAdapter extends NgbDateAdapter<Date> {
|
||||
|
||||
fromModel(date: Date): NgbDateStruct {
|
||||
|
@@ -6,7 +6,9 @@ import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType} from
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EventService {
|
||||
|
||||
public event:Subject <IEventMessage> = new Subject<IEventMessage>();
|
||||
|
@@ -6,7 +6,9 @@ import { IItem } from '../models/item';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class FolderService {
|
||||
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
|
@@ -7,7 +7,9 @@ import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import * as appCommonActions from '../actions/app-common.actions';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class FullScreenGuard implements CanActivate {
|
||||
|
||||
private loginDispatched = false;
|
||||
|
@@ -7,7 +7,9 @@ import { IItemTask } from '../models/itemTask';
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ItemService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
@@ -4,7 +4,9 @@ import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import {IItemTypes} from '../models/item.types'
|
||||
import {IItem} from '../models/item'
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ItemTypeService {
|
||||
public itemTypes: IItemTypes;
|
||||
|
||||
|
@@ -7,7 +7,9 @@ import * as appCommonReducer from '../reducers/app-common.reducer'
|
||||
import * as appCommonActions from '../actions/app-common.actions';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NavBarGuard implements CanActivate {
|
||||
|
||||
private loginDispatched = false;
|
||||
|
@@ -3,7 +3,9 @@ import { DatePipe } from '@angular/common';
|
||||
import { Observable , Observer } from 'rxjs';
|
||||
import { ITypeaheadItem } from '../models/typeahead.item';
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TimespanService {
|
||||
constructor(private datePipe: DatePipe) {
|
||||
}
|
||||
|
@@ -4,7 +4,9 @@ import { ITypeaheadItem } from '../models/typeahead.item';
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TypeaheadService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
@@ -4,7 +4,9 @@ import { IUser } from '../models/user';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ export class AppConfig {
|
||||
return this.config[key];
|
||||
}
|
||||
|
||||
|
||||
public load(): Promise<any> {
|
||||
return this.httpClient.get('/configuration.json')
|
||||
.toPromise()
|
||||
|
Reference in New Issue
Block a user