92 lines
2.3 KiB
TypeScript
92 lines
2.3 KiB
TypeScript
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
import { Excel } from '../../../../services/excel/excel.service';
|
|
import { Rayconnect } from '../../../../services/rayconnect/rayconnect.service';
|
|
|
|
@Component({
|
|
selector: 'app-table',
|
|
templateUrl: './table.component.html',
|
|
styleUrls: ['./table.component.scss']
|
|
})
|
|
export class TableComponent implements OnInit {
|
|
|
|
public columns: string[] = ['firstname', 'lastname', 'fathername', 'nationalcode', 'step', 'options'];
|
|
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 {
|
|
this.subscribe();
|
|
}
|
|
|
|
subscribe() {
|
|
this.rayconnect.RequestBack({
|
|
scope: 'kateb',
|
|
uniqueID: 'profile',
|
|
TokenID: '*',
|
|
address: 'volunteers/subscribe',
|
|
info: {
|
|
method: 'SUB',
|
|
data: {
|
|
page:0,
|
|
limit:10
|
|
}
|
|
}
|
|
}).then(res => {
|
|
if (res['data']['status'] == true)
|
|
this.rayconnect.Query({
|
|
scope: "kateb",
|
|
address: "volunteers/live",
|
|
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) {
|
|
|
|
const user = list[i]['information']
|
|
user.step = list[i]['step']
|
|
user.options = true
|
|
user.uid = list[i]['uid']
|
|
|
|
rendered.push(user)
|
|
|
|
|
|
}
|
|
|
|
if(rendered.length > 0){
|
|
this.data.connect().next(rendered)
|
|
}
|
|
}));
|
|
})
|
|
}
|
|
|
|
addNewUser(data: object) {
|
|
this.data.data.unshift(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
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|