Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit 6ac863a

Browse files
Merge branch 'master' into bump-flex-layout
2 parents 5f27e23 + 2e137f4 commit 6ac863a

30 files changed

+1068
-78
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"zone.js": "0.8.14"
5151
},
5252
"devDependencies": {
53-
"@angular/cli": "1.6.6",
53+
"@angular/cli": "1.7",
5454
"@angular/compiler-cli": "5.2.2",
5555
"@angular/language-service": "5.2.2",
5656
"@types/jasmine": "2.5.53",
@@ -80,7 +80,7 @@
8080
"ts-node": "3.2.0",
8181
"tslint": "5.3.2",
8282
"tslint-config-prettier": "1.6.0",
83-
"typescript": "2.4.2",
83+
"typescript": "2.6.2",
8484
"validate-commit-msg": "2.14.0",
8585
"wallaby-webpack": "*"
8686
},

src/app/app-routing.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModuleWithProviders, NgModule } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
33

44
export const routes: Routes = [

src/app/core/services/operators.service.spec.ts

+24
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,28 @@ describe('OperatorsService', () => {
4444
});
4545
})
4646
);
47+
48+
it('should call initOperators on changeOperatorsLang', () => {
49+
spyOn(operatorsService, 'initOperators').and.stub();
50+
51+
operatorsService.changeOperatorsLang(lang);
52+
53+
expect(operatorsService.initOperators).toHaveBeenCalledWith(lang.code);
54+
});
55+
56+
it('should return operators for menu on getOperatorsForMenu', () => {
57+
spyOn(operatorsService, 'initOperators').and.stub();
58+
59+
operatorsService.getOperatorsForMenu().then(operators => {
60+
expect(operators.length).toBeTruthy();
61+
});
62+
});
63+
64+
it('should return the exist operator on getDefaultOperator', () => {
65+
spyOn(operatorsService, 'initOperators').and.stub();
66+
67+
operatorsService.getDefaultOperator('delay').then(operator => {
68+
expect(operator.operatorType).toEqual('utility');
69+
});
70+
});
4771
});

src/app/core/services/operators.service.ts

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
66
import { OperatorDoc } from '../../../operator-docs';
77
import { LanguageService } from './language.service';
88
import { Lang } from '../models/language.model';
9+
import { MenuOperator } from '../../../operator-docs/operator.model';
910

