Project 'angular/myAppraisal' was moved to 'angular/mySkill-x'. Please update any links and bookmarks that may still have the old path.
Commit dcf7a18e by Ooh-Ao

user

parent cac967b5
...@@ -11,12 +11,15 @@ import { TransectionProductManagementComponent } from './transection-product-man ...@@ -11,12 +11,15 @@ import { TransectionProductManagementComponent } from './transection-product-man
import { HistoryProductComponent } from './history-product/history-product.component'; import { HistoryProductComponent } from './history-product/history-product.component';
import { AdminRoutingModule } from './admin.routing'; import { AdminRoutingModule } from './admin.routing';
import { SharedModule } from '../shared/sharedmodule'; import { SharedModule } from '../shared/sharedmodule';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
AdminRoutingModule, AdminRoutingModule,
SharedModule SharedModule,
FormsModule,
ReactiveFormsModule,
], ],
declarations: [AdminComponent, UserManagementComponent, ProjectManagementComponent, ProductManagementComponent, ProjectEmployeeManagementComponent, ProjectProductManagementComponent, HomeAdminComponent, TransectionProductManagementComponent, HistoryProductComponent] declarations: [AdminComponent, UserManagementComponent, ProjectManagementComponent, ProductManagementComponent, ProjectEmployeeManagementComponent, ProjectProductManagementComponent, HomeAdminComponent, TransectionProductManagementComponent, HistoryProductComponent]
}) })
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<a class="ti-dropdown-item" href="javascript:void(0)">All</a> <a class="ti-dropdown-item" href="javascript:void(0)">All</a>
</div> </div>
</div> --> </div> -->
<a href="javascript:void(0);" <a (click)="newEmp()"
class="team-add-btn m-0 ti-btn ti-btn-secondary mx-1 whitespace-nowrap mt-1"> class="team-add-btn m-0 ti-btn ti-btn-secondary mx-1 whitespace-nowrap mt-1">
<i class="ti ti-circle-plus leading-none"> </i>Add New Contact <i class="ti ti-circle-plus leading-none"> </i>Add New Contact
</a> </a>
...@@ -84,10 +84,10 @@ ...@@ -84,10 +84,10 @@
<i class="ri ri-more-2-line text-lg leading-none"></i> <i class="ri ri-more-2-line text-lg leading-none"></i>
</a> </a>
<div class="hs-dropdown-menu ti-dropdown-menu"> <div class="hs-dropdown-menu ti-dropdown-menu">
<a class="ti-dropdown-item" href="javascript:void(0);"><i <!-- <a class="ti-dropdown-item" href="javascript:void(0);"><i
class="ri-share-line me-2 align-middle"></i>แก้ไข</a> class="ri-share-line me-2 align-middle"></i>แก้ไข</a> -->
<a class="ti-dropdown-item" href="javascript:void(0);"><i <a class="ti-dropdown-item" (click)="deleteUser(item)"><i
class="ri-delete-bin-5-line me-2 align-middle"></i>ลบ</a> class="ri-delete-bin-5-line me-2 align-middle"></i>ลบ</a>
</div> </div>
</div> </div>
...@@ -146,32 +146,44 @@ ...@@ -146,32 +146,44 @@
</div> </div>
</div> </div>
<div class="mt-14 space-y-5"> <div class="mt-14 space-y-5">
<div class="mt-4 text-center"> <div class="mt-5">
<h2 class="text-xl font-semibold">{{selectedUser.first_name+ " "+selectedUser.last_name}}</h2> <div class="space-y-4 text-start">
<p class="text-sm text-gray-500 dark:text-white/70 font-semibold"> <div class="grid sm:grid-cols-12 gap-x-6">
{{selectedUser.position}} <label class="col-span-3 my-auto ti-form-label whitespace-nowrap">ชื่อ:</label>
</p> <input type="text" class="col-span-9 ti-form-input" placeholder="Enter Full Name"
</div> [(ngModel)]="selectedUser.first_name" />
<h5 class="box-title my-3">ข้อมูลการติดต่อ</h5> </div>
<div class="flex space-x-3 rtl:space-x-reverse"> <div class="grid sm:grid-cols-12 gap-x-6">
<i <label class="col-span-3 my-auto ti-form-label whitespace-nowrap">นามสกุล:</label>
class="ri ri-phone-line text-lg leading-none p-3 avatar avatar-sm bg-gray-100 dark:bg-black/20 rounded-sm"></i> <input type="text" class="col-span-9 ti-form-input" placeholder="Enter Full Name"
<div class="my-auto"> [(ngModel)]="selectedUser.last_name" />
<h5 class="text-sm font-semibold">เบอร์ติดต่อ</h5> </div>
<a href="javascript:void(0);" class="text-xs text-gray-500 dark:text-white/70">{{selectedUser.phone}}</a> <div class="grid sm:grid-cols-12 gap-x-6">
</div> <label class="col-span-3 my-auto ti-form-label whitespace-nowrap">อีเมล:</label>
</div> <input type="email" class="col-span-9 ti-form-input" placeholder="Enter Email"
<div class="flex space-x-3 rtl:space-x-reverse"> [(ngModel)]="selectedUser.email" />
<i </div>
class="ri ri-mail-line text-lg leading-none p-3 avatar avatar-sm bg-gray-100 dark:bg-black/20 rounded-sm"></i> <div class="grid sm:grid-cols-12 gap-x-6">
<div class="my-auto"> <label class="col-span-3 my-auto ti-form-label whitespace-nowrap">รหัสผ่าน:</label>
<h5 class="text-sm font-semibold">อีเมล</h5> <input type="password" class="col-span-9 ti-form-input" placeholder="Enter Email"
<a class="text-xs text-gray-500 dark:text-white/70">{{selectedUser.email}}</a> [(ngModel)]="selectedUser.password" />
</div>
<div class="grid sm:grid-cols-12 gap-x-6">
<label class="col-span-3 my-auto ti-form-label whitespace-nowrap">เบอร์:</label>
<input type="number" class="col-span-9 ti-form-input" placeholder="Enter Phone No"
[(ngModel)]="selectedUser.phone" />
</div>
<div class="grid sm:grid-cols-12 gap-x-6">
<label class="col-span-3 my-auto ti-form-label whitespace-nowrap">ตำแหน่ง:</label>
<input type="number" class="col-span-9 ti-form-input" placeholder="Enter Phone No"
[(ngModel)]="selectedUser.position" />
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="box-footer"><button type="button" (click)="selectedUser = undefined" <div class="box-footer"> <button type="button" class="w-full ti-btn ti-btn-primary" (click)="save()">
<i class="ti ti-report"></i>บันทึก</button><button type="button" (click)="selectedUser = undefined"
class="w-full ti-btn font-medium border-gray-200 bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"> class="w-full ti-btn font-medium border-gray-200 bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10">
<i class="ti ti-ban"></i>ปิด <i class="ti ti-ban"></i>ปิด
</button> </button>
......
...@@ -20,6 +20,7 @@ export class UserManagementComponent { ...@@ -20,6 +20,7 @@ export class UserManagementComponent {
getUser() { getUser() {
this.userService.getLists().subscribe(result => { this.userService.getLists().subscribe(result => {
this.memberlist = result this.memberlist = result
this.selectedUser = undefined
}) })
} }
...@@ -29,32 +30,51 @@ export class UserManagementComponent { ...@@ -29,32 +30,51 @@ export class UserManagementComponent {
}) })
} }
saveUser() { save() {
console.log(this.selectedUser)
if (!this.selectedUser?.user_id) {
this.createUser()
} else {
this.updateUser()
}
}
createUser() {
if (this.selectedUser) { if (this.selectedUser) {
this.userService.save(this.selectedUser).subscribe(result => { this.userService.save(this.selectedUser).subscribe(result => {
console.log(result) console.log(result)
this.getUser()
}) })
} }
} }
deleteUser() { updateUser() {
if (this.selectedUser) { if (this.selectedUser) {
this.userService.delete(this.selectedUser).subscribe(result => { this.userService.update(this.selectedUser).subscribe(result => {
console.log(result) console.log(result)
this.getUser()
}) })
} }
} }
updateUser() { deleteUser(item: UserProfileModel) {
this.selectedUser = new UserProfileModel(item)
if (this.selectedUser) { if (this.selectedUser) {
this.userService.update(this.selectedUser).subscribe(result => { this.userService.delete(this.selectedUser).subscribe(result => {
console.log(result) console.log(result)
this.getUser()
}) })
} }
} }
newEmp() {
this.selectedUser = new UserProfileModel()
}
detailEmp(emp: UserProfileModel) { detailEmp(emp: UserProfileModel) {
this.selectedUser = emp this.selectedUser = new UserProfileModel(emp)
} }
......
import { TranslateService } from "@ngx-translate/core"; export class UserProfileModel {
import { BaseModel } from "./base.model"; user_id?: string;
export class UserProfileModel extends BaseModel {
user_id: string;
first_name: string; first_name: string;
last_name: string; last_name: string;
picture: string; picture: string;
phone: string = "-"; phone: string = "-";
position: string = "-"; position: string = "-";
email: string; email: string;
role: string; password: string;
role: string = "employee";
constructor( constructor(
data?: Partial<UserProfileModel>, data?: Partial<UserProfileModel>
translateService?: TranslateService
) { ) {
super(data, translateService);
this.user_id = data?.user_id!; this.user_id = data?.user_id!;
this.first_name = data?.first_name! this.first_name = data?.first_name!
this.last_name = data?.last_name! this.last_name = data?.last_name!
this.picture = data?.picture! this.picture = data?.picture!
this.phone = data?.phone ? data.phone : this.phone this.phone = data?.phone ? data.phone : this.phone
this.email = data?.email! this.email = data?.email!
this.position = data?.position ? data.position : this.position this.position = data?.position ? data.position : this.position
this.role = data?.role! this.password = data?.password!
this.role = data?.role ? data.role : this.role
} }
} }
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