2025-12-06 11:09:06 +03:30
|
|
|
import { CatalogRoleTagComponent } from '@/shared/catalog/roles';
|
2025-12-04 23:34:00 +03:30
|
|
|
import {
|
|
|
|
|
IColumn,
|
|
|
|
|
PageDataListComponent,
|
|
|
|
|
} from '@/shared/components/pageDataList/page-data-list.component';
|
2025-12-06 11:09:06 +03:30
|
|
|
import { Component, signal, TemplateRef, ViewChild } from '@angular/core';
|
2025-12-04 23:34:00 +03:30
|
|
|
import { UserFormComponent } from '../components/form.component';
|
|
|
|
|
import { IUserResponse } from '../models';
|
|
|
|
|
import { UsersService } from '../services/main.service';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-users',
|
|
|
|
|
templateUrl: './list.component.html',
|
2025-12-06 11:09:06 +03:30
|
|
|
imports: [PageDataListComponent, UserFormComponent, CatalogRoleTagComponent],
|
2025-12-04 23:34:00 +03:30
|
|
|
})
|
|
|
|
|
export class UsersComponent {
|
|
|
|
|
constructor(private userService: UsersService) {
|
|
|
|
|
this.getData();
|
|
|
|
|
}
|
2025-12-06 11:09:06 +03:30
|
|
|
@ViewChild('role', { static: true }) roleTpl!: TemplateRef<any>;
|
2025-12-04 23:34:00 +03:30
|
|
|
|
|
|
|
|
columns = [
|
|
|
|
|
{ field: 'id', header: 'شناسه' },
|
|
|
|
|
{ field: 'firstName', header: 'نام' },
|
|
|
|
|
{ field: 'lastName', header: 'نام خانوادگی' },
|
|
|
|
|
{ field: 'mobileNumber', header: 'شماره موبایل' },
|
2025-12-06 11:09:06 +03:30
|
|
|
// { field: 'role', header: 'نقش', customDataModel: this.roleTpl },
|
|
|
|
|
{
|
|
|
|
|
field: 'role',
|
|
|
|
|
header: 'نقش',
|
|
|
|
|
customDataModel: (item: IUserResponse) => item.role.name ?? '-',
|
|
|
|
|
},
|
2025-12-04 23:34:00 +03:30
|
|
|
] as IColumn[];
|
|
|
|
|
|
|
|
|
|
loading = signal(false);
|
|
|
|
|
items = signal<IUserResponse[]>([]);
|
|
|
|
|
visibleForm = signal(false);
|
|
|
|
|
|
|
|
|
|
refresh() {
|
|
|
|
|
this.getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getData() {
|
|
|
|
|
this.loading.set(true);
|
|
|
|
|
this.userService.getAll().subscribe((res) => {
|
|
|
|
|
this.loading.set(false);
|
2025-12-05 00:01:48 +03:30
|
|
|
this.items.set(res.data);
|
2025-12-04 23:34:00 +03:30
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openAddForm() {
|
|
|
|
|
this.visibleForm.set(true);
|
|
|
|
|
}
|
|
|
|
|
}
|