Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table with less data #978

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading