瀏覽代碼

Pagination

Alex Ondoa 2 年之前
父節點
當前提交
0000b85a06

+ 17520
- 36
Angular/package-lock.json
文件差異過大導致無法顯示
查看文件


+ 3
- 0
Angular/package.json 查看文件

@@ -27,7 +27,10 @@
27 27
         "@fullcalendar/daygrid": "^5.8.0",
28 28
         "@fullcalendar/interaction": "^5.8.0",
29 29
         "@fullcalendar/timegrid": "^5.8.0",
30
+        "bootstrap": "^5.1.3",
30 31
         "chart.js": "^3.3.2",
32
+        "jquery": "^3.6.0",
33
+        "ngx-pagination": "^5.1.1",
31 34
         "primeflex": "3.0.1",
32 35
         "primeicons": "4.1.0",
33 36
         "primeng": "12.2.1",

+ 4
- 1
Angular/src/app/app.module.ts 查看文件

@@ -106,6 +106,8 @@ import dayGridPlugin from '@fullcalendar/daygrid';
106 106
 import timeGridPlugin from '@fullcalendar/timegrid';
107 107
 import interactionPlugin from '@fullcalendar/interaction';
108 108
 
109
+import { NgxPaginationModule } from 'ngx-pagination';
110
+
109 111
 
