diff --git a/Frontend/quizz-game/src/app/app-routing.module.ts b/Frontend/quizz-game/src/app/app-routing.module.ts index abaec07b37ba5fdb9cc4a4fe60ab5ae339d34b86..bb70d1e5b595611dc3e85f5bd8516f05be44f0dc 100644 --- a/Frontend/quizz-game/src/app/app-routing.module.ts +++ b/Frontend/quizz-game/src/app/app-routing.module.ts @@ -4,6 +4,11 @@ import { LoginComponent } from "./login/login.component"; import {SignInComponent} from "./login/sign-in/sign-in.component"; import {SignUpComponent} from "./login/sign-up/sign-up.component"; import {ManageComponent} from "./manage/manage.component"; +import {ListUsersComponent} from "./manage/list-users/list-users.component"; +import {ListQuestionsComponent} from "./manage/list-questions/list-questions.component"; +import {CreateUserComponent} from "./manage/create-user/create-user.component"; +import {CreateQuestionComponent} from "./manage/create-question/create-question.component"; +import {AccountDetailsComponent} from "./manage/account-details/account-details.component"; const routes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full' }, @@ -26,7 +31,36 @@ const routes: Routes = [ } ] }, - { path: ':admin/manage', component: ManageComponent } + { path: ':admin/manage', + component: ManageComponent, + children: [ + { + path: '', + redirectTo: 'list-users', + pathMatch: 'full' + }, + { + path: 'list-users', + component: ListUsersComponent + }, + { + path: 'list-questions', + component: ListQuestionsComponent + }, + { + path: 'create-user', + component: CreateUserComponent + }, + { + path: 'create-question', + component: CreateQuestionComponent + }, + { + path: 'account-details', + component: AccountDetailsComponent + } + ] + } ]; diff --git a/Frontend/quizz-game/src/app/app.module.ts b/Frontend/quizz-game/src/app/app.module.ts index 29cd8ebc75b244a2dcd21f266f55b2554de7239f..abf8b4abcd0a63e5c3cdc0ba431461889dbaf06e 100644 --- a/Frontend/quizz-game/src/app/app.module.ts +++ b/Frontend/quizz-game/src/app/app.module.ts @@ -6,12 +6,18 @@ import { AppComponent } from './app.component'; import { SignInComponent } from './login/sign-in/sign-in.component'; import { SignUpComponent } from './login/sign-up/sign-up.component'; import { LoginComponent } from './login/login.component'; -import {CommonModule} from "@angular/common"; +import {CommonModule, NgOptimizedImage} from "@angular/common"; import { FormsModule } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { ErrorloginComponent } from './login/errorlogin/errorlogin.component'; import { ManageComponent } from './manage/manage.component'; +import { ListUsersComponent } from './manage/list-users/list-users.component'; +import { ListQuestionsComponent } from './manage/list-questions/list-questions.component'; +import { CreateUserComponent } from './manage/create-user/create-user.component'; +import { CreateQuestionComponent } from './manage/create-question/create-question.component'; +import { AccountDetailsComponent } from './manage/account-details/account-details.component'; +import { AlertAddComponent } from './manage/alert-add/alert-add.component'; @@ -22,7 +28,13 @@ import { ManageComponent } from './manage/manage.component'; SignUpComponent, LoginComponent, ErrorloginComponent, - ManageComponent + ManageComponent, + ListUsersComponent, + ListQuestionsComponent, + CreateUserComponent, + CreateQuestionComponent, + AccountDetailsComponent, + AlertAddComponent ], imports: [ BrowserModule, @@ -30,7 +42,8 @@ import { ManageComponent } from './manage/manage.component'; CommonModule, FormsModule, ReactiveFormsModule, - HttpClientModule + HttpClientModule, + NgOptimizedImage ], providers: [], bootstrap: [AppComponent] diff --git a/Frontend/quizz-game/src/app/login/login.service.ts b/Frontend/quizz-game/src/app/login/login.service.ts index 06bf2a25c9e3f6aa4bcf9e4b17e52a9b11e2b7c7..9aab1e6bb4be38c22edecdc32c39d96295b481b7 100644 --- a/Frontend/quizz-game/src/app/login/login.service.ts +++ b/Frontend/quizz-game/src/app/login/login.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import * as CryptoJS from 'crypto-js'; +import {FormControl, FormGroup, Validators} from "@angular/forms"; export enum ErrorLogin { PassConfirm , @@ -28,4 +29,32 @@ export class LoginService { const hash = CryptoJS.SHA256(password); return hash.toString(CryptoJS.enc.Base64); } + + formDataCreate():FormGroup{ + return new FormGroup({ + username: new FormControl(null, { + updateOn: 'change', + validators: [Validators.required], + }), + firstname: new FormControl(null, { + updateOn: 'change', + validators: [Validators.required], + }), + lastname: new FormControl(null, { + updateOn: 'change', + validators: [Validators.required], + }), + email: new FormControl(null, { + updateOn: 'change', + validators: [Validators.required], + }), + password: new FormControl(null, { + updateOn: 'change', + validators: [Validators.required], + }), + accountType: new FormControl("User", { + updateOn: 'change' + }) + }); + } } diff --git a/Frontend/quizz-game/src/app/login/sign-up/sign-up.component.ts b/Frontend/quizz-game/src/app/login/sign-up/sign-up.component.ts index 8a6a3feb8160c382541fe36a87d8fcd7482eeb46..e96e5f6da91a5d60b3c313d7f50539787bad9787 100644 --- a/Frontend/quizz-game/src/app/login/sign-up/sign-up.component.ts +++ b/Frontend/quizz-game/src/app/login/sign-up/sign-up.component.ts @@ -16,29 +16,7 @@ export class SignUpComponent{ ngOnInit() { this.errorOccured=false; - this.formData = new FormGroup({ - username: new FormControl(null, { - updateOn: 'change', - validators: [Validators.required], - }), - firstname: new FormControl(null, { - updateOn: 'change', - validators: [Validators.required], - }), - lastname: new FormControl(null, { - updateOn: 'change', - validators: [Validators.required], - }), - email: new FormControl(null, { - updateOn: 'change', - validators: [Validators.required], - }), - password: new FormControl(null, { - updateOn: 'change', - validators: [Validators.required], - }), - accountType: new FormControl(0) - }); + this.formData = this.loginService.formDataCreate(); } @@ -53,6 +31,7 @@ export class SignUpComponent{ return; } this.formData.value.password = this.loginService.hashPassword(this.formData.value.password); + this.formData.value.accountType=0; this.httpClient.post<any>('http://localhost:30992/api/v1/guest/create-account', this.formData.value).subscribe( response => { console.log(response); // Affiche la réponse du serveur dans la console diff --git a/Frontend/quizz-game/src/app/manage/account-details/account-details.component.css b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Frontend/quizz-game/src/app/manage/account-details/account-details.component.html b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.html new file mode 100644 index 0000000000000000000000000000000000000000..8eeff2890dd4d0e1e5b4e488672eeb099b0a554e --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.html @@ -0,0 +1 @@ +<p>account-details works!</p> diff --git a/Frontend/quizz-game/src/app/manage/account-details/account-details.component.spec.ts b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c36bff0212d2ba2ff38e9a59d89c9a5f1b56d09 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AccountDetailsComponent } from './account-details.component'; + +describe('AccountDetailsComponent', () => { + let component: AccountDetailsComponent; + let fixture: ComponentFixture<AccountDetailsComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [AccountDetailsComponent] + }); + fixture = TestBed.createComponent(AccountDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/account-details/account-details.component.ts b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c88a7437c41fbbc896e1964be76c1126b856fbd --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/account-details/account-details.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-account-details', + templateUrl: './account-details.component.html', + styleUrls: ['./account-details.component.css'] +}) +export class AccountDetailsComponent { + +} diff --git a/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.css b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.html b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.html new file mode 100644 index 0000000000000000000000000000000000000000..3c83561f845cfdc074fcb2a61b5697aeb4fb858b --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.html @@ -0,0 +1,31 @@ +<div + role="alert" + class="rounded-xl border border-gray-100 bg-white p-4 shadow-xl" +> + <div class="flex items-start gap-4"> + <span class="text-green-600"> + <svg + xmlns="http://www.w3.org/2000/svg" + fill="none" + viewBox="0 0 24 24" + stroke-width="1.5" + stroke="currentColor" + class="h-6 w-6" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" + /> + </svg> + </span> + + <div class="flex-1"> + <strong class="block font-medium text-gray-900"> Ajout d'utilisateur </strong> + + <p class="mt-1 text-sm text-gray-700"> + L'utilisateur a été ajouté avec succès + </p> + </div> + </div> +</div> diff --git a/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.spec.ts b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d830e6183b456b8769cd9b052f782999d2c2793 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AlertAddComponent } from './alert-add.component'; + +describe('AlertAddComponent', () => { + let component: AlertAddComponent; + let fixture: ComponentFixture<AlertAddComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [AlertAddComponent] + }); + fixture = TestBed.createComponent(AlertAddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.ts b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed9dd8f3c38ccc67929021aa60df76efbd679c89 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/alert-add/alert-add.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-alert-add', + templateUrl: './alert-add.component.html', + styleUrls: ['./alert-add.component.css'] +}) +export class AlertAddComponent { + +} diff --git a/Frontend/quizz-game/src/app/manage/create-question/create-question.component.css b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Frontend/quizz-game/src/app/manage/create-question/create-question.component.html b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.html new file mode 100644 index 0000000000000000000000000000000000000000..ab200b5875b1ec5448109150ab21e20a86aae4c9 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.html @@ -0,0 +1 @@ +<p>create-question works!</p> diff --git a/Frontend/quizz-game/src/app/manage/create-question/create-question.component.spec.ts b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ad0b50e1077a689570406915367a7c2d6c02e56 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CreateQuestionComponent } from './create-question.component'; + +describe('CreateQuestionComponent', () => { + let component: CreateQuestionComponent; + let fixture: ComponentFixture<CreateQuestionComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CreateQuestionComponent] + }); + fixture = TestBed.createComponent(CreateQuestionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/create-question/create-question.component.ts b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8dd2289634db24e8e838939a252f01019f2b685 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/create-question/create-question.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-create-question', + templateUrl: './create-question.component.html', + styleUrls: ['./create-question.component.css'] +}) +export class CreateQuestionComponent { + +} diff --git a/Frontend/quizz-game/src/app/manage/create-user/create-user.component.css b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Frontend/quizz-game/src/app/manage/create-user/create-user.component.html b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.html new file mode 100644 index 0000000000000000000000000000000000000000..f880057676fa33f4d43ea7f00cdad101a59a7ede --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.html @@ -0,0 +1,78 @@ +<div + class="overflow-x-hidden overflow-y-auto fixed top-4 left-0 right-0 md:inset-0 z-50 justify-center items-center h-modal sm:h-full"> + <div class="relative w-full max-w-2xl px-4 h-full md:h-auto"> + <!-- Modal content --> + <div class="bg-white rounded-lg shadow relative"> + <!-- Modal header --> + <div class="flex items-start justify-between p-5 border-b rounded-t"> + <h3 class="text-xl font-semibold"> + Ajouter un utilisateur + </h3> + <button type="button" + class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center"> + <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> + <path fill-rule="evenodd" + d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" + clip-rule="evenodd"></path> + </svg> + </button> + </div> + <!-- Modal body --> + <form [formGroup]="formData" + enctype="multipart/form-data" + (submit)="addUser($event)"> + <div class="p-6 space-y-6"> + + <div class="grid grid-cols-6 gap-6"> + <div class="col-span-6 sm:col-span-3"> + <label for="first-name" class="text-sm font-medium text-gray-900 block mb-2">Prénom</label> + <input type="text" id="first-name" formControlName="firstname" + class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-cyan-600 focus:border-cyan-600 block w-full p-2.5" + placeholder="John"> + </div> + <div class="col-span-6 sm:col-span-3"> + <label for="lastname" class="text-sm font-medium text-gray-900 block mb-2">Nom de famille</label> + <input type="text" id="lastname" formControlName="lastname" + class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-cyan-600 focus:border-cyan-600 block w-full p-2.5" + placeholder="Doe"> + </div> + <div class="col-span-6 sm:col-span-3"> + <label for="email" class="text-sm font-medium text-gray-900 block mb-2">Email</label> + <input type="email" id="email" formControlName="email" + class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-cyan-600 focus:border-cyan-600 block w-full p-2.5" + placeholder="example@company.com"> + </div> + <div class="col-span-6 sm:col-span-3"> + <label for="username" class="text-sm font-medium text-gray-900 block mb-2">Nom d'utilisateur</label> + <input type="text" id="username" formControlName="username" + class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-cyan-600 focus:border-cyan-600 block w-full p-2.5" + placeholder="johndoe74"> + </div> + <div class="col-span-6 sm:col-span-3"> + <label for="password" class="text-sm font-medium text-gray-900 block mb-2">Mot de passe</label> + <input type="password" id="password" formControlName="password" + class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-cyan-600 focus:border-cyan-600 block w-full p-2.5" + placeholder="***********"> + </div> + <div class="col-span-6 sm:col-span-3"> + <label for="user" class="text-sm font-medium text-gray-900 block mb-2">Type</label> + <label for="user" class="mr-2">Utilisateur</label> + <input type="radio" id="user" formControlName="accountType" value="User" class="mr-4"> + <label for="admin" class="mr-2">Administrateur</label> + <input type="radio" id="admin" formControlName="accountType" value="Admin" class="mr-4"> + </div> + </div> + </div> + + <!-- Modal footer --> + <div class="items-center p-6 border-t border-gray-200 rounded-b"> + <button + class="text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center" + type="submit">Ajouter un utilisateur + </button> + </div> + </form> + + </div> + </div> +</div> diff --git a/Frontend/quizz-game/src/app/manage/create-user/create-user.component.spec.ts b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0078050c96e2cc87c42b8a762e2e496664b6ac95 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CreateUserComponent } from './create-user.component'; + +describe('CreateUserComponent', () => { + let component: CreateUserComponent; + let fixture: ComponentFixture<CreateUserComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CreateUserComponent] + }); + fixture = TestBed.createComponent(CreateUserComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/create-user/create-user.component.ts b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cf7eaf7af63c4932de55308826a4b48de9a5e98 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/create-user/create-user.component.ts @@ -0,0 +1,49 @@ +import {Component, EventEmitter, OnInit, Output} from '@angular/core'; +import {FormControl, FormGroup, Validators} from "@angular/forms"; +import {ErrorLogin, LoginService} from "../../login/login.service"; +import {HttpClient} from "@angular/common/http"; +import {ManageService} from "../manage.service"; + +@Component({ + selector: 'app-create-user', + templateUrl: './create-user.component.html', + styleUrls: ['./create-user.component.css'] +}) +export class CreateUserComponent implements OnInit{ + formData!: FormGroup; + errorOccured!: boolean; + selectedRadio!:string; + @Output() closeModal: EventEmitter<void> = new EventEmitter<void>(); + + constructor(private httpClient: HttpClient, private loginService: LoginService, private manageService: ManageService) { + } + + ngOnInit() { + this.errorOccured=false; + this.formData = this.loginService.formDataCreate(); + } + + addUser(event: Event) { + event.preventDefault(); + this.errorOccured=false; + this.formData.value.password = this.loginService.hashPassword(this.formData.value.password); + if(this.formData.value.accountType === "User") + this.formData.value.accountType = 0; + else + this.formData.value.accountType = 1; + this.httpClient.post<any>('http://localhost:30992/api/v1/admin/'+this.manageService.username+'/create-user-account', this.formData.value).subscribe( + response => { + console.log(response); // Affiche la réponse du serveur dans la console + // Effectuer une action en fonction de la réponse du serveur ici + }, + error => { + this.errorOccured=true; + if(error.error.message === "USER_EXIST"){ + this.loginService.actualError=ErrorLogin.UserNameExist; + } + } + ); + } + + +} diff --git a/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.css b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.html b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.html new file mode 100644 index 0000000000000000000000000000000000000000..21a527cb97f8608e1d50e210d3759205e62d6075 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.html @@ -0,0 +1 @@ +<p>list-questions works!</p> diff --git a/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.spec.ts b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..76b8b74fcc88647481840a11f22fb90541a388cc --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListQuestionsComponent } from './list-questions.component'; + +describe('ListQuestionsComponent', () => { + let component: ListQuestionsComponent; + let fixture: ComponentFixture<ListQuestionsComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ListQuestionsComponent] + }); + fixture = TestBed.createComponent(ListQuestionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.ts b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..e74181cb3ff3def1a68f32a09b482b2e61b53125 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/list-questions/list-questions.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-list-questions', + templateUrl: './list-questions.component.html', + styleUrls: ['./list-questions.component.css'] +}) +export class ListQuestionsComponent { + +} diff --git a/Frontend/quizz-game/src/app/manage/list-users/list-users.component.css b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Frontend/quizz-game/src/app/manage/list-users/list-users.component.html b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.html new file mode 100644 index 0000000000000000000000000000000000000000..8699a1fa3b0fc08c2fb4c1c574ed4b14589d1354 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.html @@ -0,0 +1,122 @@ +<div class="p-4 bg-white block sm:flex items-center justify-between border-b border-gray-200 lg:mt-1.5"> + <div class="mb-1 w-full"> + <div class="mb-4"> + <nav class="flex mb-5" aria-label="Breadcrumb"> + <ol class="inline-flex items-center space-x-1 md:space-x-2"> + <li class="inline-flex items-center"> + <a href="#" class="text-gray-700 hover:text-gray-900 inline-flex items-center"> + <svg class="w-5 h-5 mr-2.5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> + <path + d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"></path> + </svg> + </a> + </li> + <li> + <div class="flex items-center"> + <svg class="w-6 h-6 text-gray-400" fill="currentColor" viewBox="0 0 20 20" + xmlns="http://www.w3.org/2000/svg"> + <path fill-rule="evenodd" + d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" + clip-rule="evenodd"></path> + </svg> + <a href="#" class="text-gray-700 hover:text-gray-900 ml-1 md:ml-2 text-sm font-medium">Liste des + utilisateurs</a> + </div> + </li> + </ol> + </nav> + <h1 class="text-xl sm:text-2xl font-semibold text-gray-900">All users</h1> + </div> + <div class="sm:flex"> + <div class="hidden sm:flex items-center sm:divide-x sm:divide-gray-100 mb-3 sm:mb-0"> + <form class="lg:pr-3" action="#" method="GET"> + <label for="users-search" class="sr-only">Search</label> + <div class="mt-1 relative lg:w-64 xl:w-96"> + <input type="text" name="email" id="users-search" + class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-cyan-600 focus:border-cyan-600 block w-full p-2.5" + placeholder="Search for users"> + </div> + </form> + </div> + <div class="flex items-center space-x-2 sm:space-x-3 ml-auto"> + <button type="button" (click)="addUser()" + class="w-1/2 text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium inline-flex items-center justify-center rounded-lg text-sm px-3 py-2 text-center sm:w-auto"> + <svg class="-ml-1 mr-2 h-6 w-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> + <path fill-rule="evenodd" + d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" + clip-rule="evenodd"></path> + </svg> + Ajouter un utilisateur + </button> + </div> + </div> + </div> +</div> +<div class="flex flex-col w-screen"> + <div class="overflow-x-auto"> + <div class="align-middle inline-block min-w-full"> + <div class="shadow overflow-hidden"> + <table class="table-fixed min-w-full divide-y divide-gray-200"> + <thead class="bg-gray-100"> + <tr> + <th scope="col" class="p-4 text-left text-xs font-medium text-gray-500 uppercase"> + Name + </th> + <th scope="col" class="p-4 text-left text-xs font-medium text-gray-500 uppercase"> + Position + </th> + <th scope="col" class="p-4 text-left text-xs font-medium text-gray-500 uppercase"> + Country + </th> + <th scope="col" class="p-4 text-left text-xs font-medium text-gray-500 uppercase"> + Status + </th> + <th scope="col" class="p-4"> + </th> + </tr> + </thead> + <tbody class="bg-white divide-y divide-gray-200"> + <tr class="hover:bg-gray-100" > + <td class="p-4 flex items-center whitespace-nowrap space-x-6 mr-12 lg:mr-0"> + <div class="text-sm font-normal text-gray-500"> + <div class="text-base font-semibold text-gray-900">Nom</div> + <div class="text-sm font-normal text-gray-500">Email</div> + </div> + </td> + <td class="p-4 whitespace-nowrap text-base font-medium text-gray-900">Job</td> + <td class="p-4 whitespace-nowrap text-base font-medium text-gray-900">Pays</td> + <td class="p-4 whitespace-nowrap text-base font-normal text-gray-900"> + <div class="flex items-center"> + Active + <div class="h-2.5 w-2.5 rounded-full bg-green-400 mr-2"></div> + </div> + </td> + <td class="p-4 whitespace-nowrap space-x-2"> + <button type="button" data-modal-toggle="user-modal" + class="text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm inline-flex items-center px-3 py-2 text-center"> + <svg class="mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> + <path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path> + <path fill-rule="evenodd" + d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" + clip-rule="evenodd"></path> + </svg> + Edit user + </button> + <button type="button" data-modal-toggle="delete-user-modal" + class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:ring-red-300 font-medium rounded-lg text-sm inline-flex items-center px-3 py-2 text-center"> + <svg class="mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> + <path fill-rule="evenodd" + d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" + clip-rule="evenodd"></path> + </svg> + Delete user + </button> + </td> + </tr> + </tbody> + </table> + </div> + </div> + </div> +</div> +<app-create-user *ngIf="modalUser" (closeModal)="closeModal()"></app-create-user> diff --git a/Frontend/quizz-game/src/app/manage/list-users/list-users.component.spec.ts b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e74f872fcb09cceecdff1a159db9837a2af68da --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListUsersComponent } from './list-users.component'; + +describe('ListUsersComponent', () => { + let component: ListUsersComponent; + let fixture: ComponentFixture<ListUsersComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ListUsersComponent] + }); + fixture = TestBed.createComponent(ListUsersComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/list-users/list-users.component.ts b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..166214fb870ea99b706c0b60e42955c92141789f --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/list-users/list-users.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-list-users', + templateUrl: './list-users.component.html', + styleUrls: ['./list-users.component.css'] +}) +export class ListUsersComponent { + modalUser=false; + constructor() { + } + + addUser(){ + this.modalUser=true; + } + + closeModal(){ + + } +} diff --git a/Frontend/quizz-game/src/app/manage/manage.component.html b/Frontend/quizz-game/src/app/manage/manage.component.html index f923a4f806b9d61181650e949b58b9c8c6418be1..8eb972f13b8bd015dcd637c1e55fc6fc9f826e86 100644 --- a/Frontend/quizz-game/src/app/manage/manage.component.html +++ b/Frontend/quizz-game/src/app/manage/manage.component.html @@ -1,37 +1,43 @@ -<div class="w-1/4 flex h-screen flex-col justify-between border-e bg-white"> - <div class="px-4 py-6"> +<div class="absolute top-5 left-0 right-0 flex items-center justify-center h-16"> + <app-alert-add></app-alert-add> +</div> + + +<div class="flex h-screen"> + <div class="w-1/4 flex h-screen flex-col justify-between border-e bg-white"> + <div class="px-4 py-6"> <span class="grid h-10 w-32 place-content-center rounded-lg bg-gray-100 text-xs text-gray-600" > Logo </span> - <nav aria-label="Main Nav" class="mt-6 flex flex-col space-y-1"> + <nav aria-label="Main Nav" class="mt-6 flex flex-col space-y-1"> - <details class="group [&_summary::-webkit-details-marker]:hidden"> - <summary - class="flex cursor-pointer items-center justify-between rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <div class="flex items-center gap-2"> - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" - > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" - /> - </svg> + <details class="group [&_summary::-webkit-details-marker]:hidden"> + <summary + class="flex cursor-pointer items-center justify-between rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" + > + <div class="flex items-center gap-2"> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" + /> + </svg> - <span class="text-sm font-medium"> Gestion d'utilisateurs </span> - </div> + <span class="text-sm font-medium"> Gestion d'utilisateurs </span> + </div> - <span class="shrink-0 transition duration-300 group-open:-rotate-180"> + <span class="shrink-0 transition duration-300 group-open:-rotate-180"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" @@ -45,79 +51,79 @@ /> </svg> </span> - </summary> + </summary> - <nav aria-label="Users Manage Nav" class="mt-2 flex flex-col px-4"> - <a - href="#" - class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" + <nav aria-label="Users Manage Nav" class="mt-2 flex flex-col px-4"> + <a + routerLink="./list-users" + class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636" - /> - </svg> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636" + /> + </svg> - <span class="text-sm font-medium"> Liste des utilisateurs </span> - </a> + <span class="text-sm font-medium"> Liste des utilisateurs </span> + </a> - <a - href="#" - class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" + <a + routerLink="./create-user" + class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" - /> - </svg> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" + /> + </svg> - <span class="text-sm font-medium"> Créer un utilisateur </span> - </a> - </nav> - </details> + <span class="text-sm font-medium"> Créer un utilisateur </span> + </a> + </nav> + </details> - <details class="group [&_summary::-webkit-details-marker]:hidden"> - <summary - class="flex cursor-pointer items-center justify-between rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <div class="flex items-center gap-2"> - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" - > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" - /> - </svg> + <details class="group [&_summary::-webkit-details-marker]:hidden"> + <summary + class="flex cursor-pointer items-center justify-between rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" + > + <div class="flex items-center gap-2"> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" + /> + </svg> - <span class="text-sm font-medium"> Gestion des questions </span> - </div> + <span class="text-sm font-medium"> Gestion des questions </span> + </div> - <span class="shrink-0 transition duration-300 group-open:-rotate-180"> + <span class="shrink-0 transition duration-300 group-open:-rotate-180"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" @@ -131,80 +137,80 @@ /> </svg> </span> - </summary> + </summary> - <nav aria-label="Users Manage Nav" class="mt-2 flex flex-col px-4"> - <a - href="#" - class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" + <nav aria-label="Users Manage Nav" class="mt-2 flex flex-col px-4"> + <a + routerLink="./list-questions" + class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636" - /> - </svg> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636" + /> + </svg> - <span class="text-sm font-medium"> Liste des questions </span> - </a> + <span class="text-sm font-medium"> Liste des questions </span> + </a> - <a - href="#" - class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" + <a + routerLink="./create-question" + class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" - /> - </svg> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" + /> + </svg> - <span class="text-sm font-medium"> Créer une question </span> - </a> - </nav> - </details> + <span class="text-sm font-medium"> Créer une question </span> + </a> + </nav> + </details> - <details class="group [&_summary::-webkit-details-marker]:hidden"> - <summary - class="flex cursor-pointer items-center justify-between rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <div class="flex items-center gap-2"> - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" - > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" - /> - </svg> + <details class="group [&_summary::-webkit-details-marker]:hidden"> + <summary + class="flex cursor-pointer items-center justify-between rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" + > + <div class="flex items-center gap-2"> + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" + /> + </svg> - <span class="text-sm font-medium"> Account </span> - </div> + <span class="text-sm font-medium"> Account </span> + </div> - <span class="shrink-0 transition duration-300 group-open:-rotate-180"> + <span class="shrink-0 transition duration-300 group-open:-rotate-180"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" @@ -218,35 +224,12 @@ /> </svg> </span> - </summary> + </summary> - <nav aria-label="Account Nav" class="mt-2 flex flex-col px-4"> - <a - href="#" - class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" - > - <svg - xmlns="http://www.w3.org/2000/svg" - class="h-5 w-5 opacity-75" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - stroke-width="2" - > - <path - stroke-linecap="round" - stroke-linejoin="round" - d="M10 6H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V8a2 2 0 00-2-2h-5m-4 0V5a2 2 0 114 0v1m-4 0a2 2 0 104 0m-5 8a2 2 0 100-4 2 2 0 000 4zm0 0c1.306 0 2.417.835 2.83 2M9 14a3.001 3.001 0 00-2.83 2M15 11h3m-3 4h2" - /> - </svg> - - <span class="text-sm font-medium"> Details </span> - </a> - - <form action="/logout"> - <button - type="submit" - class="flex w-full items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" + <nav aria-label="Account Nav" class="mt-2 flex flex-col px-4"> + <a + routerLink="./account-details" + class="flex items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" > <svg xmlns="http://www.w3.org/2000/svg" @@ -259,34 +242,62 @@ <path stroke-linecap="round" stroke-linejoin="round" - d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" + d="M10 6H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V8a2 2 0 00-2-2h-5m-4 0V5a2 2 0 114 0v1m-4 0a2 2 0 104 0m-5 8a2 2 0 100-4 2 2 0 000 4zm0 0c1.306 0 2.417.835 2.83 2M9 14a3.001 3.001 0 00-2.83 2M15 11h3m-3 4h2" /> </svg> - <span class="text-sm font-medium"> Logout </span> - </button> - </form> - </nav> - </details> - </nav> - </div> + <span class="text-sm font-medium"> Details </span> + </a> - <div class="sticky inset-x-0 bottom-0 border-t border-gray-100"> - <a href="#" class="flex items-center gap-2 bg-white p-4 hover:bg-gray-50"> - <img - alt="Man" - src="https://images.unsplash.com/photo-1600486913747-55e5470d6f40?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" - class="h-10 w-10 rounded-full object-cover" - /> + <form action="/logout"> + <button + type="submit" + class="flex w-full items-center gap-2 rounded-lg px-4 py-2 text-gray-500 hover:bg-gray-100 hover:text-gray-700" + > + <svg + xmlns="http://www.w3.org/2000/svg" + class="h-5 w-5 opacity-75" + fill="none" + viewBox="0 0 24 24" + stroke="currentColor" + stroke-width="2" + > + <path + stroke-linecap="round" + stroke-linejoin="round" + d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" + /> + </svg> - <div> - <p class="text-xs"> - <strong class="block font-medium">Eric Frusciante</strong> + <span class="text-sm font-medium"> Logout </span> + </button> + </form> + </nav> + </details> + </nav> + </div> - <span> eric@frusciante.com </span> - </p> - </div> - </a> + <div class="sticky inset-x-0 bottom-0 border-t border-gray-100"> + <a href="#" class="flex items-center gap-2 bg-white p-4 hover:bg-gray-50"> + <img + alt="Man" + src="https://images.unsplash.com/photo-1600486913747-55e5470d6f40?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" + class="h-10 w-10 rounded-full object-cover" + /> + + <div> + <p class="text-xs" #userInfo> + <strong class="block font-medium">{{userNamLast}}</strong> + + <span>{{userEm}}</span> + </p> + </div> + </a> + </div> + </div> + <div class="w-3/4 h-screen"> + <router-outlet></router-outlet> </div> </div> + diff --git a/Frontend/quizz-game/src/app/manage/manage.component.ts b/Frontend/quizz-game/src/app/manage/manage.component.ts index 70ae13a0b37b4b600a1e48e6561a272b15bbda5a..2740150c3fcf958fc69b21c13ab144a658e2f7bf 100644 --- a/Frontend/quizz-game/src/app/manage/manage.component.ts +++ b/Frontend/quizz-game/src/app/manage/manage.component.ts @@ -1,10 +1,40 @@ -import { Component } from '@angular/core'; +import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; +import {ActivatedRoute, Router} from "@angular/router"; +import {ManageService} from "./manage.service"; @Component({ selector: 'app-manage', templateUrl: './manage.component.html', styleUrls: ['./manage.component.css'] }) -export class ManageComponent { +export class ManageComponent implements OnInit { + @ViewChild('userInfo') userInfo!: ElementRef; + userNamLast = ''; + userEm: string = ''; + loading=false; + + + constructor(private actRoute: ActivatedRoute, private router: Router, private manageService: ManageService) { + } + + ngOnInit() { + this.loading=true; + this.actRoute.paramMap.subscribe((paramM) => { + if (!paramM.has('admin')) { + this.router.navigate(['/', 'login']); + return; + } + this.manageService.username = paramM.get('admin')!!; + console.log(this.manageService.username); + this.manageService.getUserInfo().then(userInfo => { + this.loading=false; + this.userNamLast=userInfo.firstname+' '+userInfo.lastname; + this.userEm=userInfo.email; + }) + + }) + } + + } diff --git a/Frontend/quizz-game/src/app/manage/manage.service.spec.ts b/Frontend/quizz-game/src/app/manage/manage.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..18d6a44d3ad27fad1d894a061d78560c7c963396 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/manage.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ManageService } from './manage.service'; + +describe('ManageService', () => { + let service: ManageService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ManageService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/Frontend/quizz-game/src/app/manage/manage.service.ts b/Frontend/quizz-game/src/app/manage/manage.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..a516d8580a98d7c9c941dec0ca1d6f7b26558971 --- /dev/null +++ b/Frontend/quizz-game/src/app/manage/manage.service.ts @@ -0,0 +1,35 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {ErrorLogin} from "../login/login.service"; + +@Injectable({ + providedIn: 'root' +}) +export class ManageService { + + constructor(private httpClient: HttpClient) { } + private _username!:string; + + get username():string{ + return this._username; + } + + set username(value: string){ + this._username=value; + } + async getUserInfo():Promise<any>{ + return new Promise<any>((resolve, reject) => { + let usernamePost = { + username: this.username + }; + this.httpClient.post<any>('http://localhost:30992/api/v1/admin/' + this.username + '/get-user', usernamePost).subscribe( + response => { + resolve(response.info_user); + }, + error => { + reject(error.error.message); + } + ); + }); + } +}