angular-dumb-lib 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ng-package.json +7 -0
- package/package.json +3 -16
- package/src/lib/angular-dumb-lib.component.spec.ts +21 -0
- package/src/lib/angular-dumb-lib.component.ts +15 -0
- package/src/lib/angular-dumb-lib.module.ts +19 -0
- package/src/lib/angular-dumb-lib.service.spec.ts +16 -0
- package/src/lib/angular-dumb-lib.service.ts +9 -0
- package/src/lib/components/atoms/button/button.component.html +15 -0
- package/src/lib/components/atoms/button/button.component.scss +76 -0
- package/src/lib/components/atoms/button/button.component.ts +33 -0
- package/src/lib/components/atoms/datetime-picker/datetime-picker.component.html +7 -0
- package/src/lib/components/atoms/datetime-picker/datetime-picker.component.scss +24 -0
- package/src/lib/components/atoms/datetime-picker/datetime-picker.component.ts +59 -0
- package/src/lib/components/atoms/file-selection/file-selection.component.html +24 -0
- package/src/lib/components/atoms/file-selection/file-selection.component.scss +35 -0
- package/src/lib/components/atoms/file-selection/file-selection.component.ts +86 -0
- package/src/lib/components/atoms/input/input.component.html +28 -0
- package/src/lib/components/atoms/input/input.component.scss +64 -0
- package/src/lib/components/atoms/input/input.component.ts +57 -0
- package/src/lib/components/atoms/loading/loading.component.html +3 -0
- package/src/lib/components/atoms/loading/loading.component.scss +36 -0
- package/src/lib/components/atoms/loading/loading.component.ts +21 -0
- package/src/lib/components/atoms/selection/selection.component.html +38 -0
- package/src/lib/components/atoms/selection/selection.component.scss +65 -0
- package/src/lib/components/atoms/selection/selection.component.ts +84 -0
- package/src/lib/components/atoms/slider/slider.component.html +14 -0
- package/src/lib/components/atoms/slider/slider.component.scss +50 -0
- package/src/lib/components/atoms/slider/slider.component.ts +37 -0
- package/src/lib/components/atoms/tags/tags.component.html +25 -0
- package/src/lib/components/atoms/tags/tags.component.scss +58 -0
- package/src/lib/components/atoms/tags/tags.component.ts +62 -0
- package/src/lib/components/molecules/cards/cards.component.html +12 -0
- package/src/lib/components/molecules/cards/cards.component.scss +14 -0
- package/src/lib/components/molecules/cards/cards.component.ts +19 -0
- package/src/lib/components/molecules/content-design/content-design.component.html +14 -0
- package/src/lib/components/molecules/content-design/content-design.component.scss +68 -0
- package/src/lib/components/molecules/content-design/content-design.component.ts +32 -0
- package/src/lib/components/molecules/form/form.component.html +22 -0
- package/src/lib/components/molecules/form/form.component.scss +17 -0
- package/src/lib/components/molecules/form/form.component.ts +64 -0
- package/src/lib/components/molecules/modal/modal.component.html +16 -0
- package/src/lib/components/molecules/modal/modal.component.scss +83 -0
- package/src/lib/components/molecules/modal/modal.component.ts +48 -0
- package/src/lib/components/molecules/paginator/paginator.component.html +25 -0
- package/src/lib/components/molecules/paginator/paginator.component.scss +27 -0
- package/src/lib/components/molecules/paginator/paginator.component.ts +126 -0
- package/src/lib/components/molecules/table/table.component.html +45 -0
- package/src/lib/components/molecules/table/table.component.scss +169 -0
- package/src/lib/components/molecules/table/table.component.ts +40 -0
- package/src/lib/components/pages/footer/footer.component.html +32 -0
- package/src/lib/components/pages/footer/footer.component.scss +69 -0
- package/src/lib/components/pages/footer/footer.component.ts +16 -0
- package/src/lib/components/pages/login/login.component.html +10 -0
- package/src/lib/components/pages/login/login.component.scss +32 -0
- package/src/lib/components/pages/login/login.component.ts +32 -0
- package/src/lib/components/pages/menu/menu.component.html +18 -0
- package/src/lib/components/pages/menu/menu.component.scss +87 -0
- package/src/lib/components/pages/menu/menu.component.ts +26 -0
- package/src/lib/components/pages/version/version.component.html +3 -0
- package/src/lib/components/pages/version/version.component.scss +0 -0
- package/src/lib/components/pages/version/version.component.ts +28 -0
- package/src/lib/shared/constants/constant.ts +7 -0
- package/src/lib/shared/enums/enum.ts +68 -0
- package/src/lib/shared/interfaces/interface.ts +64 -0
- package/{public-api.d.ts → src/public-api.ts} +5 -1
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/angular-dumb-lib.mjs +0 -5
- package/esm2022/lib/angular-dumb-lib.component.mjs +0 -20
- package/esm2022/lib/angular-dumb-lib.module.mjs +0 -32
- package/esm2022/lib/angular-dumb-lib.service.mjs +0 -15
- package/esm2022/lib/components/atoms/button/button.component.mjs +0 -34
- package/esm2022/lib/components/atoms/input/input.component.mjs +0 -57
- package/esm2022/lib/components/molecules/content-design/content-design.component.mjs +0 -32
- package/esm2022/lib/shared/enums/enum.mjs +0 -69
- package/esm2022/lib/shared/interfaces/interface.mjs +0 -2
- package/esm2022/public-api.mjs +0 -10
- package/fesm2022/angular-dumb-lib.mjs +0 -243
- package/fesm2022/angular-dumb-lib.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/angular-dumb-lib.component.d.ts +0 -5
- package/lib/angular-dumb-lib.module.d.ts +0 -9
- package/lib/angular-dumb-lib.service.d.ts +0 -6
- package/lib/components/atoms/button/button.component.d.ts +0 -12
- package/lib/components/atoms/input/input.component.d.ts +0 -19
- package/lib/components/molecules/content-design/content-design.component.d.ts +0 -12
- package/lib/shared/enums/enum.d.ts +0 -59
- package/lib/shared/interfaces/interface.d.ts +0 -58
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
+
import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
+
import { InputGroupType, InputType } from '../../../shared/enums/enum';
|
|
4
|
+
import { selectionInputTypes, textualInputTypes } from '../../../shared/constants/constant';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
import { ButtonComponent, InputComponent } from 'angular-dumb-lib';
|
|
7
|
+
import { SelectionComponent } from '../../atoms/selection/selection.component';
|
|
8
|
+
import { FileSelectionComponent } from '../../atoms/file-selection/file-selection.component';
|
|
9
|
+
import { IInputConfig } from '../../../shared/interfaces/interface';
|
|
10
|
+
import { IButtonConfig } from 'dist/angular-dumb-lib/lib/shared/interfaces/interface';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'app-form',
|
|
15
|
+
standalone: true,
|
|
16
|
+
templateUrl: './form.component.html',
|
|
17
|
+
styleUrls: ['./form.component.scss'],
|
|
18
|
+
imports: [CommonModule, InputComponent, SelectionComponent,
|
|
19
|
+
FileSelectionComponent, ButtonComponent, FormsModule, ReactiveFormsModule]
|
|
20
|
+
})
|
|
21
|
+
export class FormComponent {
|
|
22
|
+
@Input() formGroup!: FormGroup;
|
|
23
|
+
@Input() inputConfigs!: Array<IInputConfig>;
|
|
24
|
+
@Input() buttonConfig: IButtonConfig = {
|
|
25
|
+
label: "Submit"
|
|
26
|
+
}
|
|
27
|
+
@Input() validationMessages!: { [key: string]: string };
|
|
28
|
+
|
|
29
|
+
@Output() formSubmit = new EventEmitter<any>();
|
|
30
|
+
@Output() formChange = new EventEmitter<{ controlName: string; value: any }>();
|
|
31
|
+
|
|
32
|
+
// Define the editor configuration
|
|
33
|
+
|
|
34
|
+
onSubmit() {
|
|
35
|
+
if (this.formGroup.valid) {
|
|
36
|
+
this.formSubmit.emit(this.formGroup.value);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log('Form not valid');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onValueChange(controlName: string, value: any) {
|
|
44
|
+
this.formChange.emit({ controlName, value });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
checkFormConfigType(inputType: InputType | undefined): InputGroupType {
|
|
48
|
+
if(inputType) {
|
|
49
|
+
if(textualInputTypes.includes(inputType)) {
|
|
50
|
+
return InputGroupType.textual;
|
|
51
|
+
}
|
|
52
|
+
if(selectionInputTypes.includes(inputType)) {
|
|
53
|
+
return InputGroupType.selection;
|
|
54
|
+
}
|
|
55
|
+
if(inputType === InputType.file) {
|
|
56
|
+
return InputGroupType.file;
|
|
57
|
+
}
|
|
58
|
+
if(inputType === InputType.datetime) {
|
|
59
|
+
return InputGroupType.datetime;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return InputGroupType.textual;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="modal-overlay" (click)="handleOverlayClick($event)" *ngIf="modalEvent?.isModalVisible">
|
|
2
|
+
<div class="modal-content" (click)="handleContentClick($event)">
|
|
3
|
+
<div class="modal-header">
|
|
4
|
+
<h2>{{modalEvent.title }}</h2>
|
|
5
|
+
<button class="close-btn" (click)="closeModal()">
|
|
6
|
+
<i class="material-icons">close</i>
|
|
7
|
+
</button>
|
|
8
|
+
</div>
|
|
9
|
+
<div *ngIf="modalEvent.params && modalEvent.params['content']">{{modalEvent.params['content'] | translate}}</div>
|
|
10
|
+
<ng-container *ngTemplateOutlet="modalEvent.template; context: modalEvent.params"></ng-container>
|
|
11
|
+
<div *ngIf="!modalEvent?.isDialog" class="buttons">
|
|
12
|
+
<app-button [config]="okConfig" (clickEvent)="ok()"></app-button>
|
|
13
|
+
<app-button [config]="cancelConfig" (clickEvent)="cancel()"></app-button>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.modal-overlay {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
11
|
+
z-index: 50;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.modal-content {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 20px;
|
|
18
|
+
background-color: #fff;
|
|
19
|
+
color: #000;
|
|
20
|
+
border-radius: 0.5rem;
|
|
21
|
+
padding: 2rem;
|
|
22
|
+
max-width: 600px;
|
|
23
|
+
width: 100%;
|
|
24
|
+
max-height: calc(100vh - 7rem); /* Full height */
|
|
25
|
+
overflow-y: auto; /* Scroll if content is longer than modal */
|
|
26
|
+
|
|
27
|
+
&.dark-mode {
|
|
28
|
+
background-color: #27272a; // dark:bg-zinc-800
|
|
29
|
+
color: #d1d5db; // dark:text-zinc-300
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.modal-header {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
h2 {
|
|
40
|
+
font-size: 2rem;
|
|
41
|
+
font-weight: bold;
|
|
42
|
+
margin: unset;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
p {
|
|
46
|
+
color: #4b5563; // text-zinc-600
|
|
47
|
+
margin-bottom: 1.5rem;
|
|
48
|
+
|
|
49
|
+
&.dark-mode {
|
|
50
|
+
color: #d1d5db; // dark:text-zinc-300
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.modal-actions {
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: flex-end;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.close-btn {
|
|
60
|
+
background-color: transparent;
|
|
61
|
+
border: none;
|
|
62
|
+
font-size: 1.5rem;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
padding: 0;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.close-btn i.material-icons {
|
|
70
|
+
font-size: 24px;
|
|
71
|
+
color: #888;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.close-btn:hover i.material-icons {
|
|
75
|
+
color: #444;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.buttons {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: row;
|
|
81
|
+
justify-content: end;
|
|
82
|
+
gap: 15px;
|
|
83
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { IButtonConfig, IModalEvent } from '../../../shared/interfaces/interface';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { ButtonComponent } from 'angular-dumb-lib';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'app-modal',
|
|
8
|
+
standalone: true,
|
|
9
|
+
templateUrl: './modal.component.html',
|
|
10
|
+
styleUrls: ['./modal.component.scss'],
|
|
11
|
+
imports: [CommonModule, ButtonComponent]
|
|
12
|
+
})
|
|
13
|
+
export class ModalComponent implements OnInit {
|
|
14
|
+
@Input() modalEvent!: IModalEvent;
|
|
15
|
+
okConfig: IButtonConfig = {
|
|
16
|
+
label: "Ok"
|
|
17
|
+
}
|
|
18
|
+
cancelConfig: IButtonConfig = {
|
|
19
|
+
label: "Cancel"
|
|
20
|
+
}
|
|
21
|
+
constructor() { }
|
|
22
|
+
|
|
23
|
+
ngOnInit() {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
closeModal() {
|
|
27
|
+
this.modalEvent.isModalVisible = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handleOverlayClick(event: MouseEvent) {
|
|
31
|
+
this.closeModal();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handleContentClick(event: MouseEvent) {
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ok() {
|
|
39
|
+
if (this.modalEvent && this.modalEvent.onOk) {
|
|
40
|
+
this.modalEvent.onOk();
|
|
41
|
+
this.closeModal();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
cancel() {
|
|
46
|
+
this.closeModal();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div class="table-footer">
|
|
2
|
+
<div class="number-of-page">
|
|
3
|
+
<app-selection [options] = "itemsPerPageList"
|
|
4
|
+
[selectedValue]="this.itemsPerPage"
|
|
5
|
+
(selectedChange) = "onChangeNumberOfPage($event)">
|
|
6
|
+
</app-selection>
|
|
7
|
+
<app-input [config]="inputConfig"></app-input>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="paginator">
|
|
10
|
+
<app-button (clickEvent)="selectPage(selectedPage - 1)"
|
|
11
|
+
[config]="previousButtonConfig"/>
|
|
12
|
+
|
|
13
|
+
<!-- Page Numbers -->
|
|
14
|
+
<ng-container *ngFor="let page of pageNumbers">
|
|
15
|
+
<app-button
|
|
16
|
+
(clickEvent)="selectPage(page)"
|
|
17
|
+
[config]="getPageButtonConfig(page)">
|
|
18
|
+
</app-button>
|
|
19
|
+
</ng-container>
|
|
20
|
+
|
|
21
|
+
<!-- Next Button -->
|
|
22
|
+
<app-button (clickEvent)="selectPage(selectedPage + 1)"
|
|
23
|
+
[config]="nextButtonConfig"/>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
body {
|
|
2
|
+
color: #566787;
|
|
3
|
+
background: #f5f5f5;
|
|
4
|
+
font-family: 'Varela Round', sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.table-footer {
|
|
9
|
+
display: flex;
|
|
10
|
+
|
|
11
|
+
.number-of-page {
|
|
12
|
+
width: 70%;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 20px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.paginator {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: flex-end;
|
|
21
|
+
width: 100%;
|
|
22
|
+
|
|
23
|
+
app-button {
|
|
24
|
+
margin: 0 2px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
3
|
+
import { IButtonConfig, IDropdownOption, IInputConfig, IPaginator } from '../../../shared/interfaces/interface';
|
|
4
|
+
import { ButtonType, InputDirection } from '../../../shared/enums/enum';
|
|
5
|
+
import { ButtonComponent, InputComponent } from 'angular-dumb-lib';
|
|
6
|
+
import { SelectionComponent } from '../../atoms/selection/selection.component';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'app-paginator',
|
|
10
|
+
standalone: true,
|
|
11
|
+
templateUrl: './paginator.component.html',
|
|
12
|
+
styleUrls: ['./paginator.component.scss'],
|
|
13
|
+
imports: [CommonModule, ButtonComponent, SelectionComponent, InputComponent]
|
|
14
|
+
})
|
|
15
|
+
export class PaginatorComponent implements OnInit {
|
|
16
|
+
itemsPerPageList: IDropdownOption[] = [];
|
|
17
|
+
inputConfig: IInputConfig = {
|
|
18
|
+
label: 'Go to page',
|
|
19
|
+
direction: InputDirection.horizontal,
|
|
20
|
+
name: 'inputConfig',
|
|
21
|
+
required: false
|
|
22
|
+
}
|
|
23
|
+
previousButtonConfig: IButtonConfig = {
|
|
24
|
+
iconValue: 'chevron_left',
|
|
25
|
+
type: ButtonType.button,
|
|
26
|
+
isDisabled: true
|
|
27
|
+
}
|
|
28
|
+
nextButtonConfig: IButtonConfig = {
|
|
29
|
+
iconValue: 'chevron_right',
|
|
30
|
+
type: ButtonType.button,
|
|
31
|
+
isDisabled: false
|
|
32
|
+
}
|
|
33
|
+
numberOfPage: number = 0;
|
|
34
|
+
itemsPerPage: number = 0;
|
|
35
|
+
selectedPage: number = 0;
|
|
36
|
+
buttonType!: ButtonType;
|
|
37
|
+
inputDirection!: InputDirection;
|
|
38
|
+
|
|
39
|
+
@Input() totalRecords: number = 0;
|
|
40
|
+
|
|
41
|
+
@Output() paginator = new EventEmitter<IPaginator>();
|
|
42
|
+
|
|
43
|
+
constructor() {}
|
|
44
|
+
|
|
45
|
+
get pageNumbers(): number[] {
|
|
46
|
+
return Array.from({ length: this.numberOfPage }, (_, i) => i + 1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ngOnInit() {
|
|
50
|
+
this.itemsPerPageList = [
|
|
51
|
+
{
|
|
52
|
+
label: "3",
|
|
53
|
+
value: 1
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: "5",
|
|
57
|
+
value: 2
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: "20",
|
|
61
|
+
value: 3
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
this.selectedPage = 1;
|
|
65
|
+
this.buttonType = ButtonType.button;
|
|
66
|
+
this.inputDirection = InputDirection.horizontal;
|
|
67
|
+
this.itemsPerPage = parseInt(this.itemsPerPageList[0].label);
|
|
68
|
+
this.calculateNumberOfPage(this.totalRecords, this.itemsPerPage);
|
|
69
|
+
this.updateButtonConfigs();
|
|
70
|
+
this.emitPaging();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ngOnChanges(): void {
|
|
74
|
+
this.calculateNumberOfPage(this.totalRecords, this.itemsPerPage);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
selectPage(i: number) {
|
|
78
|
+
this.selectedPage = i;
|
|
79
|
+
this.updateButtonConfigs();
|
|
80
|
+
this.emitPaging();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onChangeNumberOfPage(itemsPerPageId: string) {
|
|
84
|
+
this.selectedPage = 1;
|
|
85
|
+
this.itemsPerPage = parseInt(this.itemsPerPageList.find(i=> i.value === parseInt(itemsPerPageId))?.label??
|
|
86
|
+
this.itemsPerPage.toString());
|
|
87
|
+
|
|
88
|
+
this.calculateNumberOfPage(this.totalRecords, this.itemsPerPage);
|
|
89
|
+
this.updateButtonConfigs();
|
|
90
|
+
this.emitPaging();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private emitPaging() {
|
|
94
|
+
let paging: IPaginator = {
|
|
95
|
+
itemsPerPage: this.itemsPerPage,
|
|
96
|
+
selectedPage: this.selectedPage
|
|
97
|
+
}
|
|
98
|
+
this.paginator.emit(paging);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private calculateNumberOfPage (totalRecords: number, itemsPerPage: number): number {
|
|
102
|
+
return this.numberOfPage = Math.ceil(totalRecords/itemsPerPage);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private updateButtonConfigs() {
|
|
106
|
+
// Re-assign the button configuration to trigger change detection
|
|
107
|
+
this.previousButtonConfig = {
|
|
108
|
+
...this.previousButtonConfig,
|
|
109
|
+
isDisabled: this.selectedPage <= 1
|
|
110
|
+
};
|
|
111
|
+
this.nextButtonConfig = {
|
|
112
|
+
...this.nextButtonConfig,
|
|
113
|
+
isDisabled: this.selectedPage >= this.numberOfPage
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Method to return config for page number buttons
|
|
118
|
+
getPageButtonConfig(page: number): IButtonConfig {
|
|
119
|
+
return {
|
|
120
|
+
label: page.toString(),
|
|
121
|
+
type: ButtonType.button,
|
|
122
|
+
isActive: page === this.selectedPage, // Set active state based on selectedPage
|
|
123
|
+
isDisabled: false // Page buttons are never disabled
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<div class="container-xl table-wrapper">
|
|
2
|
+
<div class="table-title">
|
|
3
|
+
<h2><b>{{tableName }}</b></h2>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="loading-wrapper">
|
|
6
|
+
<ng-container *ngIf="!(loadingState | async); else loading; then table">
|
|
7
|
+
</ng-container>
|
|
8
|
+
</div>
|
|
9
|
+
<app-paginator [totalRecords] = "totalRecords" (paginator)="changePaginator($event)"></app-paginator>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<ng-template #loading>
|
|
13
|
+
<div class="loading-wrapper">
|
|
14
|
+
<app-loading></app-loading>
|
|
15
|
+
</div>
|
|
16
|
+
</ng-template>
|
|
17
|
+
|
|
18
|
+
<ng-template #table>
|
|
19
|
+
<ng-container *ngIf="totalRecords == 0; then emptyContent; else tableContent">
|
|
20
|
+
</ng-container>
|
|
21
|
+
</ng-template>
|
|
22
|
+
|
|
23
|
+
<ng-template #tableContent>
|
|
24
|
+
<p-table [value]="items" class="table table-striped table-hover">
|
|
25
|
+
<ng-template pTemplate="header">
|
|
26
|
+
<tr>
|
|
27
|
+
<th>
|
|
28
|
+
<ng-content select="[selectAllCheckbox]"></ng-content>
|
|
29
|
+
</th>
|
|
30
|
+
<ng-container *ngFor=" let col of columns">
|
|
31
|
+
<th>{{col.name }}</th>
|
|
32
|
+
</ng-container>
|
|
33
|
+
</tr>
|
|
34
|
+
</ng-template>
|
|
35
|
+
<ng-template pTemplate="body" let-item>
|
|
36
|
+
<ng-container [ngTemplateOutlet]="bodyTemplate" [ngTemplateOutletContext]="{item:item}"></ng-container>
|
|
37
|
+
</ng-template>
|
|
38
|
+
</p-table>
|
|
39
|
+
</ng-template>
|
|
40
|
+
|
|
41
|
+
<ng-template #emptyContent>
|
|
42
|
+
<div class="no-record-message">
|
|
43
|
+
<div>No records</div>
|
|
44
|
+
</div>
|
|
45
|
+
</ng-template>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
width: 100%;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
body {
|
|
6
|
+
color: #566787;
|
|
7
|
+
background: #f5f5f5;
|
|
8
|
+
font-family: 'Varela Round', sans-serif;
|
|
9
|
+
font-size: 13px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.table-responsive {
|
|
13
|
+
margin: 30px 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.table-wrapper {
|
|
17
|
+
background: #fff;
|
|
18
|
+
border-radius: 3px;
|
|
19
|
+
min-width: 1000px;
|
|
20
|
+
box-shadow: 0 1px 1px rgba(0,0,0,.05);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.table-title {
|
|
24
|
+
background: #435d7d;
|
|
25
|
+
color: #fff;
|
|
26
|
+
border-radius: 3px 3px 0 0;
|
|
27
|
+
padding: 0px 12px;
|
|
28
|
+
display: flex;
|
|
29
|
+
.table-name {
|
|
30
|
+
width: 70%;
|
|
31
|
+
};
|
|
32
|
+
.table-add {
|
|
33
|
+
width: 30%;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
a {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
h2 {
|
|
42
|
+
font-size: 24px;
|
|
43
|
+
}
|
|
44
|
+
.btn-group {
|
|
45
|
+
float: right;
|
|
46
|
+
}
|
|
47
|
+
.btn {
|
|
48
|
+
color: #fff;
|
|
49
|
+
float: right;
|
|
50
|
+
font-size: 13px;
|
|
51
|
+
border: none;
|
|
52
|
+
min-width: 50px;
|
|
53
|
+
border-radius: 2px;
|
|
54
|
+
border: none;
|
|
55
|
+
outline: none !important;
|
|
56
|
+
margin-left: 10px;
|
|
57
|
+
i {
|
|
58
|
+
float: left;
|
|
59
|
+
font-size: 21px;
|
|
60
|
+
margin-right: 5px;
|
|
61
|
+
}
|
|
62
|
+
span {
|
|
63
|
+
float: left;
|
|
64
|
+
margin-top: 2px;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
::ng-deep .table tr th, ::ng-deep .table tr td {
|
|
70
|
+
border-color: #e9e9e9;
|
|
71
|
+
padding: 12px 15px;
|
|
72
|
+
vertical-align: middle;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
::ng-deep .table tr th:first-child {
|
|
76
|
+
width: 60px;
|
|
77
|
+
display: flex;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
::ng-deep .table tr th:last-child {
|
|
81
|
+
width: 150px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
table.table-striped tbody tr:nth-of-type(odd) {
|
|
85
|
+
background-color: #fcfcfc;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
table.table-striped.table-hover tbody tr:hover {
|
|
89
|
+
background: #f5f5f5;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
::ng-deep .table th {
|
|
93
|
+
text-align: left;
|
|
94
|
+
i {
|
|
95
|
+
font-size: 13px;
|
|
96
|
+
margin: 0 5px;
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
::ng-deep .table td:last-child i {
|
|
103
|
+
opacity: 0.9;
|
|
104
|
+
font-size: 22px;
|
|
105
|
+
margin: 0 5px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
::ng-deep .table td a {
|
|
109
|
+
font-weight: bold;
|
|
110
|
+
color: #566787;
|
|
111
|
+
display: inline-block;
|
|
112
|
+
text-decoration: none;
|
|
113
|
+
outline: none !important;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.hint-text {
|
|
117
|
+
float: left;
|
|
118
|
+
margin-top: 10px;
|
|
119
|
+
font-size: 13px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.no-record-message {
|
|
123
|
+
width: 100%;
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-direction: column;
|
|
126
|
+
align-items: center;
|
|
127
|
+
justify-content: center;
|
|
128
|
+
height: 100%;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.excel {
|
|
132
|
+
display: flex;
|
|
133
|
+
a {
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.loading-wrapper {
|
|
140
|
+
height: calc(100vh - 220px);
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
width: 100%;
|
|
144
|
+
overflow-y: auto; /* Scroll vertically when content overflows */
|
|
145
|
+
overflow-x: hidden; /* Hide horizontal scrollbar */
|
|
146
|
+
|
|
147
|
+
/* Custom Scrollbar for WebKit-based Browsers */
|
|
148
|
+
&::-webkit-scrollbar {
|
|
149
|
+
width: 12px; /* Adjusted width for a more standard look */
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&::-webkit-scrollbar-track {
|
|
153
|
+
background: #f1f1f1; /* Light gray background for the track */
|
|
154
|
+
border-radius: 10px; /* Rounded corners for the track */
|
|
155
|
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1); /* Subtle shadow for a polished look */
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&::-webkit-scrollbar-thumb {
|
|
159
|
+
background: #888; /* Neutral gray color for the thumb */
|
|
160
|
+
border-radius: 10px; /* Rounded corners for the thumb */
|
|
161
|
+
border: 3px solid #f1f1f1; /* Creates a gap between the thumb and track */
|
|
162
|
+
transition: background 0.3s; /* Smooth transition for hover effect */
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
166
|
+
background: #555; /* Darker gray for the thumb on hover */
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { IDataColumnConfig, IPaginator } from '../../../shared/interfaces/interface';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { TableModule} from 'primeng/table';
|
|
6
|
+
import { LoadingComponent } from '../../atoms/loading/loading.component';
|
|
7
|
+
import { PaginatorComponent } from '../paginator/paginator.component';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'app-table',
|
|
11
|
+
standalone: true,
|
|
12
|
+
templateUrl: './table.component.html',
|
|
13
|
+
styleUrls: ['./table.component.scss'],
|
|
14
|
+
imports: [CommonModule, TableModule, LoadingComponent, PaginatorComponent]
|
|
15
|
+
})
|
|
16
|
+
export class TableComponent<T> implements OnInit {
|
|
17
|
+
@Input() items: T[] = [];
|
|
18
|
+
@Input() columns: IDataColumnConfig[] = [];
|
|
19
|
+
@Input() totalRecords: number = 0;
|
|
20
|
+
@Input() tableName: string = '';
|
|
21
|
+
@Input() loadingState!: Observable<boolean>;
|
|
22
|
+
|
|
23
|
+
@Output() paginator = new EventEmitter<IPaginator>()
|
|
24
|
+
|
|
25
|
+
@ContentChild('bodyTemplate') bodyTemplate!: TemplateRef<any>;
|
|
26
|
+
|
|
27
|
+
allSelected = false;
|
|
28
|
+
|
|
29
|
+
constructor(private cdRef: ChangeDetectorRef) { }
|
|
30
|
+
|
|
31
|
+
ngOnInit() {
|
|
32
|
+
this.loadingState.subscribe(() => {
|
|
33
|
+
this.cdRef.detectChanges(); // Explicitly mark for change detection
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
changePaginator(paging: IPaginator) {
|
|
38
|
+
this.paginator.emit(paging);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<footer class="footer">
|
|
2
|
+
<div class="footer-container">
|
|
3
|
+
<div class="footer-section">
|
|
4
|
+
<h3>About Us</h3>
|
|
5
|
+
<p>We are a company dedicated to providing excellent services and products to our customers.</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class="footer-section">
|
|
9
|
+
<h3>Quick Links</h3>
|
|
10
|
+
<ul>
|
|
11
|
+
<li><a href="#">Home</a></li>
|
|
12
|
+
<li><a href="#">Services</a></li>
|
|
13
|
+
<li><a href="#">Contact</a></li>
|
|
14
|
+
<li><a href="#">Privacy Policy</a></li>
|
|
15
|
+
</ul>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="footer-section">
|
|
19
|
+
<h3>Follow Us</h3>
|
|
20
|
+
<div class="social-icons">
|
|
21
|
+
<a href="#" aria-label="Facebook"><i class="fab fa-facebook-f"></i></a>
|
|
22
|
+
<a href="#" aria-label="Twitter"><i class="fab fa-twitter"></i></a>
|
|
23
|
+
<a href="#" aria-label="Instagram"><i class="fab fa-instagram"></i></a>
|
|
24
|
+
<a href="#" aria-label="LinkedIn"><i class="fab fa-linkedin-in"></i></a>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="footer-bottom">
|
|
30
|
+
<p>© 2024 Your Company. All Rights Reserved.</p>
|
|
31
|
+
</div>
|
|
32
|
+
</footer>
|