1011
@Injectable()
1112
export class OperatorsService {
@@ -41,4 +42,20 @@ export class OperatorsService {
4142
getOperators(): Observable<OperatorDoc[]> {
4243
return this.operators;
4344
}
45+
46+
getOperatorsForMenu(): Promise<MenuOperator[]> {
47+
return import('../../../operator-docs').then(module => {
48+
return module.ALL_OPERATORS_EN.map(operator => {
49+
const { name, operatorType } = operator;
50+
51+
return { name, operatorType };
52+
});
53+
});
54+
}
55+
56+
getDefaultOperator(name: string): Promise<OperatorDoc | undefined> {
57+
return import('../../../operator-docs').then(module => {
58+
return module.ALL_OPERATORS_EN.find(operator => operator.name === name);
59+
});
60+
}
4461
}
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1-
<app-operator-header [operatorName]="operatorName"
1+
<div *ngIf="operator">
2+
<app-operator-header [operatorName]="operatorName"
23
[operatorSignature]="signature"
34
[id]="operatorName"
45
class="operator-header">
5-
</app-operator-header>
6-
<section class="main-operator-container mat-typography">
7-
<h3 class="short-description"
8-
[innerHTML]="shortDescription">
9-
</h3>
10-
<app-operator-extras class="margin-bottom-16"
11-
*ngIf="shortDescriptionExtras"
12-
[operatorExtras]="shortDescriptionExtras">
13-
</app-operator-extras>
14-
<app-marble-diagram class="margin-bottom-32"
15-
[operatorName]="operatorName"
16-
[useInteractiveMarbles]="useInteractiveMarbles"
17-
[url]="marbleUrl">
18-
</app-marble-diagram>
19-
<app-operator-examples [operatorExamples]="examples"
20-
(copyToClipboard)="copyToClipboard($event)"
21-
class="margin-bottom-16">
22-
</app-operator-examples>
23-
<app-operator-parameters [operatorParameters]="parameters"
24-
*ngIf="parameters?.length">
25-
</app-operator-parameters>
26-
<app-operator-walkthrough class="margin-bottom-16"
27-
[operatorWalkthrough]="walkthrough">
28-
</app-operator-walkthrough>
29-
<app-operator-extras class="margin-bottom-16"
30-
*ngIf="walkthroughExtras"
31-
[operatorExtras]="walkthroughExtras">
32-
</app-operator-extras>
33-
<app-related-operators [relatedOperators]="relatedOperators">
34-
</app-related-operators>
35-
<app-additional-resources [additionalResources]="additionalResources"
36-
[sourceUrl]="sourceUrl"
37-
[specsUrl]="specsUrl">
38-
</app-additional-resources>
39-
</section>
6+
</app-operator-header>
7+
<div *ngIf="noTranslation" class="operator-info-warning">
8+
<mat-icon>language</mat-icon> <span>{{ 'OPERATOR.NO_TRANSLATION' | translate}}</span>
9+
</div>
10+
<section class="main-operator-container mat-typography">
11+
<h3 class="short-description"
12+
[innerHTML]="shortDescription">
13+
</h3>
14+
<app-operator-extras class="margin-bottom-16"
15+
*ngIf="shortDescriptionExtras"
16+
[operatorExtras]="shortDescriptionExtras">
17+
</app-operator-extras>
18+
<app-marble-diagram class="margin-bottom-32"
19+
[operatorName]="operatorName"
20+
[useInteractiveMarbles]="useInteractiveMarbles"
21+
[url]="marbleUrl">
22+
</app-marble-diagram>
23+
<app-operator-examples [operatorExamples]="examples"
24+
(copyToClipboard)="copyToClipboard($event)"
25+
class="margin-bottom-16">
26+
</app-operator-examples>
27+
<app-operator-parameters [operatorParameters]="parameters"
28+
*ngIf="parameters?.length">
29+
</app-operator-parameters>
30+
<app-operator-walkthrough class="margin-bottom-16"
31+
[operatorWalkthrough]="walkthrough">
32+
</app-operator-walkthrough>
33+
<app-operator-extras class="margin-bottom-16"
34+
*ngIf="walkthroughExtras"
35+
[operatorExtras]="walkthroughExtras">
36+
</app-operator-extras>
37+
<app-related-operators [relatedOperators]="relatedOperators">
38+
</app-related-operators>
39+
<app-additional-resources [additionalResources]="additionalResources"
40+
[sourceUrl]="sourceUrl"
41+
[specsUrl]="specsUrl">
42+
</app-additional-resources>
43+
</section>
44+
</div>
45+

src/app/operators/components/operator/operator.component.scss

+14
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,17 @@
1717
.margin-bottom-16 {
1818
margin-bottom: 16px;
1919
}
20+
21+
.operator-info-warning {
22+
display: flex;
23+
align-items: center;
24+
margin: 1rem;
25+
padding: .75rem 1.25rem;
26+
border: 1px solid #ffeeba;
27+
border-radius: .25rem;
28+
color: #856404;
29+
background-color: #fff3cd;
30+
span {
31+
padding-left: 5px;
32+
}
33+
}

src/app/operators/components/operator/operator.component.ts

+42-19
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Subscription } from 'rxjs/Subscription';
1717
})
1818
export class OperatorComponent implements OnInit, OnDestroy {
1919
operatorsSubscription: Subscription;
20+
noTranslation = false;
2021
public operators: OperatorDoc[];
2122
public operator: OperatorDoc;
2223
public operatorsMap = new Map<string, OperatorDoc>();
@@ -37,31 +38,54 @@ export class OperatorComponent implements OnInit, OnDestroy {
3738
this.operatorsSubscription = this._operatorsService
3839
.getOperators()
3940
.subscribe(data => {
41+
this.operatorsMap.clear();
4042
this.operators = data;
4143
this.operators.forEach((op: OperatorDoc) => {
4244
this.operatorsMap.set(op.name, op);
4345
});
4446

45-
this._activatedRoute.params
46-
.pipe(pluck('operator'))
47-
.subscribe((name: string) => {
48-
if (this.operatorsMap.has(name)) {
49-
this.operator = this.operatorsMap.get(name);
50-
this.scrollToTop();
51-
} else {
52-
this.notfound();
53-
return;
54-
}
55-
this._seo.setHeaders({
56-
title: [this.operator.name, this.operator.operatorType],
57-
description: this.operator.shortDescription
58-
? this.operator.shortDescription.description
59-
: ''
60-
});
61-
});
47+
this.setOperator();
6248
});
6349
}
6450

51+
setOperator(): void {
52+
this._activatedRoute.params
53+
.pipe(pluck('operator'))
54+
.subscribe((name: string) => {
55+
this.noTranslation = false;
56+
57+
if (this.operatorsMap.has(name)) {
58+
this.operator = this.operatorsMap.get(name);
59+
this.scrollToTop();
60+
this.setHeaders();
61+
} else {
62+
this.setNotFoundOperator(name);
63+
}
64+
});
65+
}
66+
67+
setNotFoundOperator(name: string): void {
68+
this._operatorsService.getDefaultOperator(name).then(operator => {
69+
if (operator) {
70+
this.noTranslation = true;
71+
this.operator = operator;
72+
this.scrollToTop();
73+
this.setHeaders();
74+
return;
75+
}
76+
this.notFound();
77+
});
78+
}
79+
80+
setHeaders(): void {
81+
this._seo.setHeaders({
82+
title: [this.operator.name, this.operator.operatorType],
83+
description: this.operator.shortDescription
84+
? this.operator.shortDescription.description
85+
: ''
86+
});
87+
}
88+
6589
scrollToTop() {
6690
const content = document.querySelector('.mat-drawer-content');
6791

@@ -144,8 +168,7 @@ export class OperatorComponent implements OnInit, OnDestroy {
144168
return this.operator.additionalResources || [];
145169
}
146170

147-
private notfound() {
171+
private notFound(): void {
148172
this._router.navigate(['/operators']);
149-
return {};
150173
}
151174
}

src/app/operators/operators.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class OperatorsComponent implements OnInit, AfterContentInit, OnDestroy {
6969
) {}
7070

7171
ngOnInit() {
72-
this._operatorsService.getOperators().subscribe(data => {
72+
this._operatorsService.getOperatorsForMenu().then(data => {
7373
this.operators = data;
7474
this.groupedOperators = groupOperatorsByType(this.operators);
7575
this.categories = Object.keys(this.groupedOperators);

src/app/operators/specs/operators.spec.ts

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { ComponentFixture, TestBed } from '@angular/core/testing';
1+
import {
2+
ComponentFixture,
3+
fakeAsync,
4+
TestBed,
5+
tick
6+
} from '@angular/core/testing';
27
import { RouterTestingModule } from '@angular/router/testing';
38
import { NO_ERRORS_SCHEMA } from '@angular/core';
49
import { ActivatedRoute } from '@angular/router';
@@ -51,15 +56,21 @@ describe('Operators', () => {
5156
operatorsService = TestBed.get(OperatorsService);
5257
});
5358

54-
it('should group operators by operator type', () => {
55-
spyOn(operatorsService, 'getOperators').and.returnValue(
56-
Observable.of(allOperators)
57-
);
58-
59-
component.ngOnInit();
60-
61-
expect(component.groupedOperators['utility'].length).toBeTruthy();
62-
});
59+
it(
60+
'should group operators by operator type',
61+
fakeAsync(() => {
62+
spyOn(operatorsService, 'getOperatorsForMenu').and.returnValue(
63+
Promise.resolve([
64+
{ name: 'combineLatest', operatorType: 'combination' }
65+
])
66+
);
67+
component.ngOnInit();
68+
69+
tick();
70+
71+
expect(component.groupedOperators['combination'].length).toBeTruthy();
72+
})
73+
);
6374

6475
it('should have a sidenav mode of over when on a small screen', () => {
6576
spyOn(breakpointService, 'isMatched').and.returnValue(true);

src/app/team/team.service.ts

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ export class TeamService {
102102
avatar: 'https://avatars0.githubusercontent.com/u/1584489',
103103
twitterUrl: 'https://twitter.com/knitcodemonkey',
104104
webpageUrl: 'http://jenluker.com'
105+
},
106+
{
107+
name: 'Jan-Niklas Wortmann',
108+
role: 'Developer',
109+
githubUrl: 'https://github.com/JWO719',
110+
avatar: 'https://avatars3.githubusercontent.com/u/6104311',
111+
twitterUrl: 'https://twitter.com/niklas_wortmann',
112+
webpageUrl: ''
105113
}
106114
];
107115

src/assets/i18n/en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"WALKTHROUGH": {
2828
"TITLE": "Walkthrough"
29-
}
29+
},
30+
"NO_TRANSLATION": "Translation not completed. See the description in English"
3031
}
3132
}

src/assets/i18n/ru.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"WALKTHROUGH": {
2828
"TITLE": "Описание"
29-
}
29+
},
30+
"NO_TRANSLATION": "Перевод не завершен. Смотрите описание на английском языке"
3031
}
3132
}

src/favicon.ico

356 KB
Binary file not shown.

0 commit comments

Comments
 (0)