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.
 
 
 
 
 

104 lines
2.0 KiB

import { Component, OnInit } from '@angular/core';
import { Rayconnect } from '../../../../services/rayconnect/rayconnect.service';
import { Item, items } from '../../../../database/user.permission';
import { MatTableDataSource } from '@angular/material/table';
@Component({
selector: 'app-table',
templateUrl: './table.component.html',
styleUrls: ['./table.component.scss']
})
export class TableComponent implements OnInit {
public columns: string[] = ['fullname', 'username', 'permission', 'cards', 'options'];
public data: MatTableDataSource<object> = new MatTableDataSource<object>();
public search: string = ''; // search filter
public permissions: Item[] = items;
public loading: boolean = false; // is loading and fetching data or doing process
constructor(private rayconnect: Rayconnect) { }
ngOnInit(): void {
this.data.data = []
this.getUsers()
}
searching() {
this.getUsers(this.search)
}
getUsers(content = null) {
let query
if (content) {
query = {
sync: true,
index: 0,
limit: 15,
search: content
}
} else {
query = {
sync: true,
index: 0,
limit: 5,
search: content
}
}
this.rayconnect.RequestBack(
{
uniqueID: "profile",
TokenID: "*",
scope: 'profile',
address: 'profile/user/manage/list/get',
info: {
method: 'get',
data: query
}
}
).then((data: any) => {
this.data.connect().next([])
const users = data.data
const dataList = []
users.list.forEach(element => {
dataList.push({
id: element._id,
firstname: element.name,
lastname: element.family,
username: element.uid,
permission: 'none',
cards: element.cards
})
});
this.data.connect().next(dataList)
})
}
getPermission(value: string) {
return this.permissions.find(item => item.value == value).title;
}
}