Skip to content
Snippets Groups Projects
Commit 7adb9d9d authored by narindra.rajohnso's avatar narindra.rajohnso
Browse files

Add questions functionnality and correct alert component

parent 2ff1ed93
No related branches found
No related tags found
No related merge requests found
Showing
with 57 additions and 50 deletions
...@@ -4,10 +4,10 @@ import { LoginComponent } from "./login/login.component"; ...@@ -4,10 +4,10 @@ import { LoginComponent } from "./login/login.component";
import {SignInComponent} from "./login/sign-in/sign-in.component"; import {SignInComponent} from "./login/sign-in/sign-in.component";
import {SignUpComponent} from "./login/sign-up/sign-up.component"; import {SignUpComponent} from "./login/sign-up/sign-up.component";
import {ManageComponent} from "./manage/manage.component"; import {ManageComponent} from "./manage/manage.component";
import {ListUsersComponent} from "./manage/list-users/list-users.component"; import {ListUsersComponent} from "./manage/users/list-users/list-users.component";
import {ListQuestionsComponent} from "./manage/list-questions/list-questions.component"; import {ListQuestionsComponent} from "./manage/questions/list-questions/list-questions.component";
import {CreateUserComponent} from "./manage/create-user/create-user.component"; import {CreateUserComponent} from "./manage/users/create-user/create-user.component";
import {CreateQuestionComponent} from "./manage/create-question/create-question.component"; import {CreateQuestionComponent} from "./manage/questions/create-question/create-question.component";
import {AccountDetailsComponent} from "./manage/account-details/account-details.component"; import {AccountDetailsComponent} from "./manage/account-details/account-details.component";
const routes: Routes = [ const routes: Routes = [
......
...@@ -12,16 +12,16 @@ import { ReactiveFormsModule } from '@angular/forms'; ...@@ -12,16 +12,16 @@ import { ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
import { ErrorloginComponent } from './login/errorlogin/errorlogin.component'; import { ErrorloginComponent } from './login/errorlogin/errorlogin.component';
import { ManageComponent } from './manage/manage.component'; import { ManageComponent } from './manage/manage.component';
import { ListUsersComponent } from './manage/list-users/list-users.component'; import { ListUsersComponent } from './manage/users/list-users/list-users.component';
import { ListQuestionsComponent } from './manage/list-questions/list-questions.component'; import { ListQuestionsComponent } from './manage/questions/list-questions/list-questions.component';
import { CreateUserComponent } from './manage/create-user/create-user.component'; import { CreateUserComponent } from './manage/users/create-user/create-user.component';
import { CreateQuestionComponent } from './manage/create-question/create-question.component'; import { CreateQuestionComponent } from './manage/questions/create-question/create-question.component';
import { AccountDetailsComponent } from './manage/account-details/account-details.component'; import { AccountDetailsComponent } from './manage/account-details/account-details.component';
import { AlertAddComponent } from './manage/alert-add/alert-add.component'; import { AlertAddComponent } from './manage/component/alert-add/alert-add.component';
import { LoadingComponent } from './manage/loading/loading.component'; import { LoadingComponent } from './manage/component/loading/loading.component';
import { EditUserComponent } from './manage/edit-user/edit-user.component'; import { EditUserComponent } from './manage/users/edit-user/edit-user.component';
import { EditQuestionComponent } from './manage/edit-question/edit-question.component'; import { EditQuestionComponent } from './manage/questions/edit-question/edit-question.component';
import { DeleteItemComponent } from './manage/delete-item/delete-item.component'; import { DeleteItemComponent } from './manage/component/delete-item/delete-item.component';
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import * as CryptoJS from 'crypto-js'; import * as CryptoJS from 'crypto-js';
import {AbstractControl, FormControl, FormGroup, Validators} from "@angular/forms"; import {AbstractControl, FormControl, FormGroup, Validators} from "@angular/forms";
import {User} from "../manage/list-users/user-model"; import {User} from "../manage/users/user-model";
export enum ErrorLogin { export enum ErrorLogin {
PassConfirm , PassConfirm ,
......
...@@ -11,16 +11,29 @@ export class AlertAddComponent implements OnInit { ...@@ -11,16 +11,29 @@ export class AlertAddComponent implements OnInit {
@Input() typeAlert!: string; @Input() typeAlert!: string;
ngOnInit() { ngOnInit() {
if(this.typeAlert === "add_success"){ if(this.typeAlert === "add_user_success"){
this.alertTitle="Ajout d'utilisateur"; this.alertTitle="Ajout d'utilisateur";
this.alertDescription="L'utilisateur a été ajouté avec succès"; this.alertDescription="L'utilisateur a été ajouté avec succès";
}else if(this.typeAlert === "edit_success"){ }
if(this.typeAlert === "add_question_success"){
this.alertTitle="Ajout d'une question";
this.alertDescription="La question a été ajouté avec succès";
}
if(this.typeAlert === "edit_user_success"){
this.alertTitle="Modification d'utilisateur"; this.alertTitle="Modification d'utilisateur";
this.alertDescription="L'utilisateur a été modifié avec succès" this.alertDescription="L'utilisateur a été modifié avec succès"
}else{ }
// delete success if(this.typeAlert === "edit_question_success"){
this.alertTitle="Modification d'une question";
this.alertDescription="La question a été modifié avec succès"
}
if(this.typeAlert === "delete_user_success"){
this.alertTitle="Suppression d'utilisateur"; this.alertTitle="Suppression d'utilisateur";
this.alertDescription="L'utilisateur a été supprimé avec succèes" this.alertDescription="L'utilisateur a été supprimé avec succès"
}
if(this.typeAlert === "delete_question_success"){
this.alertTitle="Suppression d'une question";
this.alertDescription="La question a été supprimé avec succès"
} }
} }
} }
...@@ -10,11 +10,16 @@ ...@@ -10,11 +10,16 @@
</svg> </svg>
</div> </div>
<div class="ml-3"> <div class="ml-3" *ngIf="username">
<h2 class="font-semibold text-gray-800">Suppression d'un utilisateur</h2> <h2 class="font-semibold text-gray-800">Suppression d'un utilisateur</h2>
<p class="mt-2 text-sm text-gray-600 leading-relaxed">Êtes vous sûr de supprimer l'utilisateur <p class="mt-2 text-sm text-gray-600 leading-relaxed">Êtes vous sûr de supprimer l'utilisateur
"{{username}}"?</p> "{{username}}"?</p>
</div> </div>
<div class="ml-3" *ngIf="idQuestion">
<h2 class="font-semibold text-gray-800">Suppression d'une question</h2>
<p class="mt-2 text-sm text-gray-600 leading-relaxed">Êtes vous sûr de supprimer la question
"{{idQuestion}}"?</p>
</div>
</div> </div>
<div class="flex items-center mt-3"> <div class="flex items-center mt-3">
...@@ -24,7 +29,7 @@ ...@@ -24,7 +29,7 @@
</button> </button>
<button class="flex-1 px-4 py-2 ml-2 bg-red-600 hover:bg-red-700 text-white text-sm font-medium rounded-md" <button class="flex-1 px-4 py-2 ml-2 bg-red-600 hover:bg-red-700 text-white text-sm font-medium rounded-md"
(click)="deleteUser()"> (click)="deleteItem()">
Supprimer Supprimer
</button> </button>
</div> </div>
......
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import {User} from "../list-users/user-model"; import {User} from "../../users/user-model";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {LoginService} from "../../login/login.service"; import {LoginService} from "../../../login/login.service";
import {ManageService} from "../manage.service"; import {ManageService} from "../../manage.service";
import {error} from "@angular/compiler-cli/src/transformers/util"; import {error} from "@angular/compiler-cli/src/transformers/util";
@Component({ @Component({
...@@ -11,22 +11,34 @@ import {error} from "@angular/compiler-cli/src/transformers/util"; ...@@ -11,22 +11,34 @@ import {error} from "@angular/compiler-cli/src/transformers/util";
styleUrls: ['./delete-item.component.css'] styleUrls: ['./delete-item.component.css']
}) })
export class DeleteItemComponent { export class DeleteItemComponent {
@Input() username!: string @Input() username!: string;
@Input() idQuestion!: number;
@Output() closeModal: EventEmitter<string> = new EventEmitter<string>(); @Output() closeModal: EventEmitter<string> = new EventEmitter<string>();
constructor(private httpClient: HttpClient, private loginService: LoginService, private manageService: ManageService) { constructor(private httpClient: HttpClient, private loginService: LoginService, private manageService: ManageService) {
} }
deleteUser(){ deleteItem(){
if(this.username){ if(this.username){
this.manageService.deleteUser(this.username).subscribe(()=>{ this.manageService.deleteUser(this.username).subscribe(()=>{
this.closeModal.emit("delete_success") this.closeModal.emit("delete_user_success")
}, error=>{ }, error=>{
console.log("error delete user:", error); console.log("error delete user:", error);
this.closeModal.emit('error') this.closeModal.emit('error')
}) })
} }
if(this.idQuestion){
this.manageService.deleteQuestion(this.idQuestion).subscribe(()=>{
this.closeModal.emit("delete_question_success")
}, error=>{
console.log("error delete question:", error);
this.closeModal.emit('error')
})
} }
}
closeModalInterface(){ closeModalInterface(){
this.closeModal.emit(undefined); this.closeModal.emit(undefined);
} }
......
<p>create-question works!</p>
import { Component } from '@angular/core';
@Component({
selector: 'app-create-question',
templateUrl: './create-question.component.html',
styleUrls: ['./create-question.component.css']
})
export class CreateQuestionComponent {
}
<p>edit-question works!</p>
import { Component } from '@angular/core';
@Component({
selector: 'app-edit-question',
templateUrl: './edit-question.component.html',
styleUrls: ['./edit-question.component.css']
})
export class EditQuestionComponent {
}
<p>list-questions works!</p>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment