Skip to content

Commit ec585b8

Browse files
committed
fixes issue 265 and total data size is now directly fetched from backend
1 parent cb814d9 commit ec585b8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/app/components/data-viewer/data-viewer.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
</div>
111111
<mat-paginator
112112
*ngIf="showPagination"
113-
[length]="pageData.item.len"
113+
[length]="page.totalSize"
114114
[pageSizeOptions]="[10,20,50,100]"
115115
[pageIndex]="page.pageIndex"
116116
(page)="onPageEvent($event)"

src/app/components/data-viewer/data-viewer.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
3737
public page = {
3838
pageIndex: 0,
3939
pageSize: 20,
40+
totalSize: 0
4041
};
4142
cli$: Observable<any> = null;
4243
public data = [];
@@ -120,7 +121,6 @@ export class DataViewerComponent implements OnInit, OnChanges {
120121
this._store.dispatch(new ReqFetchTree({id: this.pageData.id}));
121122
this.hashCachedData = null;
122123
this.setCachedData = null;
123-
this.pageData.item.len -= values.length;
124124
this.fetchData();
125125
this.util.showMessage('Deleted successfully.');
126126
if (cb) { cb(); }
@@ -178,15 +178,17 @@ export class DataViewerComponent implements OnInit, OnChanges {
178178
this.showPagination = false;
179179
if (type === 'list') {
180180
this.loadingPageData = true;
181-
this.redisService.call(instanceId, [['LRANGE', key, start, end]]).subscribe(ret => {
181+
this.redisService.call(instanceId, [['LRANGE', key, start, end], ['LLEN', key]]).subscribe(ret => {
182+
this.page.totalSize = ret[1];
182183
this.data = injectValuesToArray(ret[0]);
183184
this.showPagination = true;
184185
this.loadingPageData = false;
185186
}
186187
);
187188
} else if (type === 'zset') {
188189
this.loadingPageData = true;
189-
this.redisService.call(instanceId, [['ZRANGE', key, start, end, 'withscores']]).subscribe(ret => {
190+
this.redisService.call(instanceId, [['ZRANGE', key, start, end, 'withscores'], ['ZCARD', key]]).subscribe(ret => {
191+
this.page.totalSize = ret[1];
190192
this.data = [];
191193
for (let i = 0; i < ret[0].length;) {
192194
this.data.push({
@@ -205,6 +207,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
205207
this.loadingPageData = true;
206208
this.redisService.call(instanceId, [['SMEMBERS', key]]).subscribe(ret => {
207209
this.setCachedData = injectValuesToArray(ret[0]);
210+
this.page.totalSize = this.setCachedData.length;
208211
this.data = this.setCachedData.slice(start, end);
209212
this.loadingPageData = false;
210213
this.showPagination = true;
@@ -225,6 +228,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
225228
});
226229
i += 2;
227230
}
231+
this.page.totalSize = this.hashCachedData.length;
228232
this.data = this.hashCachedData.slice(start, end);
229233
this.loadingPageData = false;
230234
this.showPagination = true;
@@ -277,7 +281,6 @@ export class DataViewerComponent implements OnInit, OnChanges {
277281
this._store.dispatch(new ReqFetchTree({id: this.pageData.id}));
278282
this.hashCachedData = null;
279283
this.setCachedData = null;
280-
this.pageData.item.len += ret.len;
281284
this.fetchData();
282285
}
283286
};

0 commit comments

Comments
 (0)