Skip to content
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
2 changes: 1 addition & 1 deletion src/app/components/data-viewer/data-viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</div>
<mat-paginator
*ngIf="showPagination"
[length]="pageData.item.len"
[length]="page.totalSize"
[pageSizeOptions]="[10,20,50,100]"
[pageIndex]="page.pageIndex"
(page)="onPageEvent($event)"
Expand Down
11 changes: 7 additions & 4 deletions src/app/components/data-viewer/data-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
public page = {
pageIndex: 0,
pageSize: 20,
totalSize: 0
};
cli$: Observable<any> = null;
public data = [];
Expand Down Expand Up @@ -120,7 +121,6 @@ export class DataViewerComponent implements OnInit, OnChanges {
this._store.dispatch(new ReqFetchTree({id: this.pageData.id}));
this.hashCachedData = null;
this.setCachedData = null;
this.pageData.item.len -= values.length;
this.fetchData();
this.util.showMessage('Deleted successfully.');
if (cb) { cb(); }
Expand Down Expand Up @@ -178,15 +178,17 @@ export class DataViewerComponent implements OnInit, OnChanges {
this.showPagination = false;
if (type === 'list') {
this.loadingPageData = true;
this.redisService.call(instanceId, [['LRANGE', key, start, end]]).subscribe(ret => {
this.redisService.call(instanceId, [['LRANGE', key, start, end], ['LLEN', key]]).subscribe(ret => {
this.page.totalSize = ret[1];
this.data = injectValuesToArray(ret[0]);
this.showPagination = true;
this.loadingPageData = false;
}
);
} else if (type === 'zset') {
this.loadingPageData = true;
this.redisService.call(instanceId, [['ZRANGE', key, start, end, 'withscores']]).subscribe(ret => {
this.redisService.call(instanceId, [['ZRANGE', key, start, end, 'withscores'], ['ZCARD', key]]).subscribe(ret => {
this.page.totalSize = ret[1];
this.data = [];
for (let i = 0; i < ret[0].length;) {
this.data.push({
Expand All @@ -205,6 +207,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
this.loadingPageData = true;
this.redisService.call(instanceId, [['SMEMBERS', key]]).subscribe(ret => {
this.setCachedData = injectValuesToArray(ret[0]);
this.page.totalSize = this.setCachedData.length;
this.data = this.setCachedData.slice(start, end);
this.loadingPageData = false;
this.showPagination = true;
Expand All @@ -225,6 +228,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
});
i += 2;
}
this.page.totalSize = this.hashCachedData.length;
this.data = this.hashCachedData.slice(start, end);
this.loadingPageData = false;
this.showPagination = true;
Expand Down Expand Up @@ -277,7 +281,6 @@ export class DataViewerComponent implements OnInit, OnChanges {
this._store.dispatch(new ReqFetchTree({id: this.pageData.id}));
this.hashCachedData = null;
this.setCachedData = null;
this.pageData.item.len += ret.len;
this.fetchData();
}
};
Expand Down