Skip to content

Commit b5b5402

Browse files
committed
created a standalone material module which imports all material moduls to cleanup the import structure of the other modules.
sneaked in some code cleanup (removed unused exports, removed outcommented code etc)
1 parent 3fc6822 commit b5b5402

18 files changed

+84
-95
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,19 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { TestBed, async,fakeAsync, inject } from '@angular/core/testing';
19+
import { TestBed, async, inject } from '@angular/core/testing';
2020
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2121
import { ApiService } from './api.service';
2222
import { HttpClientModule } from '@angular/common/http';
2323

2424
describe('ApiService', () => {
2525

26-
let service, http;
27-
2826
beforeEach(() => {
2927
TestBed.configureTestingModule({
3028
imports: [HttpClientTestingModule, HttpClientModule],
3129
providers: [ApiService],
3230
});
3331

34-
service = TestBed.get(ApiService);
35-
http = TestBed.get(HttpTestingController);
3632
});
3733

3834

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class SocketService {
9898
*/
9999
const registeredEvents = Object.keys(this.observers);
100100

101-
let publishEventName;
101+
let publishEventName: EventType;
102102
/**
103103
* Map all numbers changed event to global registry event
104104
*/

client/src/app/dashboard/add-dialog/add-dialog.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, OnInit, Inject } from '@angular/core';
2-
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
1+
import { Component, OnInit } from '@angular/core';
2+
import { MatDialogRef } from '@angular/material';
33
import { FormControl, Validators } from '@angular/forms';
44
import { ApiService} from '../../api/api/api.service';
55

client/src/app/dashboard/crawler/crawler.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class CrawlerComponent implements OnInit {
3232
compType: string;
3333

3434
constructor(private apiService: ApiService) {
35-
3635
}
3736

3837
ngOnInit() {
@@ -42,7 +41,7 @@ export class CrawlerComponent implements OnInit {
4241
this.apiService.getInstances(ComponentTypeEnum.Crawler).subscribe((result: Array<Instance>) => {
4342
this.tableData = result;
4443
}, err => {
45-
console.log('error receiving data for crawler');
44+
console.log('error receiving data for crawler', err);
4645
});
4746
}
4847

client/src/app/dashboard/dashboard-card/dashboard-card.component.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ <h5 class="card-title custom_title">{{title}}</h5>
2525
</div>
2626
<div class="text-center">
2727
<button type="button" class="btn btn-primary custom_btn" routerLink={{route}} routerLinkActive="active">View Details</button>
28-
<!--<button type="button" class="btn btn-secondary custom_btn">Logs/Statistics</button>-->
2928
</div>
3029
<hr>
3130
<div class="text-center">
3231
<p class="card-text">Number of Instances: {{numberOfInstances}}</p>
33-
<!--<p class="card-text">Number of failed Instances: {{numberOfFailedInstances}}</p>-->
34-
</div>
3532
</div>
33+
</div>

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
19-
2018
import { async, TestBed, inject } from '@angular/core/testing';
2119
import { Location } from '@angular/common';
2220
import { Router } from '@angular/router';
@@ -36,8 +34,6 @@ import { ApiService } from 'src/app/api/api/api.service';
3634

3735

3836
describe('component: DashboardCardComponent', () => {
39-
let location;
40-
let router;
4137

4238
beforeEach(() => {
4339
TestBed.configureTestingModule({
@@ -53,13 +49,11 @@ describe('component: DashboardCardComponent', () => {
5349
});
5450

5551
beforeEach(inject([Router, Location], (_router: Router, _location: Location) => {
56-
location = _location;
57-
router = _router;
5852
}));
5953

6054

6155
it(`should create`, async(inject([HttpTestingController, ApiService],
62-
(httpClient: HttpTestingController, apiService: ApiService) => {
56+
(apiService: ApiService) => {
6357
expect(apiService).toBeTruthy();
6458
})));
6559
});

client/src/app/dashboard/dashboard-overview/dashboard-overview.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
<div class="container-fluid">
2020
<div class="row">
2121
<div class="col-md-3 col-sm-4">
22-
<app-dashboard-card route="crawler" componentType={{crawler}} title="Crawler" img="../assets/images/crawler.png"></app-dashboard-card>
22+
<app-dashboard-card route="crawler" componentType={{crawler}} title="Crawler" img="../assets/images/crawler.png"></app-dashboard-card>
2323
</div>
2424
<div class="col-md-3 col-sm-4">
25-
<app-dashboard-card route="webApi" componentType={{webApi}} title="Web API" img="../assets/images/webapi.png"></app-dashboard-card>
25+
<app-dashboard-card route="webApi" componentType={{webApi}} title="Web API" img="../assets/images/webapi.png"></app-dashboard-card>
2626
</div>
2727
<div class="col-md-3 col-sm-4">
28-
<app-dashboard-card route="webapp" componentType={{webApp}} title="Web APP" img="../assets/images/webapp.png"></app-dashboard-card>
28+
<app-dashboard-card route="webapp" componentType={{webApp}} title="Web APP" img="../assets/images/webapp.png"></app-dashboard-card>
2929
</div>
30-
<div class="col-md-1 col-sm-4">
30+
<div class="col-md-1 col-sm-4">
3131
</div>
3232
<div class="col-md-2 col-sm-4">
33-
<app-statuscard></app-statuscard>
33+
<app-statuscard></app-statuscard>
34+
</div>
3435
</div>
3536
</div>
36-
</div>

client/src/app/dashboard/dashboard.component.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
19+
import { async, TestBed, inject } from '@angular/core/testing';
2020
import { Location } from '@angular/common';
21-
import { Router, RouterOutlet } from '@angular/router';
21+
import { Router } from '@angular/router';
2222
import { RouterTestingModule } from '@angular/router/testing';
2323
import { HeaderComponent } from './header/header.component';
2424
import { DashboardComponent } from './dashboard.component';
25-
import {HttpClientModule} from '@angular/common/http';
2625

2726

2827
describe('component: DashboardComponent', () => {
2928

30-
let location, router;
29+
let location: Location, router: Router;
3130

3231

3332
beforeEach(() => {

client/src/app/dashboard/dashboard.module.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import { DashboardModule } from './dashboard.module';
2121
describe('DashboardModule', () => {
2222
let dashboardModule: DashboardModule;
2323

24-
25-
2624
beforeEach(() => {
2725
dashboardModule = new DashboardModule();
2826
});

client/src/app/dashboard/dashboard.module.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,8 @@
1919
import { NgModule } from '@angular/core';
2020
import { BrowserModule } from '@angular/platform-browser';
2121
import { BrowserAnimationsModule} from '@angular/platform-browser/animations';
22-
import { MatButtonModule, MatMenuModule, MatTableModule, MatPaginatorModule} from '@angular/material';
23-
import { MatIconModule} from '@angular/material/icon';
24-
import { MatCheckboxModule} from '@angular/material/checkbox';
25-
import { MatDialogModule} from '@angular/material/dialog';
2622
import { CommonModule } from '@angular/common';
2723
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
28-
import { MatFormFieldModule} from '@angular/material/form-field';
29-
import { MatInputModule} from '@angular/material/input';
30-
import { MatTooltipModule} from '@angular/material/tooltip';
3124
import { DashboardRoutingModule } from './dashboard-routing.module';
3225
import { DashboardCardComponent } from './dashboard-card/dashboard-card.component';
3326
import { DashboardComponent } from './dashboard.component';
@@ -43,25 +36,17 @@ import { UserProfileComponent } from './user-profile/user-profile.component';
4336
import { DeleteDialogComponent } from './delete-dialog/delete-dialog.component';
4437
import { AddDialogComponent } from './add-dialog/add-dialog.component';
4538
import {ApiModule} from '../api/api.module';
39+
import { MaterialModule } from '../material-module/material.module';
4640

4741

4842
@NgModule({
4943
imports: [
5044
BrowserModule,
5145
BrowserAnimationsModule,
52-
MatButtonModule,
53-
MatMenuModule,
54-
MatIconModule,
55-
MatTableModule,
56-
MatPaginatorModule,
57-
MatCheckboxModule,
58-
MatDialogModule,
46+
MaterialModule,
5947
CommonModule,
6048
FormsModule,
6149
ReactiveFormsModule,
62-
MatFormFieldModule,
63-
MatInputModule,
64-
MatTooltipModule,
6550
DashboardRoutingModule,
6651
DashboardRoutingModule,
6752
ApiModule

client/src/app/dashboard/delete-dialog/delete-dialog.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component, OnInit, Inject } from '@angular/core';
22
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
3-
import { MatDialogModule } from '@angular/material/dialog';
43
import { Instance } from '../../api/model/instance';
54

65
@Component({

client/src/app/dashboard/header/header.component.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
</div>
3232
<div class="navbar-expand ml-auto navbar-nav">
3333
<div class="navbar-nav">
34-
35-
<!--<a class="nav-item nav-link" href="#"><i class="fa fa-bell"></i></a>-->
36-
<a class="nav-item nav-link" href="/dashboard/userProfile"><i class="fa fa-user-circle"></i></a>
37-
34+
<a class="nav-item nav-link" href="/dashboard/userProfile"><i class="fa fa-user-circle"></i></a>
3835
</div>
3936
</div>
4037
</nav>

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,37 @@
1818

1919
import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
2020
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
21-
import { HttpClientModule, HttpClient } from '@angular/common/http';
21+
import { HttpClientModule } from '@angular/common/http';
2222
import { BrowserModule, By } from '@angular/platform-browser';
2323
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
24-
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
25-
import { MatTableModule, MatInputModule, MatPaginatorModule } from '@angular/material';
26-
import { MatFormFieldModule } from '@angular/material/form-field';
27-
import { MatCheckboxModule } from '@angular/material/checkbox';
28-
import { MatIconModule } from '@angular/material/icon';
24+
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
2925
import { MatDialogRef, MAT_DIALOG_DATA, MatTableDataSource } from '@angular/material';
30-
import { MatDialogModule } from '@angular/material/dialog';
3126
import { TableAllComponent } from './table-all.component';
3227
import { AddDialogComponent } from '../add-dialog/add-dialog.component';
3328
import { DeleteDialogComponent } from '../delete-dialog/delete-dialog.component';
34-
import { DebugElement } from '@angular/core';
3529
import { ApiService } from '../../api/api/api.service';
30+
import { MaterialModule } from 'src/app/material-module/material.module';
3631

3732

3833
describe('TableAllComponent', () => {
3934
let component: TableAllComponent;
4035
let fixture: ComponentFixture<TableAllComponent>;
41-
let debugElement: DebugElement;
4236

4337
beforeEach(async(() => {
4438
TestBed.configureTestingModule({
4539
declarations: [TableAllComponent],
4640
imports: [HttpClientTestingModule, HttpClientModule, BrowserModule, BrowserAnimationsModule,
47-
MatTableModule, MatInputModule, MatPaginatorModule,
48-
MatFormFieldModule, MatCheckboxModule, MatIconModule, MatDialogModule],
41+
MaterialModule],
4942
providers: [{
5043
provide: MatDialogRef,
5144
useValue: {}
5245
}, {
5346
provide: MAT_DIALOG_DATA,
54-
useValue: {}
47+
useValue: {}
5548
},
5649
{
5750
provide: MatTableDataSource,
58-
useValue: {}
51+
useValue: {}
5952
}]
6053
})
6154
.compileComponents();
@@ -70,12 +63,11 @@ describe('TableAllComponent', () => {
7063
beforeEach(() => {
7164
fixture = TestBed.createComponent(TableAllComponent);
7265
component = fixture.componentInstance;
73-
debugElement = fixture.debugElement;
7466
fixture.detectChanges();
7567
});
7668

7769
it(`should create`, async(inject([HttpTestingController, ApiService],
78-
(httpClient: HttpTestingController, apiService: ApiService) => {
70+
(apiService: ApiService) => {
7971
expect(apiService).toBeTruthy();
8072
})));
8173

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { Component, OnInit, Input, ViewChild, ɵstringify } from '@angular/core';
19+
import { Component, OnInit, Input, ViewChild } from '@angular/core';
2020
import { Instance} from '../../api/model/instance';
21-
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatTable, MatPaginator, MatTableDataSource } from '@angular/material';
21+
import { MatDialog, MatTable, 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 { ApiService } from '../../api/api/api.service';
@@ -60,8 +60,8 @@ export class TableAllComponent implements OnInit {
6060
}
6161

6262
/**
63-
* Function for deleting an insatnce. Cannot delete an instance if its running.
64-
* Prompts to Stop the instance before deleting.
63+
* Function for deleting an insatnce. Cannot delete an instance if its running.
64+
* Prompts to Stop the instance before deleting.
6565
* @param InstanceID
6666
*/
6767
openDeleteDialog(i: number, instance: Instance, id: string) {
@@ -100,7 +100,7 @@ export class TableAllComponent implements OnInit {
100100
}
101101

102102
/**
103-
* Adding an instance using mat-dialog component
103+
* Adding an instance using mat-dialog component
104104
* @param componentType
105105
* @param componentName
106106
*/
@@ -129,7 +129,7 @@ export class TableAllComponent implements OnInit {
129129
}
130130

131131
/**
132-
* Function used to control the state of the instance. Case1: 'start' an instance
132+
* Function used to control the state of the instance. Case1: 'start' an instance
133133
* @param InstanceID
134134
*/
135135
public startInstance(id: string): void {
@@ -142,7 +142,7 @@ export class TableAllComponent implements OnInit {
142142
}
143143

144144
/**
145-
* Function used to control the state of the instance. Case2: 'stop' an instance
145+
* Function used to control the state of the instance. Case2: 'stop' an instance
146146
* @param InstanceID
147147
*/
148148
public stopInstance(id: string): void {
@@ -155,7 +155,7 @@ export class TableAllComponent implements OnInit {
155155
}
156156

157157
/**
158-
* Function used to control the state of the instance. Case3: 'Pause' an instance
158+
* Function used to control the state of the instance. Case3: 'Pause' an instance
159159
* @param InstanceID
160160
*/
161161
public pauseInstance(id: string): void {
@@ -168,7 +168,7 @@ export class TableAllComponent implements OnInit {
168168
}
169169

170170
/**
171-
* Function used to control the state of the instance. Case4: 'Resume' an instance if Paused
171+
* Function used to control the state of the instance. Case4: 'Resume' an instance if Paused
172172
* @param InstanceID
173173
*/
174174
public resumeInstance(id: string): void {

client/src/app/dashboard/webapi/web-api.component.spec.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,31 @@ import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'
2020
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2121
import { HttpClientModule } from '@angular/common/http';
2222
import { BrowserAnimationsModule} from '@angular/platform-browser/animations';
23-
import { MatTableModule, MatInputModule, MatPaginatorModule} from '@angular/material';
24-
import { MatFormFieldModule} from '@angular/material/form-field';
25-
import { MatCheckboxModule} from '@angular/material/checkbox';
26-
import { MatIconModule} from '@angular/material/icon';
27-
import { MatDialogModule} from '@angular/material/dialog';
2823
import { TableAllComponent } from '../table-all/table-all.component';
2924
import { WebApiComponent } from './web-api.component';
3025
import { ApiService } from '../../api/api/api.service';
26+
import { MaterialModule } from 'src/app/material-module/material.module';
3127

3228

3329
describe('WebApiComponent', () => {
34-
let component: WebApiComponent;
3530
let fixture: ComponentFixture<WebApiComponent>;
3631

3732
beforeEach(async(() => {
3833
TestBed.configureTestingModule({
3934
declarations: [ WebApiComponent, TableAllComponent ],
4035
imports: [HttpClientTestingModule, HttpClientModule, BrowserAnimationsModule,
41-
MatTableModule, MatInputModule, MatPaginatorModule, MatFormFieldModule, MatCheckboxModule, MatIconModule, MatDialogModule]
36+
MaterialModule]
4237
})
4338
.compileComponents();
4439
}));
4540

4641
beforeEach(() => {
4742
fixture = TestBed.createComponent(WebApiComponent);
48-
component = fixture.componentInstance;
4943
fixture.detectChanges();
5044
});
5145

5246
it(`should create`, async(inject([HttpTestingController, ApiService],
53-
(httpClient: HttpTestingController, apiService: ApiService) => {
47+
(apiService: ApiService) => {
5448
expect(apiService).toBeTruthy();
5549
})));
5650
});

0 commit comments

Comments
 (0)