minor usability enhancements
This commit is contained in:
@@ -2,7 +2,7 @@ import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} f
|
||||
import HostRecord from '../../../structures/HostRecord';
|
||||
import {ApiService} from '../../../service/api.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AlertController, ModalController} from '@ionic/angular';
|
||||
import {AlertController, LoadingController, ModalController} from '@ionic/angular';
|
||||
import {ColumnsComponent} from './columns/columns.component';
|
||||
import {AgGridAngular} from 'ag-grid-angular';
|
||||
|
||||
@@ -27,6 +27,7 @@ export class DatabaseComponent implements OnInit {
|
||||
protected api: ApiService,
|
||||
protected modals: ModalController,
|
||||
protected alerts: AlertController,
|
||||
protected loader: LoadingController,
|
||||
) { }
|
||||
|
||||
title = 'app';
|
||||
@@ -34,10 +35,14 @@ export class DatabaseComponent implements OnInit {
|
||||
rowData = [];
|
||||
|
||||
ngOnInit() {
|
||||
this.getInitObservable().subscribe(() => {
|
||||
this.getColumnLoadObservable().subscribe(() => {
|
||||
this.getDataLoadObservable().subscribe(() => {
|
||||
|
||||
this.loader.create({message: 'Loading database...'}).then(loader => {
|
||||
loader.present().then(() => {
|
||||
this.getInitObservable().subscribe(() => {
|
||||
this.getColumnLoadObservable().subscribe(() => {
|
||||
this.getDataLoadObservable().subscribe(() => {
|
||||
loader.dismiss();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -86,6 +91,7 @@ export class DatabaseComponent implements OnInit {
|
||||
onInsertRow() {
|
||||
this.rowData.push({});
|
||||
this.agGridElement.api.setRowData(this.rowData);
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
async onRemoveRow() {
|
||||
@@ -107,6 +113,7 @@ export class DatabaseComponent implements OnInit {
|
||||
this.rowData = newRows;
|
||||
this.agGridElement.api.setRowData(this.rowData);
|
||||
this.lastClickRow = -1;
|
||||
this.dirty = true;
|
||||
},
|
||||
}
|
||||
],
|
||||
@@ -153,11 +160,16 @@ export class DatabaseComponent implements OnInit {
|
||||
}
|
||||
|
||||
onSyncRecords() {
|
||||
this.api.post(`/db/${this.hostRecord.PageId}/${this.hostRecord.UUID}/set/${this.hostRecord.Value.Value}/data`, this.rowData)
|
||||
.subscribe(res => {
|
||||
this.rowData = res.data.map(x => x.RowData);
|
||||
this.agGridElement.api.setRowData(this.rowData);
|
||||
this.dirty = false;
|
||||
this.loader.create({message: 'Syncing the database...'}).then(loader => {
|
||||
loader.present().then(() => {
|
||||
this.api.post(`/db/${this.hostRecord.PageId}/${this.hostRecord.UUID}/set/${this.hostRecord.Value.Value}/data`, this.rowData)
|
||||
.subscribe(res => {
|
||||
this.rowData = res.data.map(x => x.RowData);
|
||||
this.agGridElement.api.setRowData(this.rowData);
|
||||
this.dirty = false;
|
||||
loader.dismiss();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user