Skip to content

Commit a4aea52

Browse files
authored
Merge branch 'develop' into inconsistent-tests
2 parents 3920792 + 08fdb6e commit a4aea52

File tree

11 files changed

+350
-439
lines changed

11 files changed

+350
-439
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ apt:
1212
before_install:
1313
- npm install -g @angular/cli
1414
script:
15-
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; cd client && npm install && ng build --prod && npm run test -- --no-progress --browsers=ChromeHeadlessCI && cd .. ; fi'
16-
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; cd client && npm install && ng build --prod && npm run test -- --no-progress --browsers=ChromeHeadlessCI && cd .. ; fi'
15+
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sbt ++$TRAVIS_SCALA_VERSION test; cd client && npm install && ng build --prod && npm run test -- --no-progress --browsers=ChromeHeadlessCI --source-map=false && cd .. ; fi'
16+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sbt ++$TRAVIS_SCALA_VERSION coverage test coverageReport coverageAggregate codacyCoverage; cd client && npm install && ng build --prod && npm run test -- --no-progress --browsers=ChromeHeadlessCI --source-map=false && cd .. ; fi'
1717
after_success:
1818
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash <(curl -s https://codecov.io/bash); fi'

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,20 @@ It takes commands from authenticated administrators over the web interface and i
2020

2121
## How can I use it?
2222
To build the angular app for deployment make sure to have npm and the angular cli installed
23+
2324
```
2425
cd client && npm install && ng build --prod && cd ..
2526
```
27+
28+
For OS X users you need to expose the TCP port manually. The docker FAQ suggest it in this way:
29+
30+
```
31+
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:9095:9095 bobrik/socat TCP-LISTEN:9095,fork UNIX-CONNECT:/var/run/docker.sock
32+
```
33+
2634
For any deployed instance you need an administrator account to interact with the application.
2735
You can start your own instance by executing
36+
2837
```
2938
sbt run
3039
```

app/controllers/InstanceRegistryController.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
117117
.addQueryStringParameters("Id" -> instanceID)
118118
.post("")
119119
.map { response =>
120-
response.status match {
121-
case 202 =>
122-
Ok(response.body)
123-
case x =>
124-
new Status(x)
125-
}
120+
new Status(response.status)
126121
}(myExecutionContext)
127122
}
128123

client/package-lock.json

