Skip to content

Commit

Permalink
feat(dojo): install prettier and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
merranleo committed May 7, 2024
1 parent 70ac6af commit 5744a13
Show file tree
Hide file tree
Showing 54 changed files with 228 additions and 204 deletions.
1 change: 1 addition & 0 deletions dojo-front/dojo-front/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To u
## Further help

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.

# dojo-immo
33 changes: 15 additions & 18 deletions dojo-front/dojo-front/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
basePath: "",
frameworks: ["jasmine", "@angular-devkit/build-angular"],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
require("karma-jasmine"),
require("karma-chrome-launcher"),
require("karma-jasmine-html-reporter"),
require("karma-coverage"),
require("@angular-devkit/build-angular/plugins/karma"),
],
client: {
jasmine: {
Expand All @@ -19,26 +19,23 @@ module.exports = function (config) {
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
suppressAll: true, // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/dojo-immobilier'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
dir: require("path").join(__dirname, "./coverage/dojo-immobilier"),
subdir: ".",
reporters: [{ type: "html" }, { type: "text-summary" }],
},
reporters: ['progress', 'kjhtml'],
reporters: ["progress", "kjhtml"],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
browsers: ["Chrome"],
singleRun: false,
restartOnFileChange: true
restartOnFileChange: true,
});
};
20 changes: 20 additions & 0 deletions dojo-front/dojo-front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dojo-front/dojo-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@angular/platform-browser": "^16.2.12",
"@angular/platform-browser-dynamic": "^16.2.12",
"@angular/router": "^16.2.12",
"prettier": "^3.2.5",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.3"
Expand All @@ -38,4 +39,4 @@
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.9.5"
}
}
}
6 changes: 3 additions & 3 deletions dojo-front/dojo-front/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from 'src/shared/guard/auth.guard';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import {InvestComponent} from "./invest/invest.component";
import {OwnedRealtiesComponent} from "./owned-realties/owned-realties.component";
import {InstructionComponent} from "./instruction/instruction.component";
import { InvestComponent } from './invest/invest.component';
import { OwnedRealtiesComponent } from './owned-realties/owned-realties.component';
import { InstructionComponent } from './instruction/instruction.component';

const routes: Routes = [
{
Expand Down
12 changes: 5 additions & 7 deletions dojo-front/dojo-front/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
imports: [RouterTestingModule],
declarations: [AppComponent],
}).compileComponents();
});

Expand All @@ -30,6 +26,8 @@ describe('AppComponent', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain('dojo-immobilier app is running!');
expect(compiled.querySelector('.content span')?.textContent).toContain(
'dojo-immobilier app is running!',
);
});
});
2 changes: 1 addition & 1 deletion dojo-front/dojo-front/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
title = 'dojo-immobilier';
Expand Down
10 changes: 5 additions & 5 deletions dojo-front/dojo-front/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import { LoginComponent } from './login/login.component';
import { AuthInterceptor } from './login/services/auth.interceptor';
import { NavbarComponent } from './navbar/navbar.component';
import { InstructionComponent } from './instruction/instruction.component';
import {MatProgressSpinnerModule} from "@angular/material/progress-spinner";
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatMenuModule } from '@angular/material/menu';
import {MatCardModule} from "@angular/material/card";
import {MatFormFieldModule} from "@angular/material/form-field";
import {MatSelectModule} from "@angular/material/select";
import {MatPaginatorModule} from "@angular/material/paginator";
import { MatCardModule } from '@angular/material/card';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { MatPaginatorModule } from '@angular/material/paginator';

registerLocaleData(localeFr);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="row">
<span class="date">{{ date | date : "shortDate" }}</span>
<span class="date">{{ date | date: "shortDate" }}</span>
<span class="label">{{ label }}</span>
<span class="value" [class.green]="value >= 0">{{
value | currency : "EUR" : "symbol" : "1.2-2" | money
value | currency: "EUR" : "symbol" : "1.2-2" | money
}}</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('TransactionComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ TransactionComponent ]
})
.compileComponents();
declarations: [TransactionComponent],
}).compileComponents();
});

beforeEach(() => {
Expand Down
6 changes: 4 additions & 2 deletions dojo-front/dojo-front/src/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div class="container">
<div class="balance">
<h1>Solde</h1>
<ng-container *ngIf="amount !=null; else emptyAmount">
<span class="amount-value">{{ amount | currency : "EUR" : "symbol" : "1.0-0" }}</span>
<ng-container *ngIf="amount != null; else emptyAmount">
<span class="amount-value">{{
amount | currency: "EUR" : "symbol" : "1.0-0"
}}</span>
</ng-container>
</div>
<div class="transactions">
Expand Down
2 changes: 1 addition & 1 deletion dojo-front/dojo-front/src/app/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@

::ng-deep {
.mat-mdc-progress-spinner {
--mdc-circular-progress-active-indicator-color:#7160ff
--mdc-circular-progress-active-indicator-color: #7160ff;
}
}
5 changes: 2 additions & 3 deletions dojo-front/dojo-front/src/app/home/home.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('HomeComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ HomeComponent ]
})
.compileComponents();
declarations: [HomeComponent],
}).compileComponents();
});

