Skip to content

Commit

Permalink
Merge pull request #978 from aneoconsulting/fix/table-with-less-data
Browse files Browse the repository at this point in the history
fix: table with less data
  • Loading branch information
ngruelaneo authored Mar 20, 2024
2 parents f679951 + 88f0ee4 commit 84c2db2
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 88 deletions.
36 changes: 21 additions & 15 deletions src/app/applications/components/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,27 @@ export class ApplicationsTableComponent implements OnInit, AfterViewInit {
}

@Input({ required: true }) set data(entries: ApplicationRaw[]) {
entries.forEach((entry, index) => {
const application = this._data[index];
if (application && application.raw.name === entry.name && application.raw.version === entry.version) {
this._data[index].value$?.next(entry);
} else {
const lineData: ApplicationData = {
raw: entry,
queryTasksParams: this.createTasksByStatusQueryParams(entry.name, entry.version),
filters: this.countTasksByStatusFilters(entry.name, entry.version),
value$: new Subject<ApplicationRaw>()
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
if (entries.length !== 0) {
this._data = this.data.filter(d => entries.find(entry => entry.name === d.raw.namespace && entry.version === d.raw.version));
entries.forEach((entry, index) => {
const application = this._data[index];
if (application && application.raw.name === entry.name && application.raw.version === entry.version) {
this._data[index].value$?.next(entry);
} else {
const lineData: ApplicationData = {
raw: entry,
queryTasksParams: this.createTasksByStatusQueryParams(entry.name, entry.version),
filters: this.countTasksByStatusFilters(entry.name, entry.version),
value$: new Subject<ApplicationRaw>()
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
} else {
this._data = [];
this.dataSource.data = this._data;
}
}

@Output() optionsChange = new EventEmitter<never>();
Expand Down
36 changes: 21 additions & 15 deletions src/app/partitions/components/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,27 @@ export class PartitionsTableComponent implements OnInit, AfterViewInit {
}

@Input({ required: true }) set data(entries: PartitionRaw[]) {
entries.forEach((entry, index) => {
const partition = this._data[index];
if (partition && partition.raw.id === entry.id) {
this._data[index].value$?.next(entry);
} else {
const lineData: PartitionData = {
raw: entry,
queryTasksParams: this.createTasksByStatusQueryParams(entry.id),
filters: this.countTasksByStatusFilters(entry.id),
value$: new Subject<PartitionRaw>()
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
if (entries.length !== 0) {
this._data = this.data.filter(d => entries.find(entry => entry.id === d.raw.id));
entries.forEach((entry, index) => {
const partition = this._data[index];
if (partition && partition.raw.id === entry.id) {
this._data[index].value$?.next(entry);
} else {
const lineData: PartitionData = {
raw: entry,
queryTasksParams: this.createTasksByStatusQueryParams(entry.id),
filters: this.countTasksByStatusFilters(entry.id),
value$: new Subject<PartitionRaw>()
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
} else {
this._data = [];
this.dataSource.data = this._data;
}
}

@Output() optionsChange = new EventEmitter<never>();
Expand Down
32 changes: 19 additions & 13 deletions src/app/results/components/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,25 @@ export class ResultsTableComponent implements AfterViewInit {
private _data: ResultData[] = [];

@Input({required: true}) set data(entries: ResultRaw[]) {
entries.forEach((entry, index) => {
const result = this._data[index];
if (result && result.raw.resultId === entry.resultId) {
this._data[index].value$?.next(entry);
} else {
const lineData: ResultData = {
raw: entry,
value$: new Subject<ResultRaw>(),
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
if (entries.length !== 0) {
this._data = this.data.filter(d => entries.find(entry => entry.resultId === d.raw.resultId));
entries.forEach((entry, index) => {
const result = this._data[index];
if (result && result.raw.resultId === entry.resultId) {
this._data[index].value$?.next(entry);
} else {
const lineData: ResultData = {
raw: entry,
value$: new Subject<ResultRaw>(),
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
} else {
this._data = [];
this.dataSource.data = this._data;
}
}

get data(): ResultData[] {
Expand Down
58 changes: 27 additions & 31 deletions src/app/sessions/components/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,38 +187,34 @@ export class ApplicationsTableComponent implements OnInit, AfterViewInit {
});

this.data$.subscribe(entries => {
entries.forEach((entry, index) => {
const session = this._data[index];
if (session && session.raw.sessionId === entry.sessionId) {
session.raw = entry;
this._data.splice(index, 1, session);
this._data[index].value$.next(entry);
} else {
const queryParams = new Map<ColumnKey<SessionRaw>, Params>();
queryParams.set('sessionId', { '0-root-1-0': entry.sessionId });
const session: SessionData = {
raw: entry,
queryParams,
queryTasksParams: this.createTasksByStatusQueryParams(entry.sessionId),
resultsQueryParams: {...this.createResultsQueryParams(entry.sessionId)},
filters: this.countTasksByStatusFilters(entry.sessionId),
value$: new Subject<SessionRaw>(),
};
this._data.splice(index, 1, session);
}
});
this.dataSource.data = this._data;
});
}

hasDifference(first: SessionRaw, second: SessionRaw): boolean{
const keys = Object.keys(first);
for(const key of keys) {
if (JSON.stringify(first[key as keyof SessionRaw]) !== JSON.stringify(second[key as keyof SessionRaw])) {
return true;
if (entries.length !== 0) {
this._data = this.data.filter(d => entries.find(entry => entry.sessionId === d.raw.sessionId));
entries.forEach((entry, index) => {
const session = this._data[index];
if (session && session.raw.sessionId === entry.sessionId) {
session.raw = entry;
this._data.splice(index, 1, session);
this._data[index].value$.next(entry);
} else {
const queryParams = new Map<ColumnKey<SessionRaw>, Params>();
queryParams.set('sessionId', { '0-root-1-0': entry.sessionId });
const session: SessionData = {
raw: entry,
queryParams,
queryTasksParams: this.createTasksByStatusQueryParams(entry.sessionId),
resultsQueryParams: {...this.createResultsQueryParams(entry.sessionId)},
filters: this.countTasksByStatusFilters(entry.sessionId),
value$: new Subject<SessionRaw>(),
};
this._data.splice(index, 1, session);
}
});
this.dataSource.data = this._data;
} else {
this._data = [];
this.dataSource.data = this._data;
}
}
return false;
});
}

getIcon(name: string): string {
Expand Down
34 changes: 20 additions & 14 deletions src/app/tasks/components/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,26 @@ export class TasksTableComponent implements AfterViewInit {
}

@Input({required: true}) set data(entries: TaskSummary[]) {
entries.forEach((entry, index) => {
const task = this._data[index];
if (task && task.raw.id === entry.id) {
this._data[index].value$?.next(entry);
} else {
const lineData: TaskData = {
raw: entry,
resultsQueryParams: this.createResultsQueryParams(entry.id),
value$: new Subject<TaskSummary>(),
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
if (entries.length !== 0) {
this._data = this.data.filter(d => entries.find(entry => entry.id === d.raw.id));
entries.forEach((entry, index) => {
const task = this._data[index];
if (task && task.raw.id === entry.id) {
this._data[index].value$?.next(entry);
} else {
const lineData: TaskData = {
raw: entry,
resultsQueryParams: this.createResultsQueryParams(entry.id),
value$: new Subject<TaskSummary>(),
};
this._data.splice(index, 1, lineData);
}
});
this.dataSource.data = this._data;
} else {
this._data = [];
this.dataSource.data = this._data;
}
}

get columnKeys() {
Expand Down

1 comment on commit 84c2db2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 89%
88.54% (2774/3133) 70.77% (511/722) 80.22% (645/804)

JUnit

Tests Skipped Failures Errors Time
770 0 💤 0 ❌ 0 🔥 57.531s ⏱️
Files coverage (89%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files88.5470.7780.2289.4 
applications100100100100 
   index.component.ts100100100100 
applications/components80.3762.566.6684.84 
   table.component.ts80.3762.566.6684.84126–153, 248, 262
applications/services87.577.7776.1988.23 
   applications-filters.service.ts79.1610062.581.8175–81
   applications-grpc.service.ts9271.4210091.6676–82
   applications-index.service.ts91.366.668090.970–74
components96.0592.4291.5996.35 
   actions-toolbar-group.component.ts100100100100 
   actions-toolbar.component.ts100100100100 
   auto-refresh-button.component.html100100100100 
   auto-refresh-button.component.ts1006010010036, 59
   auto-refresh-dialog.component.html100100100100 
   auto-refresh-dialog.component.ts100100100100 
   columns-button.component.ts100100100100 
   columns-modify-dialog.component.html100100100100 
   columns-modify-dialog.component.ts94.599089.4710050
   count-tasks-by-status.component.ts1005010010056
   page-header.component.html100100100100 
   page-header.component.ts8010008033
   page-section-header.component.ts8010008031
   page-section.component.ts100100100100 
   refresh-button.component.ts100100100100 
   share-url.component.ts92.851007592.337
   show-action-area.component.html100100100100 
   show-action-area.component.ts100100100100 
   show-actions.component.html100100100100 
   show-actions.component.ts100100100100 
   show-card-content.component.html100100100100 
   show-card-content.component.ts100100100100 
   show-card.component.ts7510007537–38
   show-page.component.ts100100100100 
   spinner.component.ts100100100100 
   table-actions-toolbar.component.html100100100100 
   table-actions-toolbar.component.ts100100100100 
   table-container.component.ts100100100100 
   view-tasks-by-status-dialog.component.html100100100100 
   view-tasks-by-status-dialog.component.ts100100100100 
   view-tasks-by-status.component.ts73.5206072.7259, 88–106
components/filters94.2187.493.5894.24 
   filters-chips.component.html100100100100 
   filters-chips.component.ts100100100100 
   filters-dialog-and.component.html100100100100 
   filters-dialog-and.component.ts100100100100 
   filters-dialog-filter-field.component.html100100100100 
   filters-dialog-filter-field.component.ts92.9487.597.2992.36104, 114, 124, 136–139, 147, 192–194, 201, 334
   filters-dialog-input.component.html100100100100 
   filters-dialog-input.component.ts8278.7871.4283.3357, 85–86, 142–151
   filters-dialog-or.component.html100100100100 
   filters-dialog-or.component.ts100100100100 
   filters-dialog.component.html100100100100 
   filters-dialog.component.ts100100100100 
   filters-toolbar.component.html100100100100 
   filters-toolbar.component.ts100100100100 
components/navigation99.1197.0595.8399.07 
   add-external-service-dialog.component.html100100100100 
   add-external-service-dialog.component.ts100100100100 
   change-language-button.component.html100100100100 
   change-language-button.component.ts97.291009096.9657
   edit-external-service-dialog.component.html100100100100 
   edit-external-service-dialog.component.ts100100100100 
   form-external-service.component.html100100100100 
   form-external-service.component.ts100100100100 
   manage-external-services-dialog.component.html100100100100 
   manage-external-services-dialog.component.ts100100100100 
   navigation.component.html100100100100 
   navigation.component.ts98.1893.3388.8898.14113
   theme-selector.component.html100100100100 
   theme-selector.component.ts100100100100 
components/table80.268.7565.3880 
   table-actions.component.html100100100100 
   table-actions.component.ts87.5100087.529
   table-cell.component.html100100100100 
   table-cell.component.ts90.7484.6189.4790.7491, 105, 115–119
   table-empty-data.component.ts100100100100 
   table-inspect-object-dialog.component.html100100100100 
   table-inspect-object-dialog.component.ts41.66100041.6626–40
   table-inspect-object.component.html100100100100 
   table-inspect-object.component.ts60006031–50
dashboard89.0135.7193.3388.88 
   index.component.html100100100100 
   index.component.ts88.8835.7193.3388.76166–180, 193, 231
dashboard/components99.210098.5799.19 
   add-line-dialog.component.ts100100100100 
   add-statuses-group-dialog.component.ts100100100100 
   edit-name-line-dialog.component.ts100100100100 
   edit-status-group-dialog.component.ts100100100100 
   form-name-line.component.html100100100100 
   form-name-line.component.ts95.6510083.3395.6586
   form-statuses-group.component.html100100100100 
   form-statuses-group.component.ts100100100100 
   manage-groups-dialog.component.html100100100100 
   manage-groups-dialog.component.ts100100100100 
   reorganize-lines-dialog.component.html100100100100 
   reorganize-lines-dialog.component.ts100100100100 
   split-lines-dialog.component.ts100100100100 
   statuses-group-card.component.html100100100100 
   statuses-group-card.component.ts97.9110010097.72138
dashboard/components/lines98.0188.8895.7497.96 
   applications-line.component.html100100100100 
   applications-line.component.ts97.4390.996.2997.36138–140
   task-by-status-line.component.html100100100100 
   task-by-status-line.component.ts98.7985.719598.76210
dashboard/services100100100100 
   dashboard-index.service.ts100100100100 
   dashboard-storage.service.ts100100100100 
directives50100050 
   no-wrap.directive.ts501000505–6
healthcheck100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
healthcheck/services100100100100 
   healthcheck-grpc.service.ts100100100100 
   healthcheck-index.service.ts100100100100 
partitions/components79.785068.1882.95 
   table.component.html100100100100 
   table.component.ts79.565068.1882.7578–105, 179, 211
partitions/services21.730018.18 
   partitions-index.service.ts21.730018.1811–120
pipes250018.18 
   duration.pipe.ts16.660011.767–27
   empty-cell.pipe.ts5000406–10
results/components74.2405078.68 
   table.component.html100100100100 
   table.component.ts73.8405078.3374–96, 111
results/services34.4808.3329.62 
   results-index.service.ts21.730018.1810–117
   results-statuses.service.ts83.33100508016
services93.4877.5386.7993.53 
   auto-refresh.service.ts100100100100 
   default-config.service.ts10050100100193
   environment.service.ts80100507519
   filters.service.ts50037.55277–93
   grpc-build-request.service.ts64.288.3316.6664.2826, 39, 49, 59, 69
   icons.service.ts100100100100 
   navigation.service.ts10080100100116
   notification.service.ts100100100100 
   query-params.service.ts100100100100 
   share-url.service.ts100100100100 
   storage.service.ts98.0310010097.9595
   table-storage.service.ts500042.8511–31
   table-url.service.ts100100100100 
   table.service.ts100100100100 
   tasks-by-status.service.ts100100100100 
   user-grpc.service.ts100100100100 
   user.service.ts100100100100 
   utils.service.ts97.5694.1110097.43119
   versions-grpc.service.ts100100100100 
   versions.service.ts1007010010014, 25, 32
sessions/components81.5765.6261.5387.68 
   table.component.html100100100100 
   table.component.ts81.4565.6261.5387.5992, 153–159, 195–197, 214–215, 288–298, 320
sessions/services46.3721.4225.9245.31 
   sessions-filters.service.ts66.66506070168–186
   sessions-index.service.ts17.850014.8111–218
   sessions-statuses.service.ts62.51002557.1418–26
tasks/components76.8644.1155.8882.25 
   table.component.html100100100100 
   table.component.ts76.6944.1155.8882.11106, 118–124, 173–185, 214–236, 249
tasks/services60.95266060.6 
   tasks-filters.service.ts69.6983.336073.33207–220
   tasks-grpc.service.ts21.210018.7513–155
   tasks-index.service.ts87.09808086.66229, 295–300
   tasks-statuses.service.ts87.507585.7141
tokens100100100100 
   filters.token.ts100100100100 
types100100100100 
   filter-definition.ts100100100100 

Please sign in to comment.