Skip to content

Commit

Permalink
fix: change offset to page
Browse files Browse the repository at this point in the history
change offset name to page
for paginated

Reviewed-by: andriacap
[Refs ticket]: #4
  • Loading branch information
andriacap committed Jan 19, 2023
1 parent ca3319e commit 97ae9bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[rowHeight]="40"
[externalPaging]="true"
[count]="page.count"
[offset]="page.offset"
[offset]="page.page"
[limit]="page.limit"
[rows]="rows"
[columns]="columns"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface SitesGroupsExtended extends Omit<GeoJSON.Feature, "P"|"type"> {
interface Page {
count: number;
limit: number;
offset: number;
page: number;
}

interface PaginatedSitesGroup extends Page{
Expand Down Expand Up @@ -69,7 +69,7 @@ interface CustomGeoJson {
})
export class MonitoringSitesGroupsComponent implements OnInit {
@ViewChild(DatatableComponent) table: DatatableComponent;
@Input() page: Page = {count: 0, limit: 0, offset: 0};
@Input() page: Page = {count: 0, limit: 0, page: 0};
@Input() dataTable;
@Input() sitesGroups:CustomGeoJson;
@Input() columnNameSiteGroup: typeof columnNameSiteGroup = columnNameSiteGroup;
Expand All @@ -82,11 +82,11 @@ export class MonitoringSitesGroupsComponent implements OnInit {
this.getSites()
}

getSites(offset=1, params={}) {
getSites(page=1, params={}) {
this._sites_service
.getSitesGroups(offset, LIMIT, params)
.getSitesGroups(page, LIMIT, params)
.subscribe((data: PaginatedSitesGroup) => {
this.page = {count: data.count, limit: data.limit, offset: data.offset - 1}
this.page = {count: data.count, limit: data.limit, page: data.page - 1}
this.sitesGroups = this._sites_service.setFormatToGeoJson(data)
this.dataTable = this._sites_service.getDataTable(this.sitesGroups);
});
Expand All @@ -95,7 +95,7 @@ export class MonitoringSitesGroupsComponent implements OnInit {

setPage($event) {
console.log('setPage Sitesgroups Components')
this.getSites($event.offset + 1, this.filters)
this.getSites($event.page + 1, this.filters)
}

onSortEvent(filters) {
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/services/data-table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Observable} from "rxjs";
interface Page {
count: number;
limit: number;
offset: number;
page: number;
}

interface ColName {
Expand All @@ -31,13 +31,13 @@ objectsStatus:ItemsObjectTable;
rowStatus:ItemObjectTable;
idObj:number;

public page: Page = {count: 0, limit: 0, offset: 0};
public page: Page = {count: 0, limit: 0, page: 0};
constructor(
) {}


setPaginationConfig(count:number=0,limit:number=0, offset:number=0):Page{
return {"count":count,"limit":limit,"offset":offset}
setPaginationConfig(count:number=0,limit:number=0, page:number=0):Page{
return {"count":count,"limit":limit,"page":page}
}
// setPage(e){
// this.obj
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/services/sites.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface SitesGroupsExtended extends Omit<GeoJSON.Feature, "P"|"type"> {
interface Page {
count: number;
limit: number;
offset: number;
page: number;
}

interface PaginatedSitesGroup extends Page{
Expand All @@ -43,8 +43,8 @@ export class SitesService {
private _cacheService: CacheService
) {}

getSitesGroups(offset=1, limit=10, params={}) {
return this._cacheService.request("get", `sites_groups`, {queryParams: {offset, limit, ...params}});
getSitesGroups(page=1, limit=10, params={}) {
return this._cacheService.request("get", `sites_groups`, {queryParams: {page, limit, ...params}});
}

setFormatToGeoJson(data:PaginatedSitesGroup):CustomGeoJson{
Expand Down

0 comments on commit 97ae9bb

Please sign in to comment.