You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

163 lines
3.4 KiB

import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { type } from 'os';
import { Excel } from '../../../../services/excel/excel.service';
import { Rayconnect } from '../../../../services/rayconnect/rayconnect.service';
import * as moment from 'jalali-moment'
@Component({
selector: 'app-table',
templateUrl: './table.component.html',
styleUrls: ['./table.component.scss']
})
export class TableComponent implements OnInit {
public columns: string[] = ['firstname', 'lastname', 'fathername', 'major', 'nationalcode', 'militaryserviceStatus', 'step', 'done', 'options'];
public data: MatTableDataSource<object> = new MatTableDataSource<object>();
public loading: boolean = false;
public search: string = '';
public size = 0;
public searchBy = "nationalcode";
public page = 0;
public uuid = "";
public filters = {
university: ""
}
limit: number = 10;
constructor(private excel: Excel, private rayconnect: Rayconnect, private cdr: ChangeDetectorRef) { }
ngOnInit(): void {
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']
if (user.done) {
console.log(user.done)
user.done = moment(user.done).format("jYYYY/jMM/jDD")
} else {
user.done = null
}
user.major = list[i]["educationalInformation"]["major"]
rendered.push(user)
}
this.data.connect().next(rendered)
}));
this.subscribe();
this.UUID()
}
async UUID() {
const data = await this.rayconnect.RequestBack({
scope: 'kateb',
uniqueID: 'profile',
TokenID: '*',
address: "volunteers/admin/expert/uuid",
info: {
method: "GET",
data: {
page: (this.page),
limit: this.limit
}
}
})
if (data['data']['uuid'])
this.uuid = data['data']['uuid']
}
subscribe() {
this.rayconnect.RequestBack({
scope: 'kateb',
uniqueID: 'profile',
TokenID: '*',
address: 'volunteers/subscribe',
info: {
method: 'SUB',
data: {
page: (this.page),
limit: this.limit
}
}
}).then(res => {
if (res['data']['status'] == true) { }
})
}
addNewUser(data: object) {
this.data.data.unshift(data);
}
Get(e, x = "no") {
console.log(e)
let Query = {}
if (e.pageIndex != undefined) {
this.page = e.pageIndex
this.limit = e.pageSize
}
if (x == 'search') {
this.page = 0;
this.limit = 10;
Query['search'] = this.search
Query['searchBy'] = this.searchBy
}
Query = {
page: (this.page),
limit: this.limit,
search: this.search,
searchBy: this.searchBy
}
console.log(Query)
this.rayconnect.RequestBack({
scope: 'kateb',
uniqueID: 'profile',
TokenID: '*',
address: 'volunteers/subscribe',
info: {
method: 'SUB',
data: Query
}
})
}
}