Skip to content

bug fix #229

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

Merged
merged 10 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix paging bug and update dialog title
  • Loading branch information
jiangliwu committed Jan 9, 2019
commit 8e636cf5923cff60066c1b350f0a474f66f098cd
4 changes: 3 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ export class AppComponent implements OnInit {
*/
onNewValue(newValue) {
this.redisService.call(newValue.id, [newValue.rawLine]).subscribe(ret => {
this.onRefresh();
if (newValue.from === 'root') {
this.onRefresh();
}
if (newValue.onSuccess) {
newValue.onSuccess(newValue);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 mat-dialog-title>{{isEditMode()?'Edit Records':'Add new Records'}}</h1>
<h1 mat-dialog-title>{{title}}</h1>
<div mat-dialog-content>
<mat-form-field [ngClass] = "[data.hideType ? 'readOnlyField' : '']">
<textarea matInput placeholder="Key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class ValueMode {
})
export class AddValueDialogComponent implements OnInit {

title = '';
constructor(
public dialogRef: MatDialogRef<AddValueDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: ValueMode,
Expand All @@ -47,6 +48,12 @@ export class AddValueDialogComponent implements OnInit {
}

ngOnInit() {
console.log(this.data.from);
if (this.data.from === 'root') {
this.title = this.isEditMode() ? 'Edit Records' : 'Add new Records';
} else {
this.title = this.isEditMode() ? 'Edit Value' : 'Add New Value';
}
}

isEditMode() {
Expand Down
16 changes: 11 additions & 5 deletions src/app/components/data-viewer/data-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class DataViewerComponent implements OnInit, OnChanges {
private util: UtilService,
private _store: Store<any>,
) {

this.cli$ = this._store.select('cli');
}

Expand Down Expand Up @@ -96,10 +95,8 @@ export class DataViewerComponent implements OnInit, OnChanges {
}
this.dialogService.open(ConfirmDialogComponent, {
width: '250px', data: {

title: 'Delete Confirmation',
message: `Are you sure you want to delete ${element ? 'this' : 'selected'} value${values.length > 1 ? 's' : ''} ?`

}
}).afterClosed().subscribe(ret => {
if (ret) {
Expand All @@ -121,6 +118,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
this._store.dispatch({type: REQ_FETCH_TREE, payload: {id: this.pageData.id}});
this.hashCachedData = null;
this.setCachedData = null;
this.pageData.item.len -= values.length;
this.fetchData();
this.util.showMessage('Delete successful');
if (cb) { cb(); }
Expand Down Expand Up @@ -170,7 +168,6 @@ export class DataViewerComponent implements OnInit, OnChanges {
const type = this.pageData.item.type;
const key = this.pageData.item.key;
const instanceId = this.pageData.id;

const injectValuesToArray = (values) => (_.map(values, (v, index) => ({
index: this.page.pageIndex * this.page.pageSize + index,
value: v
Expand Down Expand Up @@ -211,6 +208,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
this.showPagination = true;
});
} else {
this.showPagination = true;
this.data = this.setCachedData.slice(start, end);
}
} else if (type === 'hash') {
Expand All @@ -231,6 +229,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
}
);
} else {
this.showPagination = true;
this.data = this.hashCachedData.slice(start, end);
}
}
Expand Down Expand Up @@ -274,6 +273,7 @@ export class DataViewerComponent implements OnInit, OnChanges {
this._store.dispatch({type: REQ_FETCH_TREE, payload: {id: this.pageData.id}});
this.hashCachedData = null;
this.setCachedData = null;
this.pageData.item.len += ret.len;
this.fetchData();
}
};
Expand Down Expand Up @@ -417,7 +417,13 @@ export class DataViewerComponent implements OnInit, OnChanges {
* when type changed from parent
*/
ngOnChanges(changes: SimpleChanges): void {
this.page.pageIndex = 0;

if (changes.pageData.previousValue && changes.pageData.currentValue &&
changes.pageData.currentValue.item.key !== changes.pageData.previousValue.item.key
) {
this.page.pageIndex = 0;
}

this.data = [];
this.selectedMap = {};
this.setCachedData = null;
Expand Down