Skip to content

Commit

Permalink
upgrade tests and http requests to angular 7
Browse files Browse the repository at this point in the history
  • Loading branch information
tflori committed Nov 9, 2018
1 parent 066543e commit b7cbcb3
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cache: yarn
sudo: false

node_js:
- '7'
- '8'

matrix:
fast_finish: true
Expand Down
13 changes: 7 additions & 6 deletions config/spec-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ require('core-js/es7/reflect');
require('ts-helpers');

require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
require('zone.js/dist/sync-test');
require('zone.js/dist/proxy'); // since zone.js 0.6.15
require('zone.js/dist/jasmine-patch'); // put here since zone.js 0.6.14
require('zone.js/dist/zone-testing');
// require('zone.js/dist/long-stack-trace-zone');
// require('zone.js/dist/async-test');
// require('zone.js/dist/fake-async-test');
// require('zone.js/dist/sync-test');
// require('zone.js/dist/proxy'); // since zone.js 0.6.15
// require('zone.js/dist/jasmine-patch'); // put here since zone.js 0.6.14

// RxJS
require('rxjs/Rx');
Expand Down
49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,40 @@
"typings": "./index.d.ts",
"homepage": "https://github.com/tflori/angular-translator",
"peerDependencies": {
"@angular/common": "*",
"@angular/compiler": "*",
"@angular/core": "*",
"@angular/http": "*"
"@angular/common": ">=7.0",
"@angular/compiler": ">=7.0",
"@angular/core": ">=7.0",
"@angular/http": ">=7.0"
},
"devDependencies": {
"@angular/common": "^4.3.6",
"@angular/compiler": "^4.3.6",
"@angular/compiler-cli": "^4.3.6",
"@angular/core": "^4.3.6",
"@angular/http": "^4.3.6",
"@angular/platform-browser": "^4.3.6",
"@angular/platform-browser-dynamic": "^4.3.6",
"awesome-typescript-loader": "^3.2.3",
"istanbul-instrumenter-loader": "^3.0.0",
"@angular/common": "^7.0.3",
"@angular/compiler": "^7.0.3",
"@angular/compiler-cli": "^7.0.3",
"@angular/core": "^7.0.3",
"@angular/http": "^7.0.3",
"@angular/platform-browser": "^7.0.3",
"@angular/platform-browser-dynamic": "^7.0.3",
"awesome-typescript-loader": "^3.5.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine-core": "2.5.*",
"karma": "*",
"karma": "^3.1.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "*",
"karma-coverage": "^1.1.2",
"karma-firefox-launcher": "*",
"karma-jasmine": "*",
"karma-spec-reporter": "0.0.31",
"karma-remap-coverage": "*",
"karma-jasmine": "^1.1.2",
"karma-remap-coverage": "^0.1.5",
"karma-sourcemap-loader": "*",
"karma-webpack": "^2.0.4",
"reflect-metadata": "*",
"rxjs": "^5.4.3",
"source-map-loader": "*",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.13",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.3.3",
"rxjs-compat": "*",
"source-map-loader": "^0.2.4",
"ts-helpers": "*",
"tslint": "^4.5.1",
"typescript": "^2.5.1",
"typescript": "^3.1.6",
"typings": "*",
"webpack": "^2.7.0",
"zone.js": "^0.8.17"
"zone.js": "^0.8.26"
}
}
2 changes: 1 addition & 1 deletion src/TranslateComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Translator } from "./Translator";
import { TranslatorContainer } from "./TranslatorContainer";

import { Component, Input } from "@angular/core";
import { Subscription } from "rxjs/Subscription";
import { Subscription } from "rxjs";

