Skip to content

Commit

Permalink
start
Browse files Browse the repository at this point in the history
  • Loading branch information
eliot488995568 committed Apr 13, 2023
1 parent c986747 commit fa9f514
Show file tree
Hide file tree
Showing 40 changed files with 4,646 additions and 1,408 deletions.
2 changes: 2 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"src/assets"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/ngx-toastr/toastr.css",
"src/styles.scss"
],
"scripts": []
Expand Down
3,939 changes: 3,061 additions & 878 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^15.2.0",
"@angular/animations": "^15.2.6",
"@angular/common": "^15.2.0",
"@angular/compiler": "^15.2.0",
"@angular/core": "^15.2.0",
"@angular/fire": "^7.5.0",
"@angular/forms": "^15.2.0",
"@angular/platform-browser": "^15.2.0",
"@angular/platform-browser-dynamic": "^15.2.0",
"@angular/router": "^15.2.0",
"@fortawesome/angular-fontawesome": "^0.12.1",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"boostrap": "^2.0.0",
"bootstrap": "^5.2.3",
"firebase": "^9.9.1",
"ngx-pagination": "^6.0.3",
"ngx-toastr": "^16.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
Expand All @@ -35,4 +44,4 @@
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.9.4"
}
}
}
46 changes: 46 additions & 0 deletions src/app/add-article/add-article.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<app-navbar>
<div class="pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Add article</h1>
</div>
<form [formGroup]="articleForm" (ngSubmit)="submitArticleData()" novalidate>
<div class="row">
<div class="col-lg-5 col-md-12 col-sm-12">
<div class="row">
<div class="col-md-12 mb-3">
<label>Libelle</label>
<input type="text" formControlName="libelle" class="form-control" required />
<!-- errors-->
<p *ngIf="libelle?.touched && libelle?.invalid" class="error">
<sup>*</sup>Please provide libelle
</p>
<p *ngIf="libelle?.errors?.['minlength']" class="error">
<sup>*</sup>Libelle shouldn't be less than 2 words
</p>
</div>
<div class="col-md-12 mb-3">
<label>Short tag</label>
<input type="text" formControlName="shortTag" class="form-control" required />
</div>
</div>
<div class="row">
<div class="col-md-12 mb-3">
<label>Quantity</label>
<input type="number" formControlName="quantity" class="form-control" required />
<!-- errors-->
<p *ngIf="quantity?.touched && quantity?.invalid" class="error">
<sup>*</sup>Please provide quantity
</p>
</div>
</div>
<div class="form-group text-right">
<button type="button" class="btn btn-secondary gap-right" (click)="ResetForm()">
Reset
</button>
<button type="submit" class="btn btn-success" [disabled]="!articleForm.valid">
Add Article
</button>
</div>
</div>
</div>
</form>
</app-navbar>
47 changes: 47 additions & 0 deletions src/app/add-article/add-article.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Component, OnInit } from '@angular/core';
import { CrudService } from '../shared/crud.service';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-add-article',
templateUrl: './add-article.component.html',
})
export class AddArticleComponent implements OnInit {
public articleForm!: FormGroup;
constructor(
public crudApi: CrudService,
public fb: FormBuilder,
public toastr: ToastrService
) {}
ngOnInit() {
this.crudApi.GetArticlesList();
this.articlForm();
}
articlForm() {
this.articleForm = this.fb.group({
libelle: ['', [Validators.required, Validators.minLength(2)]],
shortTag: ['', [Validators.required]],
quantity: ['', [Validators.required]],
});
}
get libelle() {
return this.articleForm.get('libelle');
}
get shortTag() {
return this.articleForm.get('shortTag');
}
get quantity() {
return this.articleForm.get('quantity');
}
ResetForm() {
this.articleForm.reset();
}
submitArticleData() {
this.crudApi.AddArticle(this.articleForm.value);
this.toastr.success(
this.articleForm.controls['libelle'].value + ' successfully added!'
);
this.ResetForm();
}
}
24 changes: 21 additions & 3 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [];

import { SignInComponent } from './components/sign-in/sign-in.component';
import { SignUpComponent } from './components/sign-up/sign-up.component';
import { DashboardComponent } from './components/dashboard/dashboard.component';
import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component';
import { VerifyEmailComponent } from './components/verify-email/verify-email.component';
import { AddArticleComponent } from './add-article/add-article.component';
import { ArticleListComponent } from './article-list/article-list.component';
import { EditArticleComponent } from './edit-article/edit-article.component';
// route guard
import { AuthGuard } from './shared/guard/auth.guard';
const routes: Routes = [
{ path: '', redirectTo: '/sign-in', pathMatch: 'full' },
{ path: 'sign-in', component: SignInComponent },
{ path: 'register-user', component: SignUpComponent },
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard] },
{ path: 'forgot-password', component: ForgotPasswordComponent },
{ path: 'verify-email-address', component: VerifyEmailComponent },
{ path: 'register-article', component: AddArticleComponent, canActivate: [AuthGuard] },
{ path: 'view-articles', component: ArticleListComponent, canActivate: [AuthGuard] },
{ path: 'edit-article/:id', component: EditArticleComponent, canActivate: [AuthGuard] }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
Expand Down
Loading

0 comments on commit fa9f514

Please sign in to comment.