├── .browserslistrc ├── .editorconfig ├── .gitignore ├── .vscode ├── extensions.json ├── launch.json └── tasks.json ├── README.md ├── angular.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── accounts │ │ ├── accounts.component.css │ │ ├── accounts.component.html │ │ ├── accounts.component.spec.ts │ │ └── accounts.component.ts │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── customer-accounts │ │ ├── customer-accounts.component.css │ │ ├── customer-accounts.component.html │ │ ├── customer-accounts.component.spec.ts │ │ └── customer-accounts.component.ts │ ├── customers │ │ ├── customers.component.css │ │ ├── customers.component.html │ │ ├── customers.component.spec.ts │ │ └── customers.component.ts │ ├── model │ │ ├── account.model.ts │ │ └── customer.model.ts │ ├── navbar │ │ ├── navbar.component.css │ │ ├── navbar.component.html │ │ ├── navbar.component.spec.ts │ │ └── navbar.component.ts │ ├── new-customer │ │ ├── new-customer.component.css │ │ ├── new-customer.component.html │ │ ├── new-customer.component.spec.ts │ │ └── new-customer.component.ts │ └── services │ │ ├── accounts.service.ts │ │ └── customer.service.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css └── test.ts ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DigitalBankingWeb 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.3. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "cli": { 4 | "analytics": "09e35bad-85de-485e-9f51-275ca431b53b" 5 | }, 6 | "version": 1, 7 | "newProjectRoot": "projects", 8 | "projects": { 9 | "digital-banking-web": { 10 | "projectType": "application", 11 | "schematics": { 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:browser", 22 | "options": { 23 | "outputPath": "dist/digital-banking-web", 24 | "index": "src/index.html", 25 | "main": "src/main.ts", 26 | "polyfills": "src/polyfills.ts", 27 | "tsConfig": "tsconfig.app.json", 28 | "assets": [ 29 | "src/favicon.ico", 30 | "src/assets" 31 | ], 32 | "styles": [ 33 | "src/styles.css", 34 | "node_modules/bootstrap/dist/css/bootstrap.min.css" 35 | ], 36 | "scripts": [ 37 | "node_modules/bootstrap/dist/js/bootstrap.bundle.js" 38 | ] 39 | }, 40 | "configurations": { 41 | "production": { 42 | "budgets": [ 43 | { 44 | "type": "initial", 45 | "maximumWarning": "500kb", 46 | "maximumError": "1mb" 47 | }, 48 | { 49 | "type": "anyComponentStyle", 50 | "maximumWarning": "2kb", 51 | "maximumError": "4kb" 52 | } 53 | ], 54 | "fileReplacements": [ 55 | { 56 | "replace": "src/environments/environment.ts", 57 | "with": "src/environments/environment.prod.ts" 58 | } 59 | ], 60 | "outputHashing": "all" 61 | }, 62 | "development": { 63 | "buildOptimizer": false, 64 | "optimization": false, 65 | "vendorChunk": true, 66 | "extractLicenses": false, 67 | "sourceMap": true, 68 | "namedChunks": true 69 | } 70 | }, 71 | "defaultConfiguration": "production" 72 | }, 73 | "serve": { 74 | "builder": "@angular-devkit/build-angular:dev-server", 75 | "configurations": { 76 | "production": { 77 | "browserTarget": "digital-banking-web:build:production" 78 | }, 79 | "development": { 80 | "browserTarget": "digital-banking-web:build:development" 81 | } 82 | }, 83 | "defaultConfiguration": "development" 84 | }, 85 | "extract-i18n": { 86 | "builder": "@angular-devkit/build-angular:extract-i18n", 87 | "options": { 88 | "browserTarget": "digital-banking-web:build" 89 | } 90 | }, 91 | "test": { 92 | "builder": "@angular-devkit/build-angular:karma", 93 | "options": { 94 | "main": "src/test.ts", 95 | "polyfills": "src/polyfills.ts", 96 | "tsConfig": "tsconfig.spec.json", 97 | "karmaConfig": "karma.conf.js", 98 | "assets": [ 99 | "src/favicon.ico", 100 | "src/assets" 101 | ], 102 | "styles": [ 103 | "src/styles.css" 104 | ], 105 | "scripts": [] 106 | } 107 | } 108 | } 109 | } 110 | }, 111 | "defaultProject": "digital-banking-web" 112 | } 113 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/digital-banking-web'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "digital-banking-web", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "~13.3.0", 14 | "@angular/common": "~13.3.0", 15 | "@angular/compiler": "~13.3.0", 16 | "@angular/core": "~13.3.0", 17 | "@angular/forms": "~13.3.0", 18 | "@angular/platform-browser": "~13.3.0", 19 | "@angular/platform-browser-dynamic": "~13.3.0", 20 | "@angular/router": "~13.3.0", 21 | "bootstrap": "^5.1.3", 22 | "bootstrap-icons": "^1.8.2", 23 | "rxjs": "~7.5.0", 24 | "tslib": "^2.3.0", 25 | "zone.js": "~0.11.4" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~13.3.3", 29 | "@angular/cli": "~13.3.3", 30 | "@angular/compiler-cli": "~13.3.0", 31 | "@types/jasmine": "~3.10.0", 32 | "@types/node": "^12.11.1", 33 | "jasmine-core": "~4.0.0", 34 | "karma": "~6.3.0", 35 | "karma-chrome-launcher": "~3.1.0", 36 | "karma-coverage": "~2.1.0", 37 | "karma-jasmine": "~4.0.0", 38 | "karma-jasmine-html-reporter": "~1.7.0", 39 | "typescript": "~4.6.2" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/app/accounts/accounts.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/app/accounts/accounts.component.css -------------------------------------------------------------------------------- /src/app/accounts/accounts.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
Accounts
6 |
7 |
8 |
9 | 10 | 11 | 15 |
16 |
17 | 18 | 19 |
{{errorMessage}}
20 |
21 | 22 | Loading ... 23 | 24 |
25 | 26 |
27 | 28 | 29 |
30 |
31 | 32 | 33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
IDDateTypeAmount
{{op.id}}{{op.operationDate | date : 'dd-MM-yyyy:HH-mm-ss'}}{{op.type}}{{op.amount | number : '1.2-2'}}
47 | 52 |
53 |
54 |
55 |
56 |
57 |
58 |
Operations
59 |
60 | 61 |
62 |
63 | 64 | 65 |
66 |
67 | 68 | 69 |
70 |
71 | 72 | 73 |
74 |
75 | 76 | 77 |
78 |
79 | 80 | 81 |
82 |
83 | 84 | 85 |
86 |
87 | 88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | -------------------------------------------------------------------------------- /src/app/accounts/accounts.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AccountsComponent } from './accounts.component'; 4 | 5 | describe('AccountsComponent', () => { 6 | let component: AccountsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ AccountsComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(AccountsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/accounts/accounts.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {FormBuilder, FormGroup} from "@angular/forms"; 3 | import {AccountsService} from "../services/accounts.service"; 4 | import {catchError, Observable, throwError} from "rxjs"; 5 | import {AccountDetails} from "../model/account.model"; 6 | 7 | @Component({ 8 | selector: 'app-accounts', 9 | templateUrl: './accounts.component.html', 10 | styleUrls: ['./accounts.component.css'] 11 | }) 12 | export class AccountsComponent implements OnInit { 13 | accountFormGroup! : FormGroup; 14 | currentPage : number =0; 15 | pageSize : number =5; 16 | accountObservable! : Observable 17 | operationFromGroup! : FormGroup; 18 | errorMessage! :string ; 19 | 20 | constructor(private fb : FormBuilder, private accountService : AccountsService) { } 21 | 22 | ngOnInit(): void { 23 | this.accountFormGroup=this.fb.group({ 24 | accountId : this.fb.control('') 25 | }); 26 | this.operationFromGroup=this.fb.group({ 27 | operationType : this.fb.control(null), 28 | amount : this.fb.control(0), 29 | description : this.fb.control(null), 30 | accountDestination : this.fb.control(null) 31 | })} 32 | 33 | handleSearchAccount() { 34 | let accountId : string =this.accountFormGroup.value.accountId; 35 | this.accountObservable=this.accountService.getAccount(accountId,this.currentPage, this.pageSize).pipe( 36 | catchError(err => { 37 | this.errorMessage=err.message; 38 | return throwError(err); 39 | }) 40 | ); 41 | } 42 | 43 | gotoPage(page: number) { 44 | this.currentPage=page; 45 | this.handleSearchAccount(); 46 | } 47 | 48 | handleAccountOperation() { 49 | let accountId :string = this.accountFormGroup.value.accountId; 50 | let operationType=this.operationFromGroup.value.operationType; 51 | let amount :number =this.operationFromGroup.value.amount; 52 | let description :string =this.operationFromGroup.value.description; 53 | let accountDestination :string =this.operationFromGroup.value.accountDestination; 54 | if(operationType=='DEBIT'){ 55 | this.accountService.debit(accountId, amount,description).subscribe({ 56 | next : (data)=>{ 57 | alert("Success Credit"); 58 | this.operationFromGroup.reset(); 59 | this.handleSearchAccount(); 60 | }, 61 | error : (err)=>{ 62 | console.log(err); 63 | } 64 | }); 65 | } else if(operationType=='CREDIT'){ 66 | this.accountService.credit(accountId, amount,description).subscribe({ 67 | next : (data)=>{ 68 | alert("Success Debit"); 69 | this.operationFromGroup.reset(); 70 | this.handleSearchAccount(); 71 | }, 72 | error : (err)=>{ 73 | console.log(err); 74 | } 75 | }); 76 | } 77 | else if(operationType=='TRANSFER'){ 78 | this.accountService.transfer(accountId,accountDestination, amount,description).subscribe({ 79 | next : (data)=>{ 80 | alert("Success Transfer"); 81 | this.operationFromGroup.reset(); 82 | this.handleSearchAccount(); 83 | }, 84 | error : (err)=>{ 85 | console.log(err); 86 | } 87 | }); 88 | 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import {CustomersComponent} from "./customers/customers.component"; 4 | import {AccountsComponent} from "./accounts/accounts.component"; 5 | import {NewCustomerComponent} from "./new-customer/new-customer.component"; 6 | import {CustomerAccountsComponent} from "./customer-accounts/customer-accounts.component"; 7 | 8 | const routes: Routes = [ 9 | { path :"customers", component : CustomersComponent}, 10 | { path :"accounts", component : AccountsComponent}, 11 | { path :"new-customer", component : NewCustomerComponent}, 12 | { path :"customer-accounts/:id", component : CustomerAccountsComponent}, 13 | ]; 14 | 15 | @NgModule({ 16 | imports: [RouterModule.forRoot(routes)], 17 | exports: [RouterModule] 18 | }) 19 | export class AppRoutingModule { } 20 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'digital-banking-web'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('digital-banking-web'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement as HTMLElement; 33 | expect(compiled.querySelector('.content span')?.textContent).toContain('digital-banking-web app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'digital-banking-web'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { NavbarComponent } from './navbar/navbar.component'; 7 | import { CustomersComponent } from './customers/customers.component'; 8 | import { AccountsComponent } from './accounts/accounts.component'; 9 | import {HttpClientModule} from "@angular/common/http"; 10 | import {ReactiveFormsModule} from "@angular/forms"; 11 | import { NewCustomerComponent } from './new-customer/new-customer.component'; 12 | import { CustomerAccountsComponent } from './customer-accounts/customer-accounts.component'; 13 | 14 | @NgModule({ 15 | declarations: [ 16 | AppComponent, 17 | NavbarComponent, 18 | CustomersComponent, 19 | AccountsComponent, 20 | NewCustomerComponent, 21 | CustomerAccountsComponent 22 | ], 23 | imports: [ 24 | BrowserModule, 25 | AppRoutingModule, 26 | HttpClientModule, 27 | ReactiveFormsModule 28 | ], 29 | providers: [], 30 | bootstrap: [AppComponent] 31 | }) 32 | export class AppModule { } 33 | -------------------------------------------------------------------------------- /src/app/customer-accounts/customer-accounts.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/app/customer-accounts/customer-accounts.component.css -------------------------------------------------------------------------------- /src/app/customer-accounts/customer-accounts.component.html: -------------------------------------------------------------------------------- 1 |
2 |
{{customerId}}
3 |
{{customer | json}}
4 |
5 | -------------------------------------------------------------------------------- /src/app/customer-accounts/customer-accounts.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CustomerAccountsComponent } from './customer-accounts.component'; 4 | 5 | describe('CustomerAccountsComponent', () => { 6 | let component: CustomerAccountsComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ CustomerAccountsComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CustomerAccountsComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/customer-accounts/customer-accounts.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {ActivatedRoute, Router} from "@angular/router"; 3 | import {Customer} from "../model/customer.model"; 4 | 5 | @Component({ 6 | selector: 'app-customer-accounts', 7 | templateUrl: './customer-accounts.component.html', 8 | styleUrls: ['./customer-accounts.component.css'] 9 | }) 10 | export class CustomerAccountsComponent implements OnInit { 11 | customerId! : string ; 12 | customer! : Customer; 13 | constructor(private route : ActivatedRoute, private router :Router) { 14 | this.customer=this.router.getCurrentNavigation()?.extras.state as Customer; 15 | } 16 | 17 | ngOnInit(): void { 18 | this.customerId = this.route.snapshot.params['id']; 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/app/customers/customers.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/app/customers/customers.component.css -------------------------------------------------------------------------------- /src/app/customers/customers.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
Customers
5 |
6 |
7 |
8 |
9 | 10 | 11 | 14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 38 | 39 | 40 |
IDNameEmail
{{c.id}}{{c.name}}{{c.email}} 29 | 32 | 34 | 37 |
41 |
42 |
43 |
44 | 45 | 46 |
47 | {{errorMessage}} 48 |
49 |
50 | 51 | Loading ..... 52 | 53 |
54 |
55 | -------------------------------------------------------------------------------- /src/app/customers/customers.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { CustomersComponent } from './customers.component'; 4 | 5 | describe('CustomersComponent', () => { 6 | let component: CustomersComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ CustomersComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(CustomersComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/customers/customers.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {HttpClient} from "@angular/common/http"; 3 | import {CustomerService} from "../services/customer.service"; 4 | import {catchError, map, Observable, throwError} from "rxjs"; 5 | import {Customer} from "../model/customer.model"; 6 | import {FormBuilder, FormGroup} from "@angular/forms"; 7 | import {Router} from "@angular/router"; 8 | 9 | @Component({ 10 | selector: 'app-customers', 11 | templateUrl: './customers.component.html', 12 | styleUrls: ['./customers.component.css'] 13 | }) 14 | export class CustomersComponent implements OnInit { 15 | customers! : Observable>; 16 | errorMessage!: string; 17 | searchFormGroup : FormGroup | undefined; 18 | constructor(private customerService : CustomerService, private fb : FormBuilder, private router : Router) { } 19 | 20 | ngOnInit(): void { 21 | this.searchFormGroup=this.fb.group({ 22 | keyword : this.fb.control("") 23 | }); 24 | this.handleSearchCustomers(); 25 | } 26 | handleSearchCustomers() { 27 | let kw=this.searchFormGroup?.value.keyword; 28 | this.customers=this.customerService.searchCustomers(kw).pipe( 29 | catchError(err => { 30 | this.errorMessage=err.message; 31 | return throwError(err); 32 | }) 33 | ); 34 | } 35 | 36 | handleDeleteCustomer(c: Customer) { 37 | let conf = confirm("Are you sure?"); 38 | if(!conf) return; 39 | this.customerService.deleteCustomer(c.id).subscribe({ 40 | next : (resp) => { 41 | this.customers=this.customers.pipe( 42 | map(data=>{ 43 | let index=data.indexOf(c); 44 | data.slice(index,1) 45 | return data; 46 | }) 47 | ); 48 | }, 49 | error : err => { 50 | console.log(err); 51 | } 52 | }) 53 | } 54 | 55 | handleCustomerAccounts(customer: Customer) { 56 | this.router.navigateByUrl("/customer-accounts/"+customer.id,{state :customer}); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/app/model/account.model.ts: -------------------------------------------------------------------------------- 1 | export interface AccountDetails { 2 | accountId: string; 3 | balance: number; 4 | currentPage: number; 5 | totalPages: number; 6 | pageSize: number; 7 | accountOperationDTOS: AccountOperation[]; 8 | } 9 | 10 | export interface AccountOperation { 11 | id: number; 12 | operationDate: Date; 13 | amount: number; 14 | type: string; 15 | description: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/app/model/customer.model.ts: -------------------------------------------------------------------------------- 1 | export interface Customer { 2 | id : number; 3 | name : string; 4 | email : string; 5 | } 6 | -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/app/navbar/navbar.component.css -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.html: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NavbarComponent } from './navbar.component'; 4 | 5 | describe('NavbarComponent', () => { 6 | let component: NavbarComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ NavbarComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NavbarComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/navbar/navbar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-navbar', 5 | templateUrl: './navbar.component.html', 6 | styleUrls: ['./navbar.component.css'] 7 | }) 8 | export class NavbarComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/new-customer/new-customer.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/app/new-customer/new-customer.component.css -------------------------------------------------------------------------------- /src/app/new-customer/new-customer.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
New Customer
4 |
5 |
6 |
7 | 8 | 9 | 13 | Name is Required 14 | 15 |
16 |
17 | 18 | 19 | 23 | Email is not valid 24 | 25 |
26 | 27 |
28 |
29 |
30 |
31 | -------------------------------------------------------------------------------- /src/app/new-customer/new-customer.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NewCustomerComponent } from './new-customer.component'; 4 | 5 | describe('NewCustomerComponent', () => { 6 | let component: NewCustomerComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ NewCustomerComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NewCustomerComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/new-customer/new-customer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {FormBuilder, FormGroup, Validators} from "@angular/forms"; 3 | import {Customer} from "../model/customer.model"; 4 | import {CustomerService} from "../services/customer.service"; 5 | import {Router} from "@angular/router"; 6 | 7 | @Component({ 8 | selector: 'app-new-customer', 9 | templateUrl: './new-customer.component.html', 10 | styleUrls: ['./new-customer.component.css'] 11 | }) 12 | export class NewCustomerComponent implements OnInit { 13 | newCustomerFormGroup! : FormGroup; 14 | constructor(private fb : FormBuilder, private customerService:CustomerService, private router:Router) { } 15 | 16 | ngOnInit(): void { 17 | this.newCustomerFormGroup=this.fb.group({ 18 | name : this.fb.control(null, [Validators.required, Validators.minLength(4)]), 19 | email : this.fb.control(null,[Validators.required, Validators.email]) 20 | }); 21 | } 22 | 23 | handleSaveCustomer() { 24 | let customer:Customer=this.newCustomerFormGroup.value; 25 | this.customerService.saveCustomer(customer).subscribe({ 26 | next : data=>{ 27 | alert("Customer has been successfully saved!"); 28 | //this.newCustomerFormGroup.reset(); 29 | this.router.navigateByUrl("/customers"); 30 | }, 31 | error : err => { 32 | console.log(err); 33 | } 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/app/services/accounts.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import {HttpClient} from "@angular/common/http"; 3 | import {environment} from "../../environments/environment"; 4 | import {Observable} from "rxjs"; 5 | import {AccountDetails} from "../model/account.model"; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class AccountsService { 11 | 12 | constructor(private http : HttpClient) { } 13 | 14 | public getAccount(accountId : string, page : number, size : number):Observable{ 15 | return this.http.get(environment.backendHost+"/accounts/"+accountId+"/pageOperations?page="+page+"&size="+size); 16 | } 17 | public debit(accountId : string, amount : number, description:string){ 18 | let data={accountId : accountId, amount : amount, description : description} 19 | return this.http.post(environment.backendHost+"/accounts/debit",data); 20 | } 21 | public credit(accountId : string, amount : number, description:string){ 22 | let data={accountId : accountId, amount : amount, description : description} 23 | return this.http.post(environment.backendHost+"/accounts/credit",data); 24 | } 25 | public transfer(accountSource: string,accountDestination: string, amount : number, description:string){ 26 | let data={accountSource, accountDestination, amount, description } 27 | return this.http.post(environment.backendHost+"/accounts/transfer",data); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/app/services/customer.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import {HttpClient} from "@angular/common/http"; 3 | import {Observable} from "rxjs"; 4 | import {Customer} from "../model/customer.model"; 5 | import {environment} from "../../environments/environment"; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class CustomerService { 11 | constructor(private http:HttpClient) { } 12 | 13 | public getCustomers():Observable>{ 14 | return this.http.get>(environment.backendHost+"/customers") 15 | } 16 | public searchCustomers(keyword : string):Observable>{ 17 | return this.http.get>(environment.backendHost+"/customers/search?keyword="+keyword) 18 | } 19 | public saveCustomer(customer: Customer):Observable{ 20 | return this.http.post(environment.backendHost+"/customers",customer); 21 | } 22 | public deleteCustomer(id: number){ 23 | return this.http.delete(environment.backendHost+"/customers/"+id); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | backendHost : "http://localhost:8085" 8 | }; 9 | 10 | /* 11 | * For easier debugging in development mode, you can import the following file 12 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 13 | * 14 | * This import should be commented out in production mode because it will have a negative impact 15 | * on performance if an error is thrown. 16 | */ 17 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 18 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohamedYoussfi/digital-banking-angular-front/8618e427089f9663b13f0255597eeb3a6a28973d/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DigitalBankingWeb 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes recent versions of Safari, Chrome (including 12 | * Opera), Edge on the desktop, and iOS and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | /*************************************************************************************************** 46 | * Zone JS is required by default for Angular itself. 47 | */ 48 | import 'zone.js'; // Included with Angular CLI. 49 | 50 | 51 | /*************************************************************************************************** 52 | * APPLICATION IMPORTS 53 | */ 54 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import "~bootstrap-icons/font/bootstrap-icons.css"; 3 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().map(context); 27 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2017", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | --------------------------------------------------------------------------------