Commit 27f02f55 by Ooh-Ao

portal

parent 8b2e4a55
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MockDataService {
constructor() { }
getKpiData(kpiName: string) {
const kpiData: { [key: string]: { value: number, trend: 'up' | 'down' | 'flat', percentage: number } } = {
'New Hires': { value: 12, trend: 'up', percentage: 15 },
'Turnover Rate': { value: 4, trend: 'down', percentage: 10 },
'Employee Satisfaction': { value: 4.5, trend: 'up', percentage: 5 },
'Projects Completed': { value: 25, trend: 'up', percentage: 20 }
};
return kpiData[kpiName] || { value: 0, trend: 'flat', percentage: 0 };
}
getChartData() {
return {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
series: [
{
name: 'Hiring',
data: [5, 8, 12, 10, 15, 18]
},
{
name: 'Resignations',
data: [2, 3, 5, 4, 6, 5]
}
]
};
}
getWelcomeMessage(userName: string = 'Admin') {
return `Welcome back, ${userName}!`;
}
getQuickLinks() {
return [
{ name: 'Company Portal', url: '#' },
{ name: 'HR Handbook', url: '#' },
{ name: 'Submit IT Ticket', url: '#' },
{ name: 'View Paystubs', url: '#' }
];
}
}
:host {
display: block;
}
.map-container{
width: 100% !important
}
<app-page-header [title]="'ข้อมูลบริษัท'" [activeTitle]="'จัดการบริษัท'" [title1]="'ข้อมูลบริษัท'"></app-page-header>
<!-- Start::row-1 -->
<div class="grid grid-cols-12 gap-6">
<div class="xl:col-span-8 col-span-12">
<div class="box custom-box">
<div class="box-header justify-between flex">
<div class="box-title">
ข้อมูลบริษัท
</div>
<div>
</div>
</div>
<div class="box-body">
<div class="sm:p-4 p-0">
<h6 class="font-semibold mb-4 text-[1rem]">
รูปภาพ :
</h6>
<div class="mb-6 sm:flex items-center">
<div class="mb-0 me-[3rem]">
<span class="avatar avatar-xxl avatar-rounded">
<img [src]="companyModel.getPicture()" alt="" id="profile-img">
<a aria-label="anchor" href="javascript:void(0);" class="badge rounded-full bg-primary avatar-badge">
<input ng2FileSelect [uploader]="uploaderProfile" type="file" name="photo"
class="absolute w-full h-full opacity-0" id="profile-image">
<i class="fe fe-camera !text-[0.65rem]"></i>
</a>
</span>
</div>
<!-- <div class="inline-flex">
<button type="button" class="ti-btn bg-primary text-white !rounded-e-none !font-medium">แก้ไข</button>
<button type="button" class="ti-btn ti-btn-light !font-medium !rounded-s-none">ลบ</button>
</div> -->
</div>
<div class="sm:grid grid-cols-12 gap-6 mb-6">
<div class="xl:col-span-6 col-span-12">
<label for="first-name" class="form-label">ชื่อบริษัท</label>
<input type="text" class="form-control w-full !rounded-md" id="first-name"
[(ngModel)]="companyModel.companyName" placeholder="ชื่อบริษัท">
</div>
<div class="xl:col-span-6 col-span-12">
<label for="first-name" class="form-label">รหัสบริษัท</label>
<input type="text" class="form-control w-full !rounded-md" id="first-name" placeholder="CODE"
[(ngModel)]="companyModel.companyCode">
</div>
<div class="xl:col-span-6 col-span-12">
<label for="bio" class="form-label">เกี่ยวกับบริษัท :</label>
<textarea class="form-control w-full !rounded-md dark:!text-defaulttextcolor/70" id="bio" rows="5"
[(ngModel)]="companyModel.companyInfo"></textarea>
</div>
<div class="xl:col-span-6 col-span-12">
<label for="bio" class="form-label">ที่อยู่ :</label>
<textarea class="form-control w-full !rounded-md dark:!text-defaulttextcolor/70" id="bio" rows="5"
[(ngModel)]="companyModel.address"></textarea>
</div>
</div>
<h6 class="font-semibold mb-4 text-[1rem]">
ข้อมูลเจ้าของบริษัท :
</h6>
<div class="sm:grid grid-cols-12 gap-6 mb-6">
<div class="xl:col-span-6 col-span-12">
<label for="email-address" class="form-label">ชื่อ-สกุล :</label>
<input type="text" class="form-control w-full !rounded-md" id="email-address"
[(ngModel)]="companyModel.ownerName" placeholder="ชื่อ-สกุล">
</div>
<div class="xl:col-span-6 col-span-12">
<label for="Contact-Details" class="form-label">เบอร์ติดต่อ :</label>
<input type="text" class="form-control w-full !rounded-md" id="Contact-Details"
[(ngModel)]="companyModel.contact" placeholder="การติดต่อ">
</div>
</div>
</div>
</div>
<div class="box-footer">
<div class="ltr:float-right rtl:float-left">
<button type="button" class="ti-btn bg-primary text-white m-1" (click)="save()">
บันทึกการเปลี่ยนแปลง
</button>
<button type="button" class="ti-btn ti-btn-ghost-secondary ti-btn-wave" (click)="reset()">ยกเลิก</button>
</div>
</div>
</div>
</div>
<div class="xl:col-span-4 col-span-12">
<div class="box custom-box">
<div class="box-header justify-between">
<div class="box-title">แผนที่บริษัท</div>
</div>
<div class="box-body">
<div class="grid grid-cols-12 sm:gap-6">
<div class="xl:col-span-6 lg:col-span-6 md:col-span-6 sm:col-span-6 col-span-6">
<label for="input-label" class="form-label">{{"ละติจูด" | translate}}</label>
<input type="text" class="form-control" id="input" [(ngModel)]="companyModel.latitude"
(ngModelChange)="changeMarker()">
</div>
<div class="xl:col-span-6 lg:col-span-6 md:col-span-6 sm:col-span-6 col-span-6">
<label for="input-label" class="form-label">{{"ลองจิจูด" | translate}}</label>
<input type="text" class="form-control" id="input" [(ngModel)]="companyModel.longitude"
(ngModelChange)="changeMarker()">
</div>
<div class="xl:col-span-12 col-span-12">
<div class="xl:col-span-12 col-span-12">
<input id="searchBox" #searchBox type="text" placeholder="ค้นหาสถานที่..."
class="form-control w-full p-2 border rounded mb-3">
</div>
<google-map class="xl:col-span-12 col-span-12" height="400px"
[center]="{ lat: companyModel.latitude, lng: companyModel.longitude }" [zoom]="12"
(mapClick)="addMarker($event,mapMarker)">
<map-marker #mapMarker="mapMarker"
[position]="{ lat: companyModel.latitude, lng: companyModel.longitude }" [options]="markerOptions" />
</google-map>
</div>
</div>
</div>
</div>
</div>
</div>
<!--End::row-1 -->
import { CommonModule } from "@angular/common";
import { ChangeDetectionStrategy, Component, ElementRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { SharedModule } from "../../../shared/shared.module";
import { GoogleMapsModule, MapInfoWindow, MapMarker } from '@angular/google-maps';
import { NgSelectModule } from "@ng-select/ng-select";
import { ActivatedRoute, Router } from "@angular/router";
import { TokenService } from "../../../shared/services/token.service";
import { CompanyService } from "../../services/company.service";
import { CompanyModel } from "../../models/company.model";
import { FormsModule } from "@angular/forms";
import { FileUploadModule } from 'ng2-file-upload';
import { FileItem, FileUploader, ParsedResponseHeaders } from "ng2-file-upload";
import { TranslateModule } from '@ngx-translate/core';
import swal from 'sweetalert';
import { environment } from "../../../../environments/environment";
@Component({
selector: 'app-company-info',
standalone: true,
imports: [SharedModule, NgSelectModule, CommonModule, FormsModule, FileUploadModule, TranslateModule, NgSelectModule, GoogleMapsModule, MapMarker],
templateUrl: './company-info.component.html',
styleUrl: './company-info.component.css',
encapsulation: ViewEncapsulation.None
})
export class CompanyInfoComponent {
@ViewChild(MapInfoWindow) infoWindow: MapInfoWindow | undefined;
center: google.maps.LatLngLiteral = { lat: 13.7563, lng: 100.5018 };
zoom = 4;
markerOptions: google.maps.MarkerOptions = { draggable: false };
markerPositions: google.maps.LatLngLiteral = { lat: 13.7563, lng: 100.5018 };
companyId = ""
companyModel: CompanyModel = new CompanyModel()
uploaderProfile: FileUploader | undefined;
uploadErrorMsg: string = "";
@ViewChild('searchBox', { static: false }) searchBoxElement!: ElementRef;
constructor(private router: Router, private route: ActivatedRoute, private comService: CompanyService, private tokenService: TokenService) {
this.companyId = this.tokenService.getSelectCompany().companyId;
this.getCompanyInfo()
this.uploadConfig()
}
async ngAfterViewInit() {
// await this.loadGoogleMapsAPI();
this.initAutocomplete();
}
initAutocomplete() {
if (!this.searchBoxElement || !this.searchBoxElement.nativeElement) {
console.error("❌ SearchBox element not found!");
return;
}
const input = this.searchBoxElement.nativeElement;
const searchBox = new google.maps.places.SearchBox(input);
searchBox.addListener('places_changed', () => {
const places = searchBox.getPlaces();
if (!places || places.length === 0) return;
const place = places[0];
if (!place.geometry || !place.geometry.location) return;
this.companyModel.latitude = place.geometry.location.lat()
this.companyModel.longitude = place.geometry.location.lng()
// this.center = {
// lat: place.geometry.location.lat(),
// lng: place.geometry.location.lng(),
// };
// this.markerPositions = this.center;
// console.log(`📍 New Location: ${this.center.lat}, ${this.center.lng}`);
});
}
uploadConfig() {
this.uploaderProfile = new FileUploader({
url: environment.baseUrl + "/api/upload-image",
isHTML5: true,
authToken: this.tokenService.getToken()!,
});
this.uploaderProfile.onAfterAddingFile = (fileItem: FileItem) => {
fileItem.withCredentials = false;
this.uploadErrorMsg = "";
while (this.uploaderProfile!.queue.length > 1) {
this.uploaderProfile!.queue[0].remove();
}
if (fileItem.file.size > 5000000) {
this.uploadErrorMsg = "maximum file size 5mb.";
swal("Opp!!", "ไม่สามารถอัพโหลดได้", "info");
fileItem.isCancel = true;
return;
}
if (fileItem.file.type!.indexOf("image") === -1) {
this.uploadErrorMsg = "please upload image only.";
swal("Opp!!", "ไม่สามารถอัพโหลดได้", "info");
fileItem.isCancel = true;
return;
}
fileItem.upload();
};
this.uploaderProfile.onCompleteItem = (
item: FileItem,
response: string,
status: number,
headers: ParsedResponseHeaders
) => {
if (item.isSuccess) {
const res = JSON.parse(response);
console.log("res", res);
this.companyModel.picture = res.filename
swal(res.message, "บันทึกสำเร็จ", "success");
} else {
this.uploadErrorMsg = "cannot upload file.";
swal("Opp!!", "ไม่สามารถอัพโหลดได้", "info");
}
};
}
changeMarker() {
this.markerPositions = { lat: this.companyModel.latitude, lng: this.companyModel.longitude }
}
addMarker(event: google.maps.MapMouseEvent, marker: MapMarker) {
console.log(event)
console.log(marker)
this.companyModel.latitude = event.latLng!.toJSON().lat
this.companyModel.longitude = event.latLng!.toJSON().lng
this.markerPositions = { lat: event.latLng!.toJSON().lat, lng: event.latLng!.toJSON().lng }
if (this.infoWindow && marker.title) {
this.infoWindow.open(marker);
}
}
getCompanyInfo() {
this.comService.getById(this.companyId).subscribe(result => {
;
this.companyModel = result
this.tokenService.saveSelectCompany(result);
console.log("companyModel", this.companyModel)
})
}
reset() {
this.getCompanyInfo()
}
save() {
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
this.comService.update(this.companyModel).subscribe(result => {
swal("Update Success!!", "บันทึกข้อมูลสมาชิก", "success");
this.getCompanyInfo()
})
});
}
}
:host {
display: block;
}
.map-container{
width: 100% !important
}
import { CommonModule } from "@angular/common";
import { ChangeDetectionStrategy, Component, ElementRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { SharedModule } from "../../../shared/shared.module";
import { NgSelectModule } from "@ng-select/ng-select";
import { CompanyLocationModel } from "../../models/company-location.model";
import { CompanyLocationService } from "../../services/company-location.service";
import { TokenService } from "../../../shared/services/token.service";
import swal from 'sweetalert';
import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { FormsModule } from "@angular/forms";
import { RouterModule } from "@angular/router";
import { GoogleMap, GoogleMapsModule, MapInfoWindow, MapMarker } from "@angular/google-maps";
@Component({
selector: 'app-company-location',
standalone: true,
imports: [CommonModule,
SharedModule,
TranslateModule,
NgSelectModule,
FormsModule,
GoogleMapsModule, MapMarker
],
templateUrl: './company-location.component.html',
styleUrl: './company-location.component.css',
encapsulation: ViewEncapsulation.None
})
export class CompanyLocationComponent {
@ViewChild('searchBox', { static: false }) searchBoxElement!: ElementRef;
@ViewChild(GoogleMap) map!: GoogleMap;
@ViewChild(MapInfoWindow) infoWindow: MapInfoWindow | undefined;
@ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') public modalDetail?: ElementRef;
action = "new";
allSelected = false;
someSelected = false;
itemsList: CompanyLocationModel[] = []
filterList: CompanyLocationModel[] = []
selectModel: CompanyLocationModel = new CompanyLocationModel()
empList: CompanyLocationModel[] = []
selectedItems = new Map<string, boolean>();
descName = 'engName'
pageIndex = 0;
get searchTerm(): string {
return this._searchTerm;
}
set searchTerm(val: string) {
this.pageIndex = 0;
this.allSelected = false
this._searchTerm = val;
if (val != '') {
this.filterList = this.filter(val);
} else {
this.updatePagedItems()
}
}
center: google.maps.LatLngLiteral = { lat: 13.7563, lng: 100.5018 };
zoom = 5;
radius = 50;
markerOptions: google.maps.MarkerOptions = { draggable: false };
markerPositions: google.maps.LatLngLiteral = { lat: 13.7563, lng: 100.5018 };
autocompleteInput: string = '';
_searchTerm = "";
companyId = ""
adressType: string = 'geocode';
@ViewChild('addresstext') addresstext: any;
constructor(private comLocationService: CompanyLocationService, public translate: TranslateService, private tokenService: TokenService) {
this.companyId = this.tokenService.getSelectCompany().companyId;;
this.getLocation()
}
ngOnInit(): void {}
async ngAfterViewInit() {
// await this.loadGoogleMapsAPI();
this.initAutocomplete();
}
initAutocomplete() {
if (!this.searchBoxElement || !this.searchBoxElement.nativeElement) {
console.error("❌ SearchBox element not found!");
return;
}
const input = this.searchBoxElement.nativeElement;
const searchBox = new google.maps.places.SearchBox(input);
searchBox.addListener('places_changed', () => {
const places = searchBox.getPlaces();
if (!places || places.length === 0) return;
const place = places[0];
if (!place.geometry || !place.geometry.location) return;
this.selectModel.latitude = place.geometry.location.lat()
this.selectModel.longitude = place.geometry.location.lng()
this.selectModel.locationName = place.name!
// this.center = {
// lat: place.geometry.location.lat(),
// lng: place.geometry.location.lng(),
// };
// this.markerPositions = this.center;
// console.log(`📍 New Location: ${this.center.lat}, ${this.center.lng}`);
});
}
getLocation() {
this.comLocationService.getLists(this.companyId).subscribe(result => {
this.itemsList = result
this.updatePagedItems()
})
}
filter(v: string) {
return this.itemsList?.filter(
(x) =>
x.locationId?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.locationName?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.getStatus().toLowerCase().indexOf(v.toLowerCase()) !== -1
);
}
delete(item: CompanyLocationModel) {
swal({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes,Delete it!"],
})
.then((willDelete: any) => {
if (willDelete) {
this.comLocationService.delete(this.companyId, item).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getLocation()
})
}
});
}
new() {
this.action = 'add'
this.selectModel = new CompanyLocationModel()
this.selectModel.latitude = 0.00
this.selectModel.longitude = 0.00
}
view(item: CompanyLocationModel) {
this.action = 'edit'
this.selectModel = new CompanyLocationModel(item)
this.markerPositions = { lat: this.selectModel.latitude, lng: this.selectModel.longitude }
console.log(this.selectModel)
}
save() {
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
if (this.action == 'add') {
this.comLocationService.save(this.companyId, this.selectModel).subscribe(result => {
console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getLocation()
this.childModal?.nativeElement.click()
})
} else if (this.action == 'edit') {
this.comLocationService.update(this.companyId, this.selectModel).subscribe(result => {
console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getLocation()
this.childModal?.nativeElement.click()
})
}
}
});
}
updatePagedItems() {
const startIndex = this.pageIndex * 10;
const endIndex = startIndex + 10;
this.filterList = this.itemsList.slice(startIndex, endIndex);
}
toggleAll(event: any) {
this.allSelected = event.target.checked;
this.selectedItems.clear();
this.itemsList.forEach(item => {
this.selectedItems.set(item.locationId, this.allSelected);
});
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.locationId));
}
onCheckboxChange(locationId: string) {
const isSelected = this.selectedItems.get(locationId) || false;
this.selectedItems.set(locationId, !isSelected);
this.allSelected = this.itemsList.every(item => this.selectedItems.get(item.locationId));
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.locationId));
}
deleteSelect() {
let employeeInfo = '';
this.selectedItems.forEach((isSelected, locationId) => {
if (isSelected) {
const item = this.itemsList.find(item => item.locationId === locationId);
if (item) {
employeeInfo += `${this.translate.instant('ชื่อตำแหน่ง')}: ${item.locationName}\n`;
}
}
});
swal({
title: "Are you sure?",
text: employeeInfo,
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes, Delete it!"],
})
.then((willDelete: any) => {
if (willDelete) {
this.selectedItems.forEach((isSelected, locationId) => {
if (isSelected) {
const item = this.itemsList.find(item => item.locationId === locationId);
if (item) {
this.comLocationService.delete(this.companyId, item).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getLocation();
});
}
}
});
}
});
}
changeMarker() {
this.markerPositions = { lat: this.selectModel.latitude, lng: this.selectModel.longitude }
}
addMarker(event: google.maps.MapMouseEvent, marker: MapMarker) {
console.log(event)
console.log(marker)
this.selectModel.latitude = event.latLng!.toJSON().lat
this.selectModel.longitude = event.latLng!.toJSON().lng
this.markerPositions = { lat: event.latLng!.toJSON().lat, lng: event.latLng!.toJSON().lng }
if (this.infoWindow && marker.title) {
this.infoWindow.open(marker);
}
}
}
import { Component } from '@angular/core';
@Component({
selector: 'app-company-management',
template: `
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">Company Management</h4>
</div>
<div class="card-body">
<p>ยินดีต้อนรับสู่ระบบจัดการบริษัท</p>
<p>ระบบจัดการข้อมูลบริษัทและพนักงาน</p>
</div>
</div>
</div>
</div>
</div>
`,
styles: [`
.card {
margin: 20px 0;
}
.card-header {
background-color: #f8f9fa;
border-bottom: 1px solid #dee2e6;
}
`]
})
export class CompanyManagementComponent {
constructor() { }
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { CompanyManagementComponent } from './company-management.component';
export const routes: Routes = [
{
path: '',
component: CompanyManagementComponent
}
];
@NgModule({
declarations: [
CompanyManagementComponent
],
imports: [
CommonModule,
RouterModule.forChild(routes)
],
exports: [
CompanyManagementComponent
]
})
export class CompanyManagementModule {
static routes = routes;
}
<video #video width="640" height="480"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover;" autoplay
(loadedmetadata)="detectFace()">
</video>
<!-- Canvas element -->
<canvas #canvas width="640" height="480"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover;">
</canvas>
<button *ngIf="checkMatch" style="position: absolute; left: 0;bottom: 0;margin-bottom: 3rem;width: 100%;" type="button"
class="ti-btn bg-primary text-white !font-medium" (click)="captureImage()">ตรวจสอบใบหน้า</button>
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { HomeInstallerComponent } from './home-installer.component';
describe('HomeInstallerComponent', () => {
let component: HomeInstallerComponent;
let fixture: ComponentFixture<HomeInstallerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeInstallerComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeInstallerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { SharedModule } from '../../../shared/shared.module';
import { TranslateModule } from '@ngx-translate/core';
import { ActivatedRoute, Router } from '@angular/router';
import { CompanyService } from '../../services/company.service';
import { TokenService } from '../../../shared/services/token.service';
@Component({
selector: 'app-home-installer',
templateUrl: './home-installer.component.html',
standalone: true,
imports: [CommonModule, SharedModule, TranslateModule],
styleUrls: ['./home-installer.component.css']
})
export class HomeInstallerComponent implements OnInit {
companyId = ""
constructor(private router: Router, private route: ActivatedRoute, private comService: CompanyService, private tokenService: TokenService) {
this.companyId = this.route.snapshot.paramMap.get('companyId')!;
this.comService.getById(this.companyId).subscribe(result => {
console.log("SAVEEE")
this.tokenService.saveSelectCompany(result);
// this.router.navigate(["/company"]);
})
}
ngOnInit() {
}
}
:host {
display: block;
}
.map-container{
width: 100% !important
}
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { TimestampLogComponent } from './timestamp-log.component';
describe('TimestampLogComponent', () => {
let component: TimestampLogComponent;
let fixture: ComponentFixture<TimestampLogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TimestampLogComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TimestampLogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, ElementRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { SharedModule } from '../../../shared/shared.module';
import { SimplebarAngularModule } from 'simplebar-angular';
import { MaterialModuleModule } from '../../../material-module/material-module.module';
import { ActivatedRoute, RouterModule } from '@angular/router';
import { NgSelectModule } from '@ng-select/ng-select';
import { FlatpickrDefaults, FlatpickrModule } from 'angularx-flatpickr';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { TimestampService } from '../../services/timestamp.service';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { TokenService } from '../../../shared/services/token.service';
import { TimestampModel } from '../../models/timestamp.model';
import swal from 'sweetalert';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import moment from 'moment';
import { EmployeeModel } from '../../models/employee.model';
import { EmployeeService } from '../../services/employee.service';
import { GoogleMapsModule, MapMarker } from '@angular/google-maps';
@Component({
selector: 'app-timestamp-log',
templateUrl: './timestamp-log.component.html',
standalone: true,
imports: [CommonModule,
SharedModule,
TranslateModule,
NgSelectModule,
FormsModule,
GoogleMapsModule, MapMarker,
RouterModule,
FlatpickrModule],
styleUrls: ['./timestamp-log.component.css'],
providers: [FlatpickrDefaults],
encapsulation: ViewEncapsulation.None
})
export class TimestampLogComponent {
public dateRange: { from: Date, to: Date } = { from: new Date(new Date().getFullYear(), new Date().getMonth(), 1), to: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0) };
public options: any = {
"autoApply": true,
ranges: this.translate.currentLang == 'th' ? {
'วันนี้': [moment(), moment()],
'7 วันล่าสุด': [moment().subtract(6, 'days'), moment()],
'30 วันล่าสุด': [moment().subtract(29, 'days'), moment()],
'เดือนนี้': [moment().startOf('month'), moment().endOf('month')]
} : {
'Today': [moment(), moment()],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')]
},
"locale": {
"format": "DD/MM/YYYY",
"separator": " - ",
"applyLabel": "ตกลง",
"cancelLabel": "ยกเลิก",
"fromLabel": "จาก",
"toLabel": "ถึง",
"daysOfWeek": this.translate.instant("NameDayShort"),
"monthNames": this.translate.instant("NameMonth"),
"customRangeLabel": this.translate.instant("Range date"),
"firstDay": 1,
direction: 'daterange-center shadow'
},
"alwaysShowCalendars": true,
"startDate": this.dateRange.from,
"endDate": this.dateRange.to,
};
@ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') public modalDetail?: ElementRef;
action = "new";
allSelected = false;
someSelected = false;
itemsList: TimestampModel[] = []
filterList: TimestampModel[] = []
selectModel?: TimestampModel
empList: EmployeeModel[] = []
empSelect = ""
statusSelect = ""
descName = 'engName'
pageIndex = 0;
center: google.maps.LatLngLiteral = { lat: 13.7563, lng: 100.5018 };
zoom = 5;
markerOptions: google.maps.MarkerOptions = { draggable: false };
markerPositions: google.maps.LatLngLiteral = { lat: 13.7563, lng: 100.5018 };
get searchTerm(): string {
return this._searchTerm;
}
set searchTerm(val: string) {
this.pageIndex = 0;
this.allSelected = false
this._searchTerm = val;
if (val != '') {
this.filterList = this.filter(val);
} else {
this.updatePagedItems()
}
}
_searchTerm = "";
companyId = ""
constructor(private timeService: TimestampService, public translate: TranslateService, private tokenService: TokenService, private employeeService: EmployeeService, private route: ActivatedRoute) {
this.empSelect = this.route.snapshot.paramMap.get('company_employeeId') || "";
this.companyId = this.tokenService.getSelectCompany().companyId;;
this.getTimestamp()
this.getEmp()
}
ngOnInit(): void {
}
getTimestamp() {
this.pageIndex = 0;
console.log(this.dateRange)
this.timeService.getListsSearch(this.tokenService.getSelectCompany().companyId, this.empSelect, new Date(this.dateRange.from).toISOString(), new Date(this.dateRange.to).toISOString(), this.statusSelect).subscribe(result => {
this.itemsList = result.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
this.updatePagedItems()
})
}
getEmp() {
this.employeeService.getLists(this.companyId).subscribe(result => {
this.empList = result
})
}
searchTime() {
console.log(this.dateRange)
}
filter(v: string) {
return this.itemsList?.filter(
(x) =>
x.company_employeeId?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.timestampId?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.timestamp?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.locationName?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.getStatus().toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.timestamp.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.employee.getFullname().toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.employee.position.getName().toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.employee.department.getName().toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.employee.employeeId.toLowerCase().indexOf(v.toLowerCase()) !== -1
);
}
delete(item: TimestampModel) {
swal({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes,Delete it!"],
})
.then((willDelete: any) => {
if (willDelete) {
this.timeService.delete(this.companyId, item).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getTimestamp()
})
}
});
}
new() {
this.action = 'add'
this.selectModel = new TimestampModel()
this.selectModel.latitude = 0.00
this.selectModel.longitude = 0.00
}
view(item: TimestampModel) {
this.action = 'edit'
this.selectModel = new TimestampModel(item, this.translate)
console.log(this.selectModel)
}
approveTime(item: TimestampModel) {
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
item.timestampType = 1;
this.timeService.update(this.companyId, item).subscribe(result => {
console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.selectModel = undefined
this.getTimestamp()
this.childModal?.nativeElement.click()
})
}
});
}
disapproveTime(item: TimestampModel) {
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
item.timestampType = 3;
this.timeService.update(this.companyId, item).subscribe(result => {
console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.selectModel = undefined
this.getTimestamp()
this.childModal?.nativeElement.click()
})
}
});
}
save() {
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
if (this.action == 'add') {
this.timeService.save(this.companyId, this.selectModel!).subscribe(result => {
console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getTimestamp()
this.childModal?.nativeElement.click()
})
} else if (this.action == 'edit') {
this.timeService.update(this.companyId, this.selectModel!).subscribe(result => {
console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getTimestamp()
this.childModal?.nativeElement.click()
})
}
}
});
}
updatePagedItems() {
const startIndex = this.pageIndex * 10;
const endIndex = startIndex + 10;
this.filterList = this.itemsList.slice(startIndex, endIndex);
}
}
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { WarningTimetampComponent } from './warning-timetamp.component';
describe('WarningTimetampComponent', () => {
let component: WarningTimetampComponent;
let fixture: ComponentFixture<WarningTimetampComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ WarningTimetampComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WarningTimetampComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-warning-timetamp',
templateUrl: './warning-timetamp.component.html',
standalone: true,
styleUrls: ['./warning-timetamp.component.css']
})
export class WarningTimetampComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
......@@ -285,18 +285,7 @@ export class HomeComponent implements OnInit {
category: 'applications',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
// การบริการ
{
id: 'dashboard',
name: 'dashboard',
displayName: 'Dashboard',
description: 'แดชบอร์ดหลัก',
icon: './assets/images/icons/dashboard.png',
path: '/portal-manage/dashboard',
isVisible: true,
category: 'services',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'meetingBooking',
name: 'meeting-booking',
......@@ -320,66 +309,13 @@ export class HomeComponent implements OnInit {
category: 'system',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'roleManagement',
name: 'role-management',
displayName: 'Role Management',
description: 'ระบบจัดการบทบาท',
icon: './assets/images/icons/users.png',
path: '/portal-manage/role-management',
isVisible: true,
category: 'system',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'menuPermissionManagement',
name: 'menu-permission-management',
displayName: 'Menu Permission',
description: 'ระบบจัดการสิทธิ์เมนู',
icon: './assets/images/icons/menu.png',
path: '/portal-manage/menu-permission-management',
isVisible: true,
category: 'system',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'userManagement',
name: 'user-role-management',
displayName: 'User & Role Management',
description: 'ระบบจัดการผู้ใช้และบทบาท',
icon: './assets/images/icons/users.png',
path: '/portal-manage/user-role-management',
isVisible: true,
category: 'system',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'companyManagement',
name: 'company-management',
displayName: 'Company Management',
description: 'ระบบจัดการบริษัท',
icon: './assets/images/icons/building.png',
path: '/portal-manage/company-management',
isVisible: true,
category: 'system',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'widgetManagement',
name: 'widget-management',
displayName: 'Widget Management',
description: 'ระบบจัดการวิดเจ็ต',
icon: './assets/images/icons/widget.png',
path: '/portal-manage/widget-management',
isVisible: true,
category: 'system',
permissions: { view: true, create: true, edit: true, delete: true, export: true, import: true }
},
{
id: 'dashboardManagement',
name: 'dashboard-management',
displayName: 'Dashboard Management',
description: 'ระบบจัดการแดชบอร์ด',
description: 'ระบบจัดการแดชบอร์ด และคลังวิดเจ็ต',
icon: './assets/images/icons/dashboard.png',
path: '/portal-manage/dashboard-management',
isVisible: true,
......
......@@ -95,13 +95,6 @@ export const portalManageRoutes: Routes = [
canActivate: [moduleAccessGuard]
},
// Company Management
{
path: 'company-management',
canActivate: [moduleAccessGuard],
loadChildren: () => import('./company-management/company-management.module').then(m => m.CompanyManagementModule)
},
// Widget Management
{
path: 'widget-management',
......
/* Add custom styles for your widget stock component here */
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Observable } from 'rxjs';
import { IWidget } from '../../shared/models/dashboard.model';
import { DashboardService } from '../../shared/services/dashboard.service';
@Component({
selector: 'app-widget-stock',
standalone: true,
imports: [CommonModule],
templateUrl: './widget-stock.component.html',
styleUrls: ['./widget-stock.component.scss']
})
export class WidgetStockComponent implements OnInit {
public availableWidgets$!: Observable<IWidget[]>;
constructor(private dashboardService: DashboardService) { }
ngOnInit(): void {
this.availableWidgets$ = this.dashboardService.getAvailableWidgets();
}
}
......@@ -451,6 +451,15 @@
</a>
</div>
<div class="">
<a routerLink="/portal-manage/widget-stock"
class="p-4 items-center related-app block text-center rounded-sm hover:bg-gray-50 dark:hover:bg-black/20">
<img src="./assets/images/icons/widget.png" alt="Widget Stock"
class="leading-[1.75] text-2xl !h-[1.75rem] align-middle flex justify-center mx-auto">
<div class="text-[0.75rem] text-defaulttextcolor dark:text-[#8c9097] dark:text-white/50 mt-1">Widget Stock</div>
</a>
</div>
</div>
</div>
......
......@@ -14,7 +14,6 @@ import { formsRoutingModule } from '../../components/forms/forms.routes';
import { mapsRoutingModule } from '../../components/maps/maps.routes';
import { iconsRoutingModule } from '../../components/icons/icons.routes';
import { tablesRoutingModule } from '../../components/tables/tables.routes';
import { CompanyManagementModule } from '../../portal-manage/company-management/company-management.module';
import { MyskillXModule } from '../../portal-manage/myskill-x/myskill-x.module';
import { MylearnModule } from '../../portal-manage/mylearn/mylearn.module';
import { MyjobModule } from '../../portal-manage/myjob/myjob.module';
......@@ -43,7 +42,6 @@ export const content: Routes = [
...mapsRoutingModule.routes,
...iconsRoutingModule.routes,
...tablesRoutingModule.routes,
...CompanyManagementModule.routes,
...MyskillXModule.routes,
...MylearnModule.routes,
...MyjobModule.routes,
......
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