Skip to content

Commit d5be302

Browse files
RINO767RINO767
authored andcommitted
fixed flicker of table content on hardware images locations views
1 parent 0fe01bc commit d5be302

File tree

11 files changed

+30
-36
lines changed

11 files changed

+30
-36
lines changed

src/app/components/clouds/cloud-view/cloud-view.component.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ <h2 class="subtitle">
2525
<div class="columns">
2626
<!-- hardware table -->
2727
<div class="column">
28-
<div class="title is-4"
28+
<div class="title is-4 is-clickable"
2929
[routerLink]="['/hardware']"
3030
[queryParams]="{ cloud: cloud? cloud.id: null}">
3131
Hardware
3232
</div>
3333
<div class="table-container card">
34-
<table cdk-table class="table is-fullwidth is-striped is-hoverable" *ngIf="hardwareDataSource"
34+
<table cdk-table class="table is-fullwidth is-striped is-hoverable is-clickable" *ngIf="hardwareDataSource"
3535
[dataSource]="hardwareDataSource.value">
3636

3737
<!-- Name Definition -->
@@ -79,9 +79,10 @@ <h2 class="subtitle">
7979
<div class="column">
8080
<div class="title is-4"
8181
[routerLink]="['/images']"
82-
[queryParams]="{ cloud: cloud? cloud.id: null}">Images</div>
82+
[queryParams]="{ cloud: cloud? cloud.id: null}">Images
83+
</div>
8384
<div class="table-container card">
84-
<table cdk-table class="table is-fullwidth is-striped is-hoverable" *ngIf="imagesDataSource"
85+
<table cdk-table class="table is-fullwidth is-striped is-hoverable is-clickable" *ngIf="imagesDataSource"
8586
[dataSource]="imagesDataSource.value">
8687

8788
<!-- Name Definition -->
@@ -97,7 +98,9 @@ <h2 class="subtitle">
9798
<th cdk-header-cell *cdkHeaderCellDef class="is-unselectable">
9899
OS
99100
</th>
100-
<td cdk-cell *cdkCellDef="let row"> {{row.operatingSystem ? row.operatingSystem.operatingSystemFamily : ''}}</td>
101+
<td cdk-cell *cdkCellDef="let row"> {{row.operatingSystem ? row.operatingSystem.operatingSystemFamily :
102+
''}}
103+
</td>
101104
</ng-container>
102105

103106
<!-- Header and Row Declarations -->

src/app/components/hardware/hardware-overview/hardware-overview.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1 class="title">Hardware</h1>
1818
</span>
1919
</p>
2020

21-
<table cdk-table class="table card is-fullwidth is-striped is-hoverable" [dataSource]="dataSource.value">
21+
<table cdk-table class="table card is-fullwidth is-striped is-hoverable is-clickable" [dataSource]="dataSource.value">
2222

2323
<!-- Name Definition -->
2424
<ng-container cdkColumnDef="name">
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.table {
22
margin: 5px 0 0 0;
3-
cursor: default;
43
}