@Component({
selector: "[translate]",
Expand Down
2 changes: 1 addition & 1 deletion src/TranslatePipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Translator } from "./Translator";
import { TranslatorContainer } from "./TranslatorContainer";

import { Inject, Pipe, PipeTransform } from "@angular/core";
import { Subscription } from "rxjs/Subscription";
import { Subscription } from "rxjs";

@Pipe({
name: "translate",
Expand Down
20 changes: 8 additions & 12 deletions src/TranslationLoader/Json.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { TranslationLoader } from "../TranslationLoader";

import { HttpClient, HttpErrorResponse } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Http } from "@angular/http";

@Injectable()
export class TranslationLoaderJson extends TranslationLoader {
constructor(private http: Http) {
constructor(private http: HttpClient) {
super();
}

Expand All @@ -29,17 +29,13 @@ export class TranslationLoaderJson extends TranslationLoader {
});
this.http.get(file)
.subscribe(
(response) => {
if (response.status === 200) {
let translations = {};
this.flattenTranslations(translations, response.json());
resolve(translations);
} else {
reject("StatusCode: " + response.status + "");
}
(data) => {
let translations = {};
this.flattenTranslations(translations, data);
resolve(translations);
},
(reason: Error) => {
reject(reason.message);
(response: HttpErrorResponse) => {
reject(response.statusText);
},
);
});
Expand Down
8 changes: 3 additions & 5 deletions src/Translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { TranslatorConfig } from "./TranslatorConfig";
import { TranslatorContainer } from "./TranslatorContainer";

import { Injectable, Injector, PipeTransform } from "@angular/core";
import { Observable } from "rxjs/Observable";
import { Observer } from "rxjs/Observer";

import "rxjs/add/operator/share";
import { Observable, Observer } from "rxjs";
import { share } from "rxjs/operators";

export class Translator {
private static regExpFromPattern(pattern: string): RegExp {
Expand Down Expand Up @@ -49,7 +47,7 @@ export class Translator {

this.languageChangedObservable = new Observable<string>((observer: Observer<string>) => {
this.languageChangedObserver = observer;
}).share();
}).pipe(share());

translatorContainer.languageChanged.subscribe((language) => {
this.language = language;
Expand Down
10 changes: 4 additions & 6 deletions src/TranslatorContainer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { TranslateLogHandler } from "./TranslateLogHandler";
import { Translator } from "./Translator";
import { TranslatorConfig } from "./TranslatorConfig";

import { Injectable, Injector } from "@angular/core";
import { Observable } from "rxjs/Observable";
import { Observer } from "rxjs/Observer";
import { Translator } from "./Translator";

import "rxjs/add/operator/share";
import { Observable , Observer } from "rxjs";
import { share } from "rxjs/operators";

@Injectable()
export class TranslatorContainer {
Expand All @@ -26,7 +24,7 @@ export class TranslatorContainer {
}
this.languageChangedObservable = new Observable<string>((observer: Observer<string>) => {
this.languageChangedObserver = observer;
}).share();
}).pipe(share());
}

get languageChanged(): Observable<string> {
Expand Down
4 changes: 2 additions & 2 deletions src/TranslatorModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Translator } from "./Translator";
import { COMMON_PURE_PIPES, TranslatorConfig } from "./TranslatorConfig";
import { TranslatorContainer } from "./TranslatorContainer";

import { HttpClientModule } from "@angular/common/http";
import { InjectionToken, ModuleWithProviders, NgModule, PipeTransform, Provider, Type } from "@angular/core";
import { HttpModule } from "@angular/http";

export const TRANSLATOR_OPTIONS: InjectionToken<object> = new InjectionToken("TRANSLATOR_OPTIONS");
export const TRANSLATOR_MODULE: InjectionToken<string> = new InjectionToken("TRANSLATOR_MODULE");
Expand All @@ -21,7 +21,7 @@ export const TRANSLATOR_MODULE: InjectionToken<string> = new InjectionToken("TRA
TranslatePipe,
TranslateComponent,
],
imports: [HttpModule],
imports: [HttpClientModule],
providers: [
TranslationLoaderJson,
TranslateLogHandler,
Expand Down
Loading

0 comments on commit b7cbcb3

Please sign in to comment.