Browse Source

..

master
drfelfel 1 year ago
parent
commit
60aae88d89
3 changed files with 39 additions and 19 deletions
  1. +2
    -2
      src/database/drawer.list.ts
  2. +2
    -2
      src/routes/panel/volunteer/table/table.component.html
  3. +35
    -15
      src/routes/panel/volunteer/table/table.component.ts

+ 2
- 2
src/database/drawer.list.ts View File

@ -51,9 +51,9 @@ export const items: Item[] = [
icon: 'exit_to_app',
path: '/panel/exit'
},
/* {
{
title: 'گفتگو با داوطلبین',
icon: 'forum',
path: '/panel/chat'
}*/
}
]

+ 2
- 2
src/routes/panel/volunteer/table/table.component.html View File

@ -21,9 +21,9 @@
</button>
</mat-form-field>
<div class="flex-space"></div>
<button mat-raised-button color="green" (click)="exportExcel()">
<button mat-raised-button color="green" (click)="Get()" *ngIf="this.size > 10">
<mat-icon>cloud_download</mat-icon>
<span>دریافت خروجی اکسل</span>
<span>بارگیری صفحات بعدی</span>
</button>
</mat-toolbar>
<mat-progress-bar

+ 35
- 15
src/routes/panel/volunteer/table/table.component.ts View File

@ -14,6 +14,8 @@ export class TableComponent implements OnInit {
public data: MatTableDataSource<object> = new MatTableDataSource<object>();
public loading: boolean = false;
public search: string = '';
public size=0;
public page=0;
constructor(private excel: Excel, private rayconnect: Rayconnect, private cdr: ChangeDetectorRef) { }
ngOnInit(): void {
@ -28,7 +30,10 @@ export class TableComponent implements OnInit {
address: 'volunteers/subscribe',
info: {
method: 'SUB',
data: {}
data: {
page:0,
limit:10
}
}
}).then(res => {
if (res['data']['status'] == true)
@ -38,34 +43,49 @@ export class TableComponent implements OnInit {
method: "LIVE",
}, (res => {
let list: object[] = res.data['list'];
let rendered = []
if(res.data['size']){
this.size = res.data['size'];
}
for (let i in list) {
let index: number = this.data.data.findIndex(item => item['_id'] == list[i]['information']['_id']);
if (index >= 0) this.data.data.splice(index, 1);
const user = list[i]['information']
user.step = list[i]['step']
user.options = true
user.uid = list[i]['uid']
this.addNewUser(list[i]['information']);
rendered.push(user)
}
if(rendered.length > 0){
this.data.connect().next(rendered)
}
this.data.data = this.data.data;
this.cdr.markForCheck();
}));
})
}
addNewUser(data: object) {
this.data.data.unshift(data);
this.cdr.detectChanges();
}
exportExcel() {
let data = Array.from(this.data.data);
data = data.map(item => {
delete item['_id']
delete item['__v']
return item;
})
this.excel.generate(this.columns, data)
Get() {
if(this.size > (this.page+1) * 10){
this.page++;
this.rayconnect.RequestBack({
scope: 'kateb',
uniqueID: 'profile',
TokenID: '*',
address: 'volunteers/subscribe',
info: {
method: 'SUB',
data: {
page:this.page,
limit:10
}
}
})
}
}
}

Loading…
Cancel
Save