Skip to content

feat(upgrade): need to depend on latest angular and rxjs #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions ex/app/shared/services/docs/docs.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { forwardRef, Inject, Injectable, LOCALE_ID } from '@angular/core'
import { Http } from '@angular/http'
import { Observable } from 'rxjs/Observable'
import {Http, Response} from '@angular/http';
import {Observable, throwError as observableThrowError, of} from 'rxjs';
import {map, catchError} from 'rxjs/operators';
import { environment } from '../../../../environments'

@Injectable()
Expand All @@ -19,22 +20,37 @@ export class DocsService {
}

getCatalog(): Observable<any> {
return this.http.get(`${this.url}/catalog.json`)
.map(res => res.json())
return this.http.get(`${this.url}/catalog.json`).pipe(
catchError(err => this.handleResponseError(err)),
map((res: Response) => {
if (!res.text()) { return null; }
return res.json();
}));
}

getDocuments(documentType: string): Observable<any> {
return this.http.get(`${this.url}/${documentType}.json`)
.map(res => res.json())
return this.http.get(`${this.url}/${documentType}.json`).pipe(
catchError(err => this.handleResponseError(err)),
map((res: Response) => {
if (!res.text()) { return null; }
return res.json();
}));
}

getVersion(): Observable<any> {
return Observable.of(environment.version || '1.0.0')
return of(environment.version || '1.0.0')
}

getChangeLogs(): Observable<any> {
return this.http.get(`${this.url}/changelog.json`)
.map(res => res.json())
return this.http.get(`${this.url}/changelog.json`).pipe(
catchError(err => this.handleResponseError(err)),
map((res: Response) => {
if (!res.text()) { return null; }
return res.json();
}));
}

private handleResponseError(error: Response): Observable<never> {
return observableThrowError(error.json());
}

}
8 changes: 8 additions & 0 deletions ex/docs/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@
}, {
"description": "移除未使用的 HttpModule"
}]
},
{
"version": "0.7.7",
"date": "2018-11-01",
"link": null,
"events": [{
"description": "更新angular4 到 angular7"
}]
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions ex/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare let __DEBUG__: any
declare function require(string: string): string

import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID } from '@angular/core'
import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, StaticProvider } from '@angular/core'
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
import { AppModule } from './app/app.module'
const translations: string = require('./locale/messages.en-US.xlf')
Expand All @@ -10,7 +10,7 @@ const translations: string = require('./locale/messages.en-US.xlf')
const LOCALE: string = (<any>window).localStorage.getItem('LOCALE') || 'zh-CN'

const makeLocaleID = () => ({ provide: LOCALE_ID, useValue: LOCALE })
const getProviders = (): Array<{}> => {
const getProviders = (): Array<StaticProvider> => {
if (LOCALE !== 'en-US') return [makeLocaleID()]
return [
{ provide: TRANSLATIONS, useValue: translations },
Expand Down
Loading