110 112
 FullCalendarModule.registerPlugins([
111 113
     dayGridPlugin,
@@ -201,7 +203,8 @@ FullCalendarModule.registerPlugins([
201 203
         TreeTableModule,
202 204
         VirtualScrollerModule,
203 205
         AppCodeModule,
204
-        ReactiveFormsModule
206
+        ReactiveFormsModule,
207
+        NgxPaginationModule
205 208
     ],
206 209
     declarations: [
207 210
         AppComponent,

+ 31
- 41
Angular/src/app/pages/candidat/candidat-list/candidat-list.component.html 查看文件

@@ -1,6 +1,7 @@
1 1
 <div class="card">
2 2
     <h5>Candidates List</h5>
3
-    <div><button (click)="showNew()" type="button" class="primary">Add</button><br></div>
3
+    <div><button (click)="showNew()" type="button" class="btn btn-primary">Add</button></div>
4
+    <br/>
4 5
     <table class="table table-bordered">
5 6
         <thead>
6 7
           <tr>
@@ -11,7 +12,7 @@
11 12
           </tr>
12 13
         </thead>
13 14
         <tbody>
14
-          <tr (click)="showDetail(candidate.id)"  *ngFor="let candidate of candidates | async">
15
+          <tr (click)="showDetail(candidate.id)"  *ngFor="let candidate of candidates | async | paginate: { itemsPerPage: 4, currentPage: cp }" class="listMargin">
15 16
                 <td>{{candidate.id}}</td>
16 17
                 <td>{{candidate.firstName}}</td>
17 18
                 <td>{{candidate.lastName}}</td>
@@ -22,50 +23,39 @@
22 23
                     </tr>
23 24
                 </td>
24 25
                 <td>
25
-                  <button icon="pi pi-pencil" class="p-button-rounded p-button-success mr-2" (click)="showDetail(candidate.id)">edit</button>
26
-                  <button  icon="pi pi-trash" class="p-button-rounded p-button-warning">delete</button>
26
+                  <button class="btn btn-warning" (click)="showDetail(candidate.id)">Edit</button> - <button class="btn btn-danger" >Delete</button>
27 27
                </td>
28 28
           </tr>
29 29
         </tbody>
30 30
       </table>
31
-      <div>
31
+      <pagination-controls (pageChange)="cp = $event"></pagination-controls>
32
+     <div>
32 33
         <form name="editForm" role="form">
33
-            <button>Search</button>
34
+            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
35
+              Search
36
+            </button>
34 37
         </form>
35 38
       </div>
36
-   <!-- <button [routerLink]="'/candidate/candidate-sidebar'" pButton pRipple type="button" label="Add" class="mr-2 mb-2"></button> -->
37
-   <!--  <p-table #dt  [value]="theCandidates" [paginator]="true" [rows]="5" [showCurrentPageReport]="true" responsiveLayout="scroll"
38
-        currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [rowsPerPageOptions]="[5,10,25,50]">
39
-        <ng-template pTemplate="header">
40
-            <tr>
41
-                <th>Id</th>
42
-                <th>First Name</th>
43
-                <th>Last Name</th>
44
-                <th>Emails</th>
45
-            </tr>
46
-        </ng-template>
47
-        <ng-template pTemplate="body" let-candidate>
48
-            <tr>
49
-                <td>{{candidate.id}}</td>
50
-                <td>{{candidate.firstname}}</td>
51
-                <td>{{candidate.lastname}}</td>
52
-                <td>
53
-                    <tr *ngFor="let ml of candidate.emails">
54
-                      <span>{{ml.email}}</span>
55
-                      <span> - {{ml.type}}</span>
56
-                    </tr>
57
-                </td>
58
-                <td>
59
-                  <button pButton pRipple icon="pi pi-pencil" class="p-button-rounded p-button-success mr-2"></button>
60
-                  <button pButton pRipple icon="pi pi-trash" class="p-button-rounded p-button-warning"></button>
61
-               </td>
62
-            </tr>
63
-        </ng-template>
64
-        <ng-template pTemplate="paginatorleft">
65
-          <span class="p-float-label">
66
-            <input type="text" class="w-full" pInputText>
67
-            <label>Search</label>
68
-          </span>
69
-        </ng-template>
70
-    </p-table> -->
39
+ 
71 40
 </div>
41
+
42
+<!-- Modal -->
43
+<div class="modal" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
44
+  <div class="modal-dialog" role="document">
45
+    <div class="modal-content">
46
+      <div class="modal-header">
47
+        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
48
+        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
49
+          <span aria-hidden="true">&times;</span>
50
+        </button>
51
+      </div>
52
+      <div class="modal-body">
53
+        ...
54
+      </div>
55
+      <div class="modal-footer">
56
+        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
57
+        <button type="button" class="btn btn-primary">Save changes</button>
58
+      </div>
59
+    </div>
60
+  </div>
61
+</div>

+ 4
- 0
Angular/src/app/pages/candidat/candidat-list/candidat-list.component.scss 查看文件

@@ -0,0 +1,4 @@
1
+.listMargin{
2
+ 
3
+    margin : 5px;
4
+}

+ 12
- 0
Angular/src/app/pages/candidat/candidat-list/candidat-list.component.ts 查看文件

@@ -19,6 +19,10 @@ export class CandidatListComponent implements OnInit {
19 19
 
20 20
     candidates: Observable<Candidate[]>;
21 21
     candidate: Candidate;
22
+    currentPage = 1;
23
+    itemsPerPage = 5;
24
+    pageSize: number;
25
+    cp: number = 1;
22 26
     constructor(private breadcrumbService: AppBreadcrumbService,private http: HttpClient, private candidatListService: candidatListService, private route: ActivatedRoute,private router: Router, private candidatService: CandidateService) {
23 27
       this.breadcrumbService.setItems([
24 28
         { label: 'Candidats' },
@@ -42,4 +46,12 @@ export class CandidatListComponent implements OnInit {
42 46
   search(){
43 47
     this.candidates = this.candidatService.search("","","");
44 48
   }
49
+
50
+  public onPageChange(pageNum: number): void {
51
+    this.pageSize = this.itemsPerPage*(pageNum - 1);
52
+  }
53
+  
54
+  public changePagesize(num: number): void {
55
+  this.itemsPerPage = this.pageSize + num;
56
+}
45 57
 }

+ 3
- 1
Angular/src/app/pages/candidat/candidat.module.ts 查看文件

@@ -8,6 +8,7 @@ import { CandidatDetailComponent } from './candidat-detail/candidat-detail.compo
8 8
 import { CandidatDetailResolver } from 'src/app/shared/resolver/candidat-detail.resolver';
9 9
 import { ReactiveFormsModule } from '@angular/forms';
10 10
 import { CandidatSidebarComponent } from './candidat-sidebar/candidat-sidebar.component';
11
+import { NgxPaginationModule } from 'ngx-pagination';
11 12
 
12 13
 
13 14
 export const routes: Routes = [
@@ -41,7 +42,8 @@ export const routes: Routes = [
41 42
   imports: [
42 43
     CommonModule,
43 44
     RouterModule.forChild(routes),
44
-    ReactiveFormsModule
45
+    ReactiveFormsModule,
46
+    NgxPaginationModule
45 47
   ],
46 48
   exports: [RouterModule]
47 49
 })

+ 18
- 0
Angular/src/assets/demo/data/candidates.json 查看文件

@@ -22,5 +22,23 @@
22 22
 			"firstName": "Gerard",
23 23
 			"lastName": "Jackson",
24 24
 			"emails": []
25
+		},
26
+		{
27
+			"id": "4",
28
+			"firstName": "Daniel",
29
+			"lastName": "Dupuy",
30
+			"emails": [
31
+				{"email":"daniel.dupuy@natan.fr", "type":"profesionnal"},
32
+				{"email":"daniel.dupuy@gmail.com", "type":"personal"}
33
+			] 
34
+		},
35
+		{
36
+			"id": "5",
37
+			"firstName": "Eric",
38
+			"lastName": "Powel",
39
+			"emails": [
40
+				{"email":"eric.powel@natan.fr", "type":"profesionnal"},
41
+				{"email":"eric.powel@gmail.com", "type":"personal"}
42
+			] 
25 43
 		}
26 44
 ]

+ 0
- 1
Angular/src/index.html 查看文件

@@ -13,7 +13,6 @@
13 13
 
14 14
     <link id="theme-css" rel="stylesheet" type="text/css" href="assets/theme/indigo/theme-light.css">
15 15
     <link id="layout-css" rel="stylesheet" type="text/css" href="assets/layout/css/layout-light.css">
16
-    <!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> -->
17 16
 </head>
18 17
 <body>
19 18
     <app-root>

+ 1
- 0
Angular/src/styles.scss 查看文件

@@ -5,3 +5,4 @@
5 5
 @import "../node_modules/@fullcalendar/daygrid/main.min.css";
6 6
 @import "../node_modules/@fullcalendar/timegrid/main.min.css";
7 7
 @import "./appdemo.scss";
8
+@import "~bootstrap/dist/css/bootstrap.css";

Powered by TurnKey Linux.