diff --git a/AngularApp/package-lock.json b/AngularApp/package-lock.json index c9a45c266ed368603e3ce4ed980b876c2060087d..9b4df25d73e6d04c60ab40d27c961090e58d324d 100644 --- a/AngularApp/package-lock.json +++ b/AngularApp/package-lock.json @@ -34,6 +34,7 @@ "hammerjs": "2.0.8", "jquery": "3.6.0", "moment": "2.29.1", + "mysql2": "^3.9.1", "perfect-scrollbar": "1.5.5", "popper.js": "1.16.1", "rxjs": "~7.5.0", @@ -46,12 +47,12 @@ "@angular/cli": "~14.2.7", "@angular/compiler-cli": "^14.2.0", "@angular/language-service": "14.2.0", - "@types/bootstrap": "4.5.0", + "@types/bootstrap": "^4.5.0", "@types/chartist": "0.11.1", "@types/google.maps": "3.47.4", "@types/jasmine": "~4.0.0", "@types/jasminewd2": "~2.0.10", - "@types/jquery": "3.5.6", + "@types/jquery": "^3.5.6", "@types/node": "^17.0.21", "codelyzer": "6.0.2", "jasmine-core": "~4.4.0", @@ -5781,6 +5782,14 @@ "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", "dev": true }, + "node_modules/denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -7389,6 +7398,14 @@ "node": ">=10" } }, + "node_modules/generate-function": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", + "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", + "dependencies": { + "is-property": "^1.0.2" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -8362,6 +8379,11 @@ "node": ">=0.10.0" } }, + "node_modules/is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==" + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -9575,6 +9597,11 @@ "node": ">=8.0" } }, + "node_modules/long": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", + "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -9981,6 +10008,62 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, + "node_modules/mysql2": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.9.1.tgz", + "integrity": "sha512-3njoWAAhGBYy0tWBabqUQcLtczZUxrmmtc2vszQUekg3kTJyZ5/IeLC3Fo04u6y6Iy5Sba7pIIa2P/gs8D3ZeQ==", + "dependencies": { + "denque": "^2.1.0", + "generate-function": "^2.3.1", + "iconv-lite": "^0.6.3", + "long": "^5.2.1", + "lru-cache": "^8.0.0", + "named-placeholders": "^1.1.3", + "seq-queue": "^0.0.5", + "sqlstring": "^2.3.2" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/mysql2/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mysql2/node_modules/lru-cache": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz", + "integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==", + "engines": { + "node": ">=16.14" + } + }, + "node_modules/named-placeholders": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.3.tgz", + "integrity": "sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==", + "dependencies": { + "lru-cache": "^7.14.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/named-placeholders/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "engines": { + "node": ">=12" + } + }, "node_modules/nanoid": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", @@ -12884,6 +12967,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/seq-queue": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz", + "integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==" + }, "node_modules/serialize-javascript": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", @@ -13266,6 +13354,14 @@ "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", "dev": true }, + "node_modules/sqlstring": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.3.tgz", + "integrity": "sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/sshpk": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", diff --git a/AngularApp/package.json b/AngularApp/package.json index 121600e0377521a0004ad2e34dea84291a6f14a0..0fe7fc123bdffce4d3c647a4fc3a54428043a55c 100644 --- a/AngularApp/package.json +++ b/AngularApp/package.json @@ -42,26 +42,26 @@ "hammerjs": "2.0.8", "jquery": "3.6.0", "moment": "2.29.1", + "mysql2": "^3.9.1", "perfect-scrollbar": "1.5.5", "popper.js": "1.16.1", "rxjs": "~7.5.0", "tslib": "^2.3.0", - "zone.js": "~0.11.4", - "web-animations-js": "2.3.2" + "web-animations-js": "2.3.2", + "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "^14.2.7", "@angular/cli": "~14.2.7", "@angular/compiler-cli": "^14.2.0", "@angular/language-service": "14.2.0", + "@types/bootstrap": "^4.5.0", + "@types/chartist": "0.11.1", + "@types/google.maps": "3.47.4", "@types/jasmine": "~4.0.0", "@types/jasminewd2": "~2.0.10", + "@types/jquery": "^3.5.6", "@types/node": "^17.0.21", - "@types/bootstrap": "4.5.0", - "@types/chartist": "0.11.1", - "@types/google.maps": "3.47.4", - "@types/jquery": "3.5.6", - "sass": "1.32.13", "codelyzer": "6.0.2", "jasmine-core": "~4.4.0", "jasmine-spec-reporter": "~7.0.0", @@ -72,6 +72,7 @@ "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0", "protractor": "7.0.0", + "sass": "1.32.13", "ts-node": "~10.9.1", "typescript": "~4.7.2" } diff --git a/AngularApp/src/app/app.routing.ts b/AngularApp/src/app/app.routing.ts index 0b160a0b3372dd599820ca31c01a389c86a1eac5..c3649106cf5f0f080c6cad01a508c24384f7b026 100644 --- a/AngularApp/src/app/app.routing.ts +++ b/AngularApp/src/app/app.routing.ts @@ -4,6 +4,8 @@ import { BrowserModule } from '@angular/platform-browser'; import { Routes, RouterModule } from '@angular/router'; import { AdminLayoutComponent } from './layouts/admin-layout/admin-layout.component'; +import * as bootstrap from "bootstrap"; +import * as $ from "jquery"; const routes: Routes =[ { diff --git a/AngularApp/src/app/card-assignment/card-assignment.component.html b/AngularApp/src/app/card-assignment/card-assignment.component.html index 119f08eec01d0ccc7ab8cb15794ddcecd13637c7..f89a0ebabd2fab7a71616330d932b41490b0c8d1 100644 --- a/AngularApp/src/app/card-assignment/card-assignment.component.html +++ b/AngularApp/src/app/card-assignment/card-assignment.component.html @@ -1,4 +1,4 @@ -<div class="card card-stats"> +<!-- <div class="card card-stats"> <div class="card-header card-header-warning card-header-icon"> <div class="card-icon"> <i class="material-icons">content_paste</i> @@ -10,4 +10,4 @@ <div class="card-footer"> <p>{{assgn.language}}</p> </div> -</div> \ No newline at end of file +</div> --> \ No newline at end of file diff --git a/AngularApp/src/app/card-assignment/card-assignment.component.ts b/AngularApp/src/app/card-assignment/card-assignment.component.ts index f9ba19065d9465ba148d2a8fd4a6d88c003a4186..7ba9179c7948db69528dfc51c4d93707d41a8538 100644 --- a/AngularApp/src/app/card-assignment/card-assignment.component.ts +++ b/AngularApp/src/app/card-assignment/card-assignment.component.ts @@ -8,7 +8,7 @@ import { Assignment } from 'app/model/assignment'; styleUrls: ['./card-assignment.component.scss'], }) export class CardAssignmentComponent implements OnInit { - @Input() assgn : Assignment; + // @Input() assgn : Assignment; constructor() { } diff --git a/AngularApp/src/app/exercise-student/exercise-student.component.ts b/AngularApp/src/app/exercise-student/exercise-student.component.ts index 59f7d85c69611ce3bdc4f5277a3d1df66b10f192..cccdd5f666fbc5db1e8c2939d7a9f77ba7455ca0 100644 --- a/AngularApp/src/app/exercise-student/exercise-student.component.ts +++ b/AngularApp/src/app/exercise-student/exercise-student.component.ts @@ -19,16 +19,16 @@ export class ExerciseStudentComponent implements OnInit { ]; dataAssignment : Assignment [] = [ - { - title: 'TCP', - description: 'Technique de compilation', - language: 'Java' - }, - { - title: 'Virtualisation', - description: 'Comprehension des VM', - language: 'C' - }, + // { + // title: 'TCP', + // description: 'Technique de compilation', + // language: 'Java' + // }, + // { + // title: 'Virtualisation', + // description: 'Comprehension des VM', + // language: 'C' + // }, ]; displayedColumns: string[] = [ @@ -212,7 +212,7 @@ export class ExerciseStudentComponent implements OnInit { filterBy(ob: HTMLSelectElement) { if (ob.value) { - this.assignmentFilter = this.dataAssignment.filter(p => p.language === ob.value); + // this.assignmentFilter = this.dataAssignment.filter(p => p.language === ob.value); } if (ob.value == 'All') { this.assignmentFilter = this.dataAssignment; diff --git a/AngularApp/src/app/model/assignment.ts b/AngularApp/src/app/model/assignment.ts index 4539f2de889fb0ecd5545c168c1d57685b5d8666..e401fff5f447b0b7fa016672d43b949570c416b0 100644 --- a/AngularApp/src/app/model/assignment.ts +++ b/AngularApp/src/app/model/assignment.ts @@ -1,5 +1,8 @@ export interface Assignment { - title : string, - description : string, - language : string + name : string, + gitLabId: string, + gitlabCreationInfo : string, + gitlabLastInfo : string, + gitlabLink : string, + gitlabLastInfoDate : string, } \ No newline at end of file diff --git a/AngularApp/src/app/table-list/table-list.component.html b/AngularApp/src/app/table-list/table-list.component.html index 1a5975754f6abdb21f4e35685135d0560d2842bf..7eeb835060839381d25562ebe77029c96c86b11a 100644 --- a/AngularApp/src/app/table-list/table-list.component.html +++ b/AngularApp/src/app/table-list/table-list.component.html @@ -16,13 +16,15 @@ </th> </thead> <tbody> - <tr *ngFor="let row of rows"> - <td>{{row.assignment.title}}</td> - <td>{{row.assignment.description}}</td> - <td>{{row.nbOfSuccess}}</td> - <td>{{row.nbExerciseCreated}}</td> + <tr *ngFor="let assignment of assignments"> + <td>{{assignment.gitlabId}}</td> + <td>{{assignment.name}}</td> + <td>{{creationInfo.description}}</td> + <td>{{creationInfo.created_at}}</td> + <td>{{lastInfo.updated_at}}</td> + <td>{{assignment.gitlabLink}}</td> <td> - <button (click)="deleteEnonce(row.assignment.title)" class="btn btn-outline-danger">Delete</button> + <button class="btn btn-outline-danger">Delete</button> </td> </tr> </tbody> diff --git a/AngularApp/src/app/table-list/table-list.component.ts b/AngularApp/src/app/table-list/table-list.component.ts index 4f52635d46f978f782416a237c3a824fd1a0f788..8ad9060955c5c6a3c9c9794de1356b237ae1ad88 100644 --- a/AngularApp/src/app/table-list/table-list.component.ts +++ b/AngularApp/src/app/table-list/table-list.component.ts @@ -1,5 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import { Assignment } from 'app/model/assignment'; import { Enonce } from 'app/model/enonce'; +import { AssignmentService } from 'services/assignment.service'; @Component({ selector: 'app-table-list', @@ -7,37 +9,29 @@ import { Enonce } from 'app/model/enonce'; styleUrls: ['./table-list.component.css'] }) export class TableListComponent implements OnInit { + assignments : Assignment[] = [] + data : [] = [] + creationInfo : JSON + lastInfo : JSON + constructor(private service : AssignmentService) { } - constructor() { } + headers : string[] = ['Gitlab ID', 'Name', 'Description', 'gitlabCreationInfo', 'Last Update', 'gitlabLink', 'Options']; - headers : string[] = ['Assignment', 'Description', 'Number of success', 'Exercises created', 'Options']; - - rows : Enonce[] = [ - { - assignment : { - title: 'TCP', - description: 'Technique de compilation', - language: 'Java' - }, - nbOfSuccess : 2, - nbExerciseCreated : 10 - }, - { - assignment : { - title: 'Virtualisation', - description: 'Comprehension des VM', - language: 'C' - }, - nbOfSuccess : 0, - nbExerciseCreated : 15 - } - ] - - deleteEnonce(title) { - this.rows = this.rows.filter((enonce) => enonce.assignment.title !== title); - console.log(this.rows); - } ngOnInit() { + this.service.getAssignments().subscribe((assignment) => { + this.assignments = assignment + for (let i = 0; i < this.assignments.length; i++) { + this.creationInfo = JSON.parse(this.assignments[i].gitlabCreationInfo) + this.lastInfo = JSON.parse(this.assignments[i].gitlabLastInfo) + console.log(this.creationInfo) + console.log(this.lastInfo) + } + }) + + } + delAssignment() { + + } } diff --git a/AngularApp/src/app/user-list/user-list.component.html b/AngularApp/src/app/user-list/user-list.component.html index 1c0997bce864305b0de5af5fe2e1d97120f6b35f..69e8d41949aef09dccf9ca276e3c4881550db213 100644 --- a/AngularApp/src/app/user-list/user-list.component.html +++ b/AngularApp/src/app/user-list/user-list.component.html @@ -1,18 +1,18 @@ <div class="main-content"> - <div class="container-fluid"> - <div class="row"> - <div class="col-md-12"> - <div class="card"> - <div class="card-header card-header-danger"> - <h4 class="card-title ">Liste utilisateurs</h4> - </div> - <div class="card-body"> - <div class="table-responsive"> - <table class="table"> - <thead class=" text-primary"> + <div class="container-fluid"> + <div class="row"> + <div class="col-md-12"> + <div class="card"> + <div class="card-header card-header-danger"> + <h4 class="card-title ">Liste utilisateurs</h4> + </div> + <div class="card-body"> + <div class="table-responsive"> + <table class="table"> + <thead class=" text-primary"> <th *ngFor="let h of headers">{{h}}</th> - </thead> - <tbody> + </thead> + <tbody> <tr *ngFor="let user of users"> <td>{{ user.gitlabUsername }}</td> <td> @@ -21,19 +21,36 @@ <mat-option *ngFor="let opt of options" value="{{opt}}">{{opt}}</mat-option> </mat-select> </mat-form-field> - <p>You selected: {{ user.role }}</p> </td> <td> - <button (click)="updUser(user.id)" class="btn btn-outline-info">Modify</button> + <button id="btnUpdModal" (click)="updateRole(user.id, user.role)" class="btn btn-outline-info">Update Role</button> + <div class="modal" id="updModal" tabindex="-1" role="dialog"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title">Confirmation</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + Votre role a été modifié + </div> + <!-- <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button> + <button type="button" class="btn btn-danger">Supprimer</button> + </div> --> + </div> + </div> + </div> </td> </tr> </tbody> - </table> - </div> - </div> - </div> - </div> - </div> - </div> - </div> - \ No newline at end of file + </table> + </div> + </div> + </div> + </div> + </div> + </div> +</div> diff --git a/AngularApp/src/app/user-list/user-list.component.ts b/AngularApp/src/app/user-list/user-list.component.ts index 5ec424f8d5c647a9232460add056de0884a02ee0..28d797d37f5cd6108b76c2b93431edacd9be085d 100644 --- a/AngularApp/src/app/user-list/user-list.component.ts +++ b/AngularApp/src/app/user-list/user-list.component.ts @@ -22,8 +22,12 @@ export class UserListComponent implements OnInit { }); } - // deleteEnonce(id) { - // this.rows = this.rows.filter((enonce) => enonce.assignment.title !== title); - // console.log(this.rows); - // } + updateRole(id : number, role : string) : void { + this.userService.updateUserRole(id, role).subscribe((upd) => { + if (upd.serverStatus == 2) { + $('#updModal').modal('show'); + } + }) + + } } diff --git a/AngularApp/src/services/assignment.service.ts b/AngularApp/src/services/assignment.service.ts index 370991c83931bc32784fbee9a4250a1546ee2930..df3626739ab89dd41de39a60fd9df52690b54b20 100644 --- a/AngularApp/src/services/assignment.service.ts +++ b/AngularApp/src/services/assignment.service.ts @@ -7,11 +7,11 @@ import { Observable } from 'rxjs'; providedIn: 'root' }) export class AssignmentService { - private baseUrl = 'http://localhost:3000'; + private baseUrl = 'http://192.168.1.156:3000'; constructor(private http: HttpClient) {} - getUsers(): Observable<Assignment[]> { + getAssignments(): Observable<Assignment[]> { return this.http.get<Assignment[]>(`${this.baseUrl}/assignments`); } } diff --git a/AngularApp/src/services/user.service.ts b/AngularApp/src/services/user.service.ts index ece9138de18903bf841d6a98f7f1d8a6d5ff8ed6..493b64fd233811f246bc97f117f3d59db75668f7 100644 --- a/AngularApp/src/services/user.service.ts +++ b/AngularApp/src/services/user.service.ts @@ -8,11 +8,17 @@ import { User } from 'app/model/user'; }) export class UserService { - private baseUrl = 'http://localhost:3000'; + private baseUrl = 'http://192.168.1.156:3000'; constructor(private http: HttpClient) {} getUsers(): Observable<User[]> { return this.http.get<User[]>(`${this.baseUrl}/users`); } + updateUserRole(userId: number, newRole: string): Observable<any> { + const body = { role: newRole }; + const url = `${this.baseUrl}/users/${userId}`; + + return this.http.put(url, body); + } }