beforeEach(() => {
Expand Down
24 changes: 12 additions & 12 deletions dojo-front/dojo-front/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Component, OnInit} from '@angular/core';
import {combineLatest, Observable, tap, timer} from 'rxjs';
import {Transaction} from './interfaces/transaction.interface';
import {TransactionService} from './services/transaction.service';
import {UserService} from './services/user.service';
import { Component, OnInit } from '@angular/core';
import { combineLatest, Observable, tap, timer } from 'rxjs';
import { Transaction } from './interfaces/transaction.interface';
import { TransactionService } from './services/transaction.service';
import { UserService } from './services/user.service';

@Component({
selector: 'app-home',
Expand All @@ -11,21 +11,21 @@ import {UserService} from './services/user.service';
})
export class HomeComponent implements OnInit {
transactions$!: Observable<Transaction[]>;
amount: number | null = null
amount: number | null = null;

constructor(
private transactionService: TransactionService,
private userService: UserService
private userService: UserService,
) {}

ngOnInit() {
this.transactions$ = this.transactionService.fetchTransactions();
combineLatest(timer(7200000,7200000),this.userService.fetchUserAmount())
combineLatest(timer(5000, 5000), this.userService.fetchUserAmount())
.pipe(
tap(([_, amount])=>{
this.amount = amount
})
tap(([_, amount]) => {
this.amount = amount;
}),
)
.subscribe()
.subscribe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class TransactionService {
date: transaction.createdAt,
label: transaction.realty.label,
value: transaction.amount,
}))
)
})),
),
);
}
}
17 changes: 8 additions & 9 deletions dojo-front/dojo-front/src/app/home/services/user.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { TestBed } from '@angular/core/testing';

import { UserService } from './user.service';
import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
import {
HttpClientTestingModule,
HttpTestingController,
} from '@angular/common/http/testing';

describe('UserService', () => {
let service: UserService;
let httpTestingController: HttpTestingController;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
imports: [HttpClientTestingModule],
});
service = TestBed.inject(UserService);
httpTestingController = TestBed.inject(HttpTestingController);
Expand All @@ -22,15 +25,11 @@ describe('UserService', () => {
it('should retrieve user level', () => {
let level: number = 0;
const mockUserLevel = {
level: 1
level: 1,
};
service
.getUserLevel()
.subscribe((_level) => (level = _level));
service.getUserLevel().subscribe((_level) => (level = _level));

const req = httpTestingController.expectOne(
'/bff/user/level',
);
const req = httpTestingController.expectOne('/bff/user/level');
req.flush(mockUserLevel);

expect(level).toEqual(mockUserLevel.level);
Expand Down
5 changes: 2 additions & 3 deletions dojo-front/dojo-front/src/app/home/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import { Injectable } from '@angular/core';
import { Observable, map } from 'rxjs';
import { UserAmount } from '../interfaces/amount.interface';
import { Asset } from '../interfaces/asset.interface';
import {UserLevel} from "../interfaces/user-level.interface";
import { UserLevel } from '../interfaces/user-level.interface';
import { Score } from 'src/app/navbar/interfaces/score.interface';

@Injectable({
providedIn: 'root',
})
export class UserService {
fetchUserScore(): Observable<Score> {
return this.http
.get<Score>('/bff/user/score')
return this.http.get<Score>('/bff/user/score');
}
constructor(private http: HttpClient) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<div *ngIf="!isLoading; else loading" class="instruction-container">
<div class="player-level">
<span>Votre niveau : {{userLevel}}</span>
<span>Votre niveau : {{ userLevel }}</span>
</div>
<h2>Votre prochaine étape : </h2>
<div [innerHTML]="templateMap.get(userLevel)" class="instruction-container-body"></div>
<h2>Votre prochaine étape :</h2>
<div
[innerHTML]="templateMap.get(userLevel)"
class="instruction-container-body"
></div>
</div>

<ng-template #loading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ describe('InstructionComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ InstructionComponent ]
})
.compileComponents();
declarations: [InstructionComponent],
}).compileComponents();

fixture = TestBed.createComponent(InstructionComponent);
component = fixture.componentInstance;
Expand Down
Loading

0 comments on commit 5744a13

Please sign in to comment.