removed unused modules

This commit is contained in:
William Welling
2017-09-29 20:44:11 -05:00
parent 81b2bff13e
commit 5b0dbfbc37
20 changed files with 10 additions and 366 deletions

View File

@@ -1,5 +0,0 @@
{
"test": {
"message": "Hello, DSpace!"
}
}

View File

@@ -25,8 +25,6 @@ import { HostWindowState } from './shared/host-window.reducer';
import { HostWindowResizeAction } from './shared/host-window.actions'; import { HostWindowResizeAction } from './shared/host-window.actions';
import { MockTranslateLoader } from './shared/testing/mock-translate-loader'; import { MockTranslateLoader } from './shared/testing/mock-translate-loader';
import { BrowserCookiesModule } from '../modules/cookies/browser-cookies.module';
import { BrowserDataLoaderModule } from '../modules/data-loader/browser-data-loader.module';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module'; import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module'; import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module';
@@ -52,8 +50,6 @@ describe('App component', () => {
useClass: MockTranslateLoader useClass: MockTranslateLoader
} }
}), }),
BrowserCookiesModule,
BrowserDataLoaderModule,
BrowserTransferStateModule, BrowserTransferStateModule,
BrowserTransferStoreModule BrowserTransferStoreModule
], ],

View File

@@ -21,7 +21,6 @@ import { appMetaReducers, debugMetaReducers } from './app.metareducers';
import { CoreModule } from './core/core.module'; import { CoreModule } from './core/core.module';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component'; import { HeaderComponent } from './header/header.component';
@@ -66,7 +65,6 @@ if (!ENV_CONFIG.production) {
EffectsModule.forRoot(appEffects), EffectsModule.forRoot(appEffects),
StoreModule.forRoot(appReducers), StoreModule.forRoot(appReducers),
StoreRouterConnectingModule, StoreRouterConnectingModule,
TransferHttpModule,
...DEV_MODULES ...DEV_MODULES
], ],
providers: [ providers: [

View File

@@ -11,8 +11,6 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
import { TransferState } from '../modules/transfer-state/transfer-state'; import { TransferState } from '../modules/transfer-state/transfer-state';
import { BrowserCookiesModule } from '../modules/cookies/browser-cookies.module';
import { BrowserDataLoaderModule } from '../modules/data-loader/browser-data-loader.module';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module'; import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreEffects } from '../modules/transfer-store/browser-transfer-store.effects'; import { BrowserTransferStoreEffects } from '../modules/transfer-store/browser-transfer-store.effects';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module'; import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module';
@@ -39,10 +37,13 @@ export function createTranslateLoader(http: HttpClient) {
appId: 'ds-app-id' appId: 'ds-app-id'
}), }),
HttpClientModule, HttpClientModule,
IdlePreloadModule.forRoot(), // forRoot ensures the providers are only created once // forRoot ensures the providers are only created once
RouterModule.forRoot([], { useHash: false, preloadingStrategy: IdlePreload }), IdlePreloadModule.forRoot(),
BrowserCookiesModule, RouterModule.forRoot([], {
BrowserDataLoaderModule, useHash: false,
preloadingStrategy:
IdlePreload
}),
BrowserTransferStateModule, BrowserTransferStateModule,
BrowserTransferStoreModule, BrowserTransferStoreModule,
TranslateModule.forRoot({ TranslateModule.forRoot({

View File

@@ -23,10 +23,6 @@ import { TransferState } from '../modules/transfer-state/transfer-state';
import { ServerTransferStoreEffects } from '../modules/transfer-store/server-transfer-store.effects'; import { ServerTransferStoreEffects } from '../modules/transfer-store/server-transfer-store.effects';
import { ServerTransferStoreModule } from '../modules/transfer-store/server-transfer-store.module'; import { ServerTransferStoreModule } from '../modules/transfer-store/server-transfer-store.module';
import { ServerCookiesModule } from '../modules/cookies/server-cookies.module';
import { ServerDataLoaderModule } from '../modules/data-loader/server-data-loader.module';
import { AppState } from './app.reducer'; import { AppState } from './app.reducer';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
@@ -54,9 +50,9 @@ export function createTranslateLoader() {
BrowserModule.withServerTransition({ BrowserModule.withServerTransition({
appId: 'ds-app-id' appId: 'ds-app-id'
}), }),
RouterModule.forRoot([], { useHash: false }), RouterModule.forRoot([], {
ServerCookiesModule, useHash: false
ServerDataLoaderModule, }),
ServerTransferStateModule, ServerTransferStateModule,
ServerTransferStoreModule, ServerTransferStoreModule,
TranslateModule.forRoot({ TranslateModule.forRoot({

View File

@@ -1,13 +0,0 @@
import { NgModule } from '@angular/core';
import { Cookies } from './cookies';
import { BrowserCookies } from './browser-cookies';
@NgModule({
providers: [
{ provide: Cookies, useClass: BrowserCookies }
]
})
export class BrowserCookiesModule {
}

View File

@@ -1,34 +0,0 @@
import { Injectable } from '@angular/core';
import { Cookies } from './cookies';
@Injectable()
export class BrowserCookies implements Cookies {
// TODO: improve - set domain from configuration value or ui baseUrl
set(name: string, value: string, days: number, path?: string): void {
const date: Date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires: string = 'expires=' + date.toUTCString();
window.document.cookie = [name, '=', value, '; ', expires, path ? '; path=' + path : ''].join('');
}
get(name: string): string {
const cookies: string[] = window.document.cookie.split(';');
let cookie: string;
for (const cc of cookies) {
const c: string = cc.replace(/^\s\+/g, '');
if (c.indexOf(name + '=') === 0) {
cookie = c.substring(name.length + 1, c.length);
break;
}
}
return cookie;
}
// TODO: set path from environment configuration
remove(name: string): void {
this.set(name, '', 0, '/');
}
}

View File

@@ -1,9 +0,0 @@
export abstract class Cookies {
abstract set(name: string, value: string, days: number, path?: string): void;
abstract get(name: string): string;
abstract remove(name: string): void;
}

View File

@@ -1,13 +0,0 @@
import { NgModule } from '@angular/core';
import { Cookies } from './cookies';
import { ServerCookies } from './server-cookies';
@NgModule({
providers: [
{ provide: Cookies, useClass: ServerCookies }
]
})
export class ServerCookiesModule {
}

View File

@@ -1,24 +0,0 @@
import { Injectable } from '@angular/core';
import { Cookies } from './cookies';
@Injectable()
export class ServerCookies implements Cookies {
// tslint:disable:no-empty
set(name: string, value: string, days: number, path?: string): void {
}
// tslint:enable:no-empty
get(name: string): string {
return undefined;
}
// tslint:disable:no-empty
remove(name: string): void {
}
// tslint:enable:no-empty
}

View File

@@ -1,13 +0,0 @@
import { NgModule } from '@angular/core';
import { DataLoader } from './data-loader';
import { BrowserDataLoader } from './browser-data-loader';
@NgModule({
providers: [
{ provide: DataLoader, useClass: BrowserDataLoader }
]
})
export class BrowserDataLoaderModule {
}

View File

@@ -1,27 +0,0 @@
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { DataLoader } from './data-loader';
@Injectable()
export class BrowserDataLoader extends DataLoader {
protected prefix: string;
protected suffix: string;
constructor(private http: Http) {
super();
this.prefix = 'assets/data';
this.suffix = '.json';
}
public getData(name: string): Observable<any> {
return this.http.get(`${this.prefix}/${this.language}/${name}${this.suffix}`, {}).map((response: Response) => {
return response.json();
});
}
}

View File

@@ -1,21 +0,0 @@
import { Observable } from 'rxjs/Observable';
export abstract class DataLoader {
protected language: string;
protected abstract prefix: string;
protected abstract suffix: string;
constructor() {
this.language = 'en';
}
public setLanguage(language: string): void {
this.language = language;
}
abstract getData(name: string): Observable<any>;
}

View File

@@ -1,13 +0,0 @@
import { NgModule } from '@angular/core';
import { DataLoader } from './data-loader';
import { ServerDataLoader } from './server-data-loader';
@NgModule({
providers: [
{ provide: DataLoader, useClass: ServerDataLoader }
]
})
export class ServerDataLoaderModule {
}

View File

@@ -1,28 +0,0 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import * as fs from 'fs';
import { DataLoader } from './data-loader';
@Injectable()
export class ServerDataLoader extends DataLoader {
protected prefix: string;
protected suffix: string;
constructor() {
super();
this.prefix = 'dist/assets/data';
this.suffix = '.json';
}
public getData(name: string): Observable<any> {
return Observable.create((observer: any) => {
observer.next(JSON.parse(fs.readFileSync(`${this.prefix}/${this.language}/${name}${this.suffix}`, 'utf8')));
observer.complete();
});
}
}

View File

@@ -1,12 +0,0 @@
import { NgModule } from '@angular/core';
import { TransferHttp } from './transfer-http';
@NgModule({
providers: [
TransferHttp
]
})
export class TransferHttpModule {
}

View File

@@ -1,132 +0,0 @@
import { Injectable } from '@angular/core';
import { ConnectionBackend, Http, Request, RequestOptions, RequestOptionsArgs, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { TransferState } from '../transfer-state/transfer-state';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/observable/of';
@Injectable()
export class TransferHttp {
constructor(private http: Http, protected transferState: TransferState) { }
request(uri: string | Request, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getData(uri, options, (url: string, options: RequestOptionsArgs) => {
return this.http.request(url, options);
});
}
get(url: string, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getData(url, options, (url: string, options: RequestOptionsArgs) => {
return this.http.get(url, options);
});
}
post(url: string, body: any, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getPostData(url, body, options, (url: string, body: any, options: RequestOptionsArgs) => {
return this.http.post(url, body, options);
});
}
put(url: string, body: any, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getData(url, options, (url: string, options: RequestOptionsArgs) => {
return this.http.put(url, options);
});
}
delete(url: string, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getData(url, options, (url: string, options: RequestOptionsArgs) => {
return this.http.delete(url, options);
});
}
patch(url: string, body: any, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getPostData(url, body, options, (url: string, body: any, options: RequestOptionsArgs) => {
return this.http.patch(url, body, options);
});
}
head(url: string, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getData(url, options, (url: string, options: RequestOptionsArgs) => {
return this.http.head(url, options);
});
}
options(url: string, options?: RequestOptionsArgs): Observable<any> {
// tslint:disable-next-line:no-shadowed-variable
return this.getData(url, options, (url: string, options: RequestOptionsArgs) => {
return this.http.options(url, options);
});
}
// tslint:disable-next-line:max-line-length
private getData(uri: string | Request, options: RequestOptionsArgs, callback: (uri: string | Request, options?: RequestOptionsArgs) => Observable<Response>) {
let url = uri;
if (typeof uri !== 'string') {
url = uri.url;
}
const key = url + JSON.stringify(options);
try {
return this.resolveData(key);
} catch (e) {
return callback(uri, options)
.map((res: Response) => res.json())
.do((data: any) => {
this.setCache(key, data);
});
}
}
private getPostData(uri: string | Request, body: any, options: RequestOptionsArgs, callback: (uri: string | Request, body: any, options?: RequestOptionsArgs) => Observable<Response>) {
let url = uri;
if (typeof uri !== 'string') {
url = uri.url;
}
const key = url + JSON.stringify(body) + JSON.stringify(options);
try {
return this.resolveData(key);
} catch (e) {
return callback(uri, body, options)
.map((res: Response) => res.json())
.do((data: any) => {
this.setCache(key, data);
});
}
}
private resolveData(key: string) {
const data = this.getFromCache(key);
if (!data) {
throw new Error();
}
return Observable.of(data);
}
private setCache(key, data) {
return this.transferState.set(key, data);
}
private getFromCache(key): any {
return this.transferState.get(key);
}
}

View File

@@ -91,9 +91,6 @@ module.exports = {
}, { }, {
from: join(__dirname, '..', 'resources', 'images'), from: join(__dirname, '..', 'resources', 'images'),
to: join('assets', 'images') to: join('assets', 'images')
}, {
from: join(__dirname, '..', 'resources', 'data'),
to: join('assets', 'data')
}, { }, {
from: join(__dirname, '..', 'resources', 'i18n'), from: join(__dirname, '..', 'resources', 'i18n'),
to: join('assets', 'i18n') to: join('assets', 'i18n')