230 lines
5.0 KiB
TypeScript
230 lines
5.0 KiB
TypeScript
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[] = ['position', 'uid', 'firstname', 'lastname', 'fathername', 'major', 'grade', 'nationalcode', 'entrynumber', 'waiting', 'step', 'done', 'options'];
|
|
public data: MatTableDataSource<object> = new MatTableDataSource<object>();
|
|
public loading: boolean = false;
|
|
public search: string = '';
|
|
public size = 0;
|
|
public searchBy = "nationalcode";
|
|
public grade = "کاردانی";
|
|
public page = 0;
|
|
public uuid = "";
|
|
public namespace = []
|
|
|
|
public sort = 'nationalcode'
|
|
public sortDirection = 'asc'
|
|
|
|
public uid = ""
|
|
univeristygroups: any[] = [
|
|
|
|
{
|
|
name: 'مرکزی',
|
|
value: "fani.markazi",
|
|
universities: [
|
|
{ value: 'fani.markazi.arak.athar', viewValue: 'اطهر' },
|
|
|
|
{ value: 'fani.markazi.arak.amirkabir', viewValue: 'امیر کبیر' },
|
|
{ value: 'fani.markazi.khomein.pkhomein', viewValue: 'دکتر حسابی خمین' },
|
|
{ value: 'fani.markazi.saveh.psaveh', viewValue: 'مرکز پسران ساوه' }
|
|
|
|
]
|
|
}
|
|
];
|
|
public filters = {
|
|
university: ""
|
|
}
|
|
limit: number = 10;
|
|
constructor(private excel: Excel, private rayconnect: Rayconnect, private cdr: ChangeDetectorRef) { }
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
|
console.log(this.rayconnect.user)
|
|
this.uid = this.rayconnect.user.uid
|
|
|
|
this.rayconnect.Query({
|
|
scope: "kateb",
|
|
address: "volunteers/live",
|
|
method: "LIVE",
|
|
}, (res => {
|
|
let list: object[] = res.data['list'];
|
|
let rendered = []
|
|
if (res.data['size'] != undefined) {
|
|
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']
|
|
user.waiting = list[i]['waiting']
|
|
user.done = list[i]['done']
|
|
if (user.done) {
|
|
user.done = moment(user.done).format("jYYYY/jMM/jDD")
|
|
|
|
}
|
|
user.major = list[i]["educationalInformation"]["major"]
|
|
user.grade = list[i]["educationalInformation"]["grade"]
|
|
|
|
|
|
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.Get({ vol: 1 })
|
|
/*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 = {
|
|
page: (this.page),
|
|
limit: this.limit,
|
|
search: this.search,
|
|
searchBy: this.searchBy,
|
|
grade: this.grade
|
|
}
|
|
|
|
if ((x == 'sort') && (e.direction != '')) {
|
|
|
|
this.sort = e.active;
|
|
|
|
this.sortDirection = e.direction
|
|
}
|
|
|
|
switch (this.sort) {
|
|
case 'name':
|
|
Query['sort'] = "information.firstname"
|
|
break;
|
|
case 'nationalcode':
|
|
Query['sort'] = "information.nationalcode"
|
|
break;
|
|
case 'lastname':
|
|
Query['sort'] = "information.lastname"
|
|
break;
|
|
case 'fathername':
|
|
Query['sort'] = "information.fathername"
|
|
case 'major':
|
|
Query['sort'] = "educationalInformation.major"
|
|
break;
|
|
case 'grade':
|
|
Query['sort'] = "educationalInformation.grade"
|
|
break;
|
|
case 'step':
|
|
Query['sort'] = "step"
|
|
break;
|
|
case 'done':
|
|
Query['sort'] = "done"
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
Query['sortDirection'] = this.sortDirection
|
|
|
|
|
|
|
|
if(this.uid == 'tvu'){
|
|
Query['namespace'] = this.namespace
|
|
|
|
}
|
|
|
|
|
|
|
|
this.rayconnect.RequestBack({
|
|
scope: 'kateb',
|
|
uniqueID: 'profile',
|
|
TokenID: '*',
|
|
address: 'volunteers/subscribe',
|
|
info: {
|
|
method: 'SUB',
|
|
data: Query
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|