Lines changed: 274 additions & 375 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
},
1212
"private": true,
1313
"dependencies": {
14-
"@angular/animations": "^7.2.0",
14+
"@angular/animations": "^7.2.1",
1515
"@angular/cdk": "^7.2.1",
16-
"@angular/common": "^7.2.0",
17-
"@angular/compiler": "^7.2.0",
18-
"@angular/core": "^7.2.0",
19-
"@angular/forms": "^7.2.0",
20-
"@angular/http": "^7.2.0",
16+
"@angular/common": "^7.2.1",
17+
"@angular/compiler": "^7.2.1",
18+
"@angular/core": "^7.2.1",
19+
"@angular/forms": "^7.2.1",
20+
"@angular/http": "^7.2.1",
2121
"@angular/material": "^7.2.1",
22-
"@angular/platform-browser": "^7.2.0",
23-
"@angular/platform-browser-dynamic": "^7.2.0",
24-
"@angular/router": "^7.2.0",
22+
"@angular/platform-browser": "^7.2.1",
23+
"@angular/platform-browser-dynamic": "^7.2.1",
24+
"@angular/router": "^7.2.1",
2525
"@ng-bootstrap/ng-bootstrap": "^4.0.1",
2626
"bootstrap": "^4.1.3",
2727
"core-js": "^2.6.2",
@@ -31,13 +31,13 @@
3131
"material-design-icons": "^3.0.1",
3232
"popper.js": "^1.14.6",
3333
"rxjs": "^6.3.3",
34-
"zone.js": "^0.8.27"
34+
"zone.js": "^0.8.28"
3535
},
3636
"devDependencies": {
37-
"@angular-devkit/build-angular": "^0.12.1",
38-
"@angular/cli": "^7.2.1",
39-
"@angular/compiler-cli": "^7.2.0",
40-
"@angular/language-service": "^7.2.0",
37+
"@angular-devkit/build-angular": "^0.12.2",
38+
"@angular/cli": "^7.2.2",
39+
"@angular/compiler-cli": "^7.2.1",
40+
"@angular/language-service": "^7.2.1",
4141
"@types/jasmine": "^3.3.5",
4242
"@types/jasminewd2": "^2.0.6",
4343
"@types/node": "^10.12.18",

client/src/app/api/api/api.service.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class ApiService {
109109
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
110110
* @param reportProgress flag to report request and response progress.
111111
*/
112-
public startInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false): Observable<HttpEvent<number>> {
112+
public startInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false) {
113113
return this.postAction(START_INSTANCE, instanceId);
114114
}
115115

@@ -119,7 +119,7 @@ export class ApiService {
119119
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
120120
* @param reportProgress flag to report request and response progress.
121121
*/
122-
public stopInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false): Observable<HttpEvent<number>> {
122+
public stopInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false) {
123123
return this.postAction(STOP_INSTANCE, instanceId);
124124
}
125125

@@ -129,7 +129,7 @@ export class ApiService {
129129
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
130130
* @param reportProgress flag to report request and response progress.
131131
*/
132-
public pauseInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false): Observable<HttpEvent<number>> {
132+
public pauseInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false) {
133133
return this.postAction(PAUSE_INSTANCE, instanceId);
134134
}
135135

@@ -139,7 +139,7 @@ export class ApiService {
139139
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
140140
* @param reportProgress flag to report request and response progress.
141141
*/
142-
public resumeInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false): Observable<HttpEvent<number>> {
142+
public resumeInstance(instanceId: string, observe: any = 'body', reportProgress: boolean = false) {
143143
return this.postAction(RESUME_INSTANCE, instanceId);
144144
}
145145

@@ -149,7 +149,7 @@ export class ApiService {
149149
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
150150
* @param reportProgress flag to report request and response progress.
151151
*/
152-
public deleteInstance(instanceId: string): Observable<HttpEvent<number>> {
152+
public deleteInstance(instanceId: string) {
153153
return this.postAction(DELETE_INSTANCE, instanceId);
154154
}
155155

@@ -214,8 +214,7 @@ export class ApiService {
214214
}
215215

216216

217-
private postAction(endpoint: string, idInstance: string, observe: any = 'body', reportProgress: boolean = false):
218-
Observable<HttpEvent<number>> {
217+
private postAction(endpoint: string, idInstance: string, observe: any = 'body', reportProgress: boolean = false) {
219218
let queryParam = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
220219

221220
if (idInstance === null || idInstance === undefined) {
@@ -228,8 +227,7 @@ export class ApiService {
228227
}
229228

230229

231-
private commonConf(endpoint: string, queryParameters: HttpParams, observe: any = 'body', reportProgress: boolean = false):
232-
Observable<HttpEvent<number>> {
230+
private commonConf(endpoint: string, queryParameters: HttpParams, observe: any = 'body', reportProgress: boolean = false) {
233231
let headers = this.defaultHeaders;
234232

235233
// to determine the Accept header

client/src/app/api/api/socket.service.spec.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import {TestBed} from '@angular/core/testing';
2020

2121
import {SocketService} from './socket.service';
22+
import { doesNotReject } from 'assert';
2223

2324
describe('SocketService', () => {
2425
let socketService: SocketService;
@@ -49,14 +50,4 @@ describe('SocketService', () => {
4950
expect(socketService).toBeTruthy();
5051
});
5152

52-
53-
it('should return correct data on subscribe', () => {
54-
console.log('new test');
55-
socketService = TestBed.get(SocketService);
56-
console.log('socket service', socketService);
57-
// need to check the result based on some mock object to simulate the connection to the webserver
58-
socketService.initSocket().then(() => {
59-
console.log('fake socket open');
60-
});
61-
});
6253
});

client/src/app/dashboard/status-card/status-card.component.spec.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,34 @@
1717
*/
1818

1919
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
20-
import { HttpClientTestingModule } from '@angular/common/http/testing';
21-
import { HttpClientModule } from '@angular/common/http';
2220
import { StatusCardComponent } from './status-card.component';
21+
import { ApiService } from 'src/app/api/api/api.service';
22+
import { Observable } from 'rxjs';
23+
import { SysInfo } from 'src/app/model/models/sysInfo';
2324

2425

2526
describe('StatusCardComponent', () => {
2627
let component: StatusCardComponent;
2728
let fixture: ComponentFixture<StatusCardComponent>;
28-
29+
const JAVA_VERSION = '1.0';
30+
const HOST_NAME = 'My Host Name';
31+
const PLATFORM_NAME = 'My Platform Name';
32+
const SCALA_VERSION = '2.0';
2933
beforeEach(async(() => {
34+
let apiServiceStub: Partial<ApiService>;
35+
apiServiceStub = {
36+
getSysInfo: () => new Observable<SysInfo>((observer) => {
37+
observer.next({
38+
javaVersion: JAVA_VERSION,
39+
hostName: HOST_NAME,
40+
platformName: PLATFORM_NAME,
41+
scalaVersion: SCALA_VERSION
42+
});
43+
})
44+
};
3045
TestBed.configureTestingModule({
3146
declarations: [ StatusCardComponent ],
32-
imports: [HttpClientTestingModule, HttpClientModule]
47+
providers: [{provide: ApiService, useValue: apiServiceStub}]
3348
})
3449
.compileComponents();
3550
}));
@@ -41,6 +56,13 @@ describe('StatusCardComponent', () => {
4156
});
4257

4358
it('should create', () => {
44-
expect(component).toBeTruthy();
59+
expect(component).toBeDefined();
60+
});
61+
62+
it('should have the dummy data stored', () => {
63+
expect(component.sysInfo.hostName).toBe(HOST_NAME);
64+
expect(component.sysInfo.javaVersion).toBe(JAVA_VERSION);
65+
expect(component.sysInfo.platformName).toBe(PLATFORM_NAME);
66+
expect(component.sysInfo.scalaVersion).toBe(SCALA_VERSION);
4567
});
4668
});

client/src/app/dashboard/table-all/table-all.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<mat-form-field>
2424
<input id="filterData" matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
2525
</mat-form-field>
26-
<table class="mat-elevation-z8 mat-table" mat-table [dataSource]="dataSource">
26+
<mat-table class="mat-elevation-z8 mat-table" [dataSource]="dataSource">
2727
<ng-container matColumnDef="ID">
2828
<mat-header-cell *matHeaderCellDef> ID </mat-header-cell>
2929
<mat-cell *matCellDef="let element"> {{element.id}} </mat-cell>
@@ -78,7 +78,7 @@
7878

7979
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
8080
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
81-
</table>
81+
</mat-table>
8282
</div>
8383
</ng-template>
8484

client/src/app/dashboard/table-all/table-all.component.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import {Instance} from '../../model/models/instance';
2020
import { Component, OnInit, Input, ViewChild } from '@angular/core';
21-
import { MatDialog, MatTable, MatPaginator, MatTableDataSource } from '@angular/material';
21+
import { MatDialog, MatPaginator, MatTableDataSource } from '@angular/material';
2222
import { DeleteDialogComponent } from '../delete-dialog/delete-dialog.component';
2323
import { AddDialogComponent } from '../add-dialog/add-dialog.component';
2424
import { HttpEvent } from '@angular/common/http';
@@ -47,7 +47,6 @@ export class TableAllComponent implements OnInit {
4747
displayedColumns = ['ID', 'name', 'host', 'portNumber', 'instanceState', 'action'];
4848
dataSource: MatTableDataSource<Instance> = new MatTableDataSource<Instance>(this.dataArray);
4949
dialogResult: string;
50-
@ViewChild(MatTable) table: MatTable<Instance>;
5150

5251
constructor(public dialog: MatDialog, private apiService: ApiService, private modelService: ModelService) {
5352
}
@@ -81,7 +80,7 @@ export class TableAllComponent implements OnInit {
8180
this.apiService.deleteInstance(id).subscribe((deleteResult: HttpEvent<number>) => {
8281
console.log('result', deleteResult);
8382
}, err => {
84-
console.log('error delete Instance');
83+
console.log('error delete Instance', err);
8584
});
8685
this.removeAt(i);
8786
}
@@ -92,7 +91,6 @@ export class TableAllComponent implements OnInit {
9291

9392
removeAt(index: number) {
9493
this.dataSource.data.splice(index, 1);
95-
this.table.renderRows();
9694
}
9795

9896
applyFilter(filterValue: string) {
@@ -113,10 +111,8 @@ export class TableAllComponent implements OnInit {
113111
dialogRef.afterClosed().subscribe(dialogResult => {
114112
this.apiService.postInstance(this.type, dialogResult.name).subscribe((result: Instance) => {
115113
this.dataSource.data.push(result);
116-
this.table.renderRows();
117-
}, err => {
118-
119-
console.log('error receiving data for crawler');
114+
}, (err: any) => {
115+
console.log('error receiving data for crawler', err);
120116
});
121117
});
122118
}
@@ -127,8 +123,7 @@ export class TableAllComponent implements OnInit {
127123
*/
128124
public startInstance(id: string): void {
129125

130-
this.apiService.startInstance(id).subscribe((result: HttpEvent<number>) => {
131-
console.log('result', result);
126+
this.apiService.startInstance(id).subscribe(() => {
132127
}, err => {
133128
console.log('error start Instance', err);
134129
});
@@ -140,8 +135,7 @@ export class TableAllComponent implements OnInit {
140135
*/
141136
public stopInstance(id: string): void {
142137

143-
this.apiService.stopInstance(id).subscribe((result: HttpEvent<number>) => {
144-
console.log('result', result);
138+
this.apiService.stopInstance(id).subscribe(() => {
145139
}, err => {
146140
console.log('error stop Instance', err);
147141
});
@@ -153,8 +147,7 @@ export class TableAllComponent implements OnInit {
153147
*/
154148
public pauseInstance(id: string): void {
155149

156-
this.apiService.pauseInstance(id).subscribe((result: HttpEvent<number>) => {
157-
console.log('result', result);
150+
this.apiService.pauseInstance(id).subscribe(() => {
158151
}, err => {
159152
console.log('error pause instance', err);
160153
});
@@ -166,8 +159,7 @@ export class TableAllComponent implements OnInit {
166159
*/
167160
public resumeInstance(id: string): void {
168161

169-
this.apiService.resumeInstance(id).subscribe((result: HttpEvent<number>) => {
170-
console.log('result', result);
162+
this.apiService.resumeInstance(id).subscribe(() => {
171163
}, err => {
172164
console.log('error pause instance', err);
173165
});

0 commit comments

Comments
 (0)