src/app/components/hardware/hardware-overview/hardware-overview.component.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Component, OnInit} from '@angular/core';
2-
import {BehaviorSubject, combineLatest} from 'rxjs';
1+
import {Component, OnDestroy, OnInit} from '@angular/core';
2+
import {BehaviorSubject, combineLatest, Subscription} from 'rxjs';
33
import {Hardware} from 'cloudiator-rest-api';
44
import {CloudDataService} from '../../../services/cloud-data.service';
55
import {FormControl} from '@angular/forms';
@@ -10,20 +10,23 @@ import {ActivatedRoute} from '@angular/router';
1010
templateUrl: './hardware-overview.component.html',
1111
styleUrls: ['./hardware-overview.component.scss']
1212
})
13-
export class HardwareOverviewComponent implements OnInit {
13+
export class HardwareOverviewComponent implements OnInit, OnDestroy {
1414

15-
dataSource: BehaviorSubject<Hardware[]>;
15+
dataSource = new BehaviorSubject<Hardware[]>([]);
1616

1717
searchFormControl = new FormControl();
1818

1919
sortKey = new BehaviorSubject<string>('');
2020
sortDirection = new BehaviorSubject<string>('');
2121

22+
subscriptions: Subscription[] = [];
23+
2224
constructor(private activatedRoute: ActivatedRoute,
2325
public cloudDataService: CloudDataService) {
2426
}
2527

2628
ngOnInit() {
29+
this.adjustSort('cores');
2730

2831
combineLatest(this.cloudDataService.findHardware(), this.searchFormControl.valueChanges, this.sortKey, this.sortDirection)
2932
.subscribe(([changedHardwareData, searchTerm, sortKey, sortDirection]) => {
@@ -50,12 +53,6 @@ export class HardwareOverviewComponent implements OnInit {
5053
this.dataSource.next(sortedHardware);
5154
});
5255

53-
54-
this.cloudDataService.findHardware().subscribe(hardware => {
55-
this.dataSource = new BehaviorSubject<Hardware[]>(hardware);
56-
this.adjustSort('cores');
57-
});
58-
5956
this.searchFormControl.setValue('');
6057

6158

@@ -68,6 +65,10 @@ export class HardwareOverviewComponent implements OnInit {
6865
});
6966
}
7067

68+
ngOnDestroy(): void {
69+
this.subscriptions.forEach(s => s.unsubscribe());
70+
}
71+
7172
adjustSort(key: string) {
7273
if (this.sortKey.value === key) {
7374
if (this.sortDirection.value === 'asc') {

src/app/components/images/images-overview/images-overview.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1 class="title">Images</h1>
1818
</span>
1919
</p>
2020

21-
<table cdk-table class="table card is-fullwidth is-striped is-hoverable" [dataSource]="dataSource.value">
21+
<table cdk-table class="table card is-fullwidth is-striped is-hoverable is-clickable" [dataSource]="dataSource.value">
2222

2323
<!-- Name Definition -->
2424
<ng-container cdkColumnDef="name">
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.table {
22
margin: 5px 0 0 0;
3-
cursor: default;
43
}

src/app/components/images/images-overview/images-overview.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {ActivatedRoute} from '@angular/router';
1212
})
1313
export class ImagesOverviewComponent implements OnInit {
1414

15-
dataSource: BehaviorSubject<Image[]>;
15+
dataSource = new BehaviorSubject<Image[]>([]);
1616

1717
searchFormControl = new FormControl();
1818

@@ -23,6 +23,7 @@ export class ImagesOverviewComponent implements OnInit {
2323
public cloudDataService: CloudDataService) { }
2424

2525
ngOnInit() {
26+
this.adjustSort('name');
2627

2728
combineLatest(this.cloudDataService.findImages(), this.searchFormControl.valueChanges, this.sortKey, this.sortDirection)
2829
.subscribe(([changedHardwareData, searchTerm, sortKey, sortDirection]) => {
@@ -50,12 +51,6 @@ export class ImagesOverviewComponent implements OnInit {
5051
});
5152

5253

53-
this.cloudDataService.findImages().subscribe(images => {
54-
this.dataSource = new BehaviorSubject<Image[]>(images);
55-
this.adjustSort('name');
56-
});
57-
58-
5954
this.searchFormControl.setValue('');
6055

6156

src/app/components/locations/locations-overview/locations-overview.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1 class="title">Locations</h1>
1818
</span>
1919
</p>
2020

21-
<table cdk-table class="table card is-fullwidth is-striped is-hoverable" [dataSource]="dataSource.value">
21+
<table cdk-table class="table card is-fullwidth is-striped is-hoverable is-clickable" [dataSource]="dataSource.value">
2222

2323
<!-- Name Definition -->
2424
<ng-container cdkColumnDef="name">
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.table {
22
margin: 5px 0 0 0;
3-
cursor: default;
43
}

src/app/components/locations/locations-overview/locations-overview.component.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {CloudDataService} from '../../../services/cloud-data.service';
1111
})
1212
export class LocationsOverviewComponent implements OnInit {
1313

14-
dataSource: BehaviorSubject<Location[]>;
14+
dataSource = new BehaviorSubject<Location[]>([]);
1515

1616
searchFormControl = new FormControl();
1717

@@ -22,6 +22,7 @@ export class LocationsOverviewComponent implements OnInit {
2222
}
2323

2424
ngOnInit() {
25+
this.adjustSort('name');
2526

2627
combineLatest(this.cloudDataService.findLocations(), this.searchFormControl.valueChanges, this.sortKey, this.sortDirection)
2728
.subscribe(([changedHardwareData, searchTerm, sortKey, sortDirection]) => {
@@ -48,13 +49,6 @@ export class LocationsOverviewComponent implements OnInit {
4849
this.dataSource.next(sortedLocations);
4950
});
5051

51-
52-
this.cloudDataService.findLocations().subscribe(locations => {
53-
this.dataSource = new BehaviorSubject<Location[]>(locations);
54-
this.adjustSort('cores');
55-
});
56-
57-
5852
this.searchFormControl.setValue('');
5953
}
6054

0 commit comments

Comments
 (0)