Commit 943801a4 by sawit

Permission Management

parent ec4c480a
......@@ -45,9 +45,9 @@
</th>
<th scope="col" class="text-start">{{"Employee" | translate}}</th>
<th scope="col" class="text-start">{{"Position" | translate}}</th>
<th scope="col" class="text-start">{{"Bu1" | translate}}</th>
<th scope="col" class="text-start">{{"Bu2" | translate}}</th>
<th scope="col" class="text-start">{{"Bu3" | translate}}</th>
<th scope="col" class="text-start">{{"Bu4" | translate}}</th>
<!-- <th scope="col" class="text-start">{{"Bu2" | translate}}</th> -->
<!-- <th scope="col" class="text-start">{{"Bu3" | translate}}</th> -->
<!-- <th scope="col" class="text-start">{{"Update Date" | translate}}</th> -->
<th scope="col" class="text-start">{{ 'Action' | translate}}</th>
<th scope="col" class="text-start"></th>
......@@ -64,30 +64,33 @@
<td>
<div class="flex items-center">
<span class="avatar avatar-sm p-1 me-1 bg-light !rounded-full">
<img [src]="item.getPicture()" alt="" id="profile-img">
<img [src]="getPictureSrc(item.picture)" alt="" id="profile-img">
</span>
<div class="ms-2">
<p class="font-semibold mb-0 flex items-center text-primary">
<a routerLink="/company/home/{{item.employeeId}}" routerLinkActive="active">
{{item.fname}}
{{item.fname}} {{item.lname}}
</a>
</p>
<p class="text-xs text-default-500 mb-0">{{item.employeeId}}</p>
</div>
</div>
</td>
<td>
<div>
<span class="block mb-1">
{{item.email}}
<!-- {{item.bu1}} {{item.thLastnameContact}} -->
<span class="block mb-1">{{item.position?.tdesc || '-'}}
</span>
</div>
</td>
<td>
<span class="badge bg-{{ item.status == 1 ? 'primary' : 'warning'}} text-white">
{{item.getStatus()}}
</span>
<span>{{item.bu4?.tdesc || '-'}}</span>
</td>
<!-- <td>
<span>{{item.bu2?.tdesc || '-'}}</span>
</td>
<td>
<span>{{item.bu3?.tdesc || '-'}}</span>
</td> -->
<!-- <td>
<span class="badge bg-info/10 text-primary">
<i class="bi bi-clock me-1"></i>
......@@ -100,10 +103,6 @@
class="ti-btn ti-btn-wave !gap-0 !m-0 bg-info/10 text-info hover:bg-info hover:text-white hover:border-info">
<i class="ri-pencil-line"></i>
</a>
<!-- <a aria-label="anchor" href="javascript:void(0);" (click)="delete(item)"
class="ti-btn ti-btn-wave product-btn !gap-0 !m-0 bg-danger/10 text-danger hover:bg-danger hover:text-white hover:border-danger">
<i class="ri-delete-bin-line"></i>
</a> -->
</div>
</td>
</tr>
......@@ -176,7 +175,7 @@
<div class="xl:col-span-12 col-span-12">
<div class="mb-0 text-center">
<span class="avatar avatar-xxl avatar-rounded">
<img [src]="selectModel.getPicture()" alt="" id="profile-img">
<img [src]="getPictureSrc(selectModel.picture)" alt="" id="profile-img">
<span class="badge rounded-full bg-primary avatar-badge">
<input (click)="triggerFileInput()" ng2FileSelect [uploader]="uploaderProfile" type="file"
name="photo" class="absolute w-full h-full opacity-[0]" id="profile-change"
......@@ -214,19 +213,12 @@
<div class="xl:col-span-12 col-span-12">
<label for="email" class="form-label">{{'Email' | translate}}</label>
<input type="email" class="form-control" id="emailAddress" placeholder="Email Addresss"
[(ngModel)]="selectModel.email" (input)="filterEngInput($event)">
<div class="text-danger" *ngIf="!selectModel.email">
<label for="employeeId" class="form-label">{{'รหัสพนักงาน' | translate}}</label>
<input type="text" class="form-control" id="employeeIdInput" placeholder=""
[(ngModel)]="selectModel.employeeId" (input)="filterEngInput($event)">
<div class="text-danger" *ngIf="!selectModel.employeeId">
{{ 'Please fill in information' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && (!selectModel.email.includes('@'))">
{{ 'Invalid email format @' | translate }}
</div>
<div class="text-danger"
*ngIf="selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')">
{{ 'Invalid email format .' | translate }}
</div>
</div>
<div class="xl:col-span-6 col-span-12" *ngIf="action !== 'edit'">
......@@ -248,39 +240,6 @@
</div>
</div>
<!-- <div class="xl:col-span-12 col-span-12">
<label for="lname" class="form-label">{{'ข้อมูลบริษัท' | translate}}</label>
<textarea class="form-control" id="lname" placeholder="" [(ngModel)]="selectModel.lname">
</textarea>
<app-rendered-html class="small-html" [htmlContent]="selectModel.lname" *ngIf="action === 'edit'">
</app-rendered-html>
<div class="text-danger" *ngIf="!selectModel.lname">
{{'Please fill in information' | translate}}
</div>
</div> -->
<!-- <div class="xl:col-span-12 col-span-12">
<label for="position" class="form-label">{{'ที่อยู่' | translate}}</label>
<textarea class="form-control" id="position" placeholder="" [(ngModel)]="selectModel.position">
</textarea>
<app-rendered-html class="small-html" [htmlContent]="selectModel.position" *ngIf="action === 'edit'">
</app-rendered-html>
</div> -->
<!-- <div class="xl:col-span-6 col-span-12">
<label for="bu1" class="form-label">{{'ชื่อเจ้าของ' | translate}}</label>
<input type="text" class="form-control" id="bu1" placeholder=""
[(ngModel)]="selectModel.bu1">
</div> -->
<!-- <div class="xl:col-span-6 col-span-12">
<label for="thLastnameContact" class="form-label">{{'นามสกุลเจ้าของ' | translate}}</label>
<input type="text" class="form-control" id="thLastnameContact" placeholder=""
[(ngModel)]="selectModel.thLastnameContact">
</div> -->
<!-- <div class="xl:col-span-12 col-span-12">
<label for="phoneContact" class="form-label">{{'เบอร์ติดต่อ' | translate}}</label>
<input type="text" class="form-control" id="phoneContact" placeholder=""
[(ngModel)]="selectModel.phoneContact">
</div> -->
<div class="xl:col-span-12 col-span-12">
<label class="form-label">{{'Status' | translate}}</label>
<ng-select name="statusSelect" id="statusSelect" placeholder="" [(ngModel)]="selectModel.status">
......@@ -312,9 +271,6 @@
<div class="text-danger" *ngIf="!newPassword">
{{ 'Please fill in information' | translate }}
</div>
<!-- <div class="text-danger text-xs mt-1" *ngIf="newPassword && newPassword.length < 8">
{{ 'Password must be at least 8 characters' | translate }}
</div> -->
</div>
<div class="xl:col-span-6 col-span-12">
......@@ -343,7 +299,7 @@
{{'Cancel' | translate}}
</button>
<button *ngIf="action === 'add'" type="button" (click)="save()"
<!-- <button *ngIf="action === 'add'" type="button" (click)="save()"
class="ti-btn bg-primary text-white !font-medium" [class.ti-btn-disabled]="!selectModel.fname||
!selectModel.engName ||
!password || !confirmPassword || (confirmPassword !== password) ||
......@@ -352,10 +308,10 @@
!selectModel.engName ||
!password || !confirmPassword || (confirmPassword !== password) ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.'))">
{{'Save' | translate}}</button>
{{'Save' | translate}}</button> -->
<button *ngIf="action === 'edit'" type="button" (click)="save()"
<!-- <button *ngIf="action === 'edit'" type="button" (click)="save()"
class="ti-btn bg-primary text-white !font-medium"
[class.ti-btn-disabled]="!selectModel.fname||
!selectModel.engName ||
......@@ -363,7 +319,7 @@
[disabled]="!selectModel.fname||
!selectModel.engName ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.'))">
{{'Save' | translate}}</button>
{{'Save' | translate}}</button> -->
</div>
</div>
</div>
......
......@@ -95,6 +95,13 @@ export class PermissionEmployeelistComponent implements OnInit {
// this.uploadConfig();
}
getPictureSrc(picture?: string): string {
if (picture && picture.trim() !== '') {
return environment.jbossUrl + "/FileViewer.jsp?uploadfield=memployee.picture&filename=" + picture;
}
return 'assets/images/faces/1.jpg';
}
togglePasswordFields() {
this.showPasswordFields = !this.showPasswordFields;
if (!this.showPasswordFields) {
......@@ -154,17 +161,29 @@ export class PermissionEmployeelistComponent implements OnInit {
// }
getEmployeeList() {
// this.permissionService.getListEmpWorkingObserve(this.pageSize, this.pageIndex).subscribe(
// (response: PermissionModel2[]) => {
// this.itemsList = response; // Directly assign the response
// this.filterList = this.itemsList.slice();
// this.updatePagedItems();
// },
// error: (error) => {
// console.error('error cant get company', error);
// swal("ข้อผิดพลาด", "ไม่สามารถดึงข้อมูลพนักงานได้", "error");
// }
// );
this.permissionService.getAllEmployeesMini().subscribe(
(response: any) => {
let list: PermissionModel2[] = [];
if (Array.isArray(response)) {
list = response as PermissionModel2[];
} else if (Array.isArray(response?.content)) {
list = response.content as PermissionModel2[];
} else if (Array.isArray(response?.data)) {
list = response.data as PermissionModel2[];
} else if (Array.isArray(response?.items)) {
list = response.items as PermissionModel2[];
}
this.itemsList = list || [];
this.filterList = this.itemsList.slice();
this.updatePagedItems();
console.log('Loaded employees:', this.itemsList.length);
},
(error) => {
console.error('error cant get employee working list', error);
swal("ข้อผิดพลาด", "ไม่สามารถดึงข้อมูลพนักงานได้", "error");
}
);
}
ngOnInit(): void {
......
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-myjob',
standalone: true,
imports: [RouterOutlet],
template: `
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">Permission Management</h4>
</div>
<div class="card-body">
<router-outlet></router-outlet>
</div>
</div>
</div>
</div>
</div>
`,
styles: [`
.card {
margin: 20px 0;
}
.card-header {
background-color: #f8f9fa;
border-bottom: 1px solid #dee2e6;
}
`]
})
export class PermissionManagementComponent {
constructor() { }
}
......@@ -4,7 +4,6 @@ import { RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { PERMISSION_ROUTES } from './permission-management.routes';
import { PermissionService } from './permission.service';
@NgModule({
declarations: [],
......@@ -13,8 +12,6 @@ import { PermissionService } from './permission.service';
HttpClientModule,
RouterModule.forChild(PERMISSION_ROUTES),
],
providers: [
PermissionService
]
providers: []
})
export class PermissionManagementModule { }
\ No newline at end of file
export class PermissionManagementModule { }
import { Routes } from '@angular/router';
import { PermissionManagementComponent } from './permission-management.component';
import { PermissionEmployeelistComponent } from './permission-employeelist/permission-employeelist.component';
export const PERMISSION_ROUTES: Routes = [
{
path: '',
component: PermissionEmployeelistComponent,
component: PermissionManagementComponent,
children: [
{
path: 'permission-employeelist',
......
......@@ -5,7 +5,6 @@ import { Observable, zip } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { DatePipe } from '@angular/common';
import { map, tap } from 'rxjs/operators';
import {PermissionModel} from './../../models/permission/permission.model';
......@@ -15,25 +14,20 @@ import {PermissionModel} from './../../models/permission/permission.model';
})
export class PermissionService {
lang: string = "";
urlApiplus: string = "https://hrplus.myhr.co.th/plus";
private readonly baseUrl: string = environment.url; // portal api base
private readonly hrplusUrl: string = 'https://hrplus.myhr.co.th/plus';
private BASE_PATH: string = this.urlApiplus + '/dashboard';
private uprofile: Observable<PermissionModel> | undefined;
urlApi = this.urlApiplus
private readonly employeePath = this.hrplusUrl + '/employee';
constructor(
private http: HttpClient,
private router: Router,
private translateService: TranslateService,
private datePipe: DatePipe,
) { }
getListEmpWorkingObserve(sizePage: number, page: number): Observable<PermissionModel[]> {
return this.http
.get<PermissionModel[]>(
this.urlApi + '/employee/workings/mini?page=' + page + '&size=' + sizePage
)
getAllEmployeesMini(): Observable<PermissionModel> {
const url = `${this.employeePath}/workings/mini?page=0&size=500`;
return this.http.get<PermissionModel>(url);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment