Commit 527c4368 authored by Julien's avatar Julien
Browse files

Merge remote-tracking branch 'origin/Front' into Dev

parents 6887b13c e37f809f
Pipeline #17249 failed with stages
in 1 minute and 33 seconds
This diff is collapsed.
......@@ -30,7 +30,7 @@ export const agenceRoute: Routes = [
path: 'agence',
component: AgenceComponent,
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.agence.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -42,7 +42,7 @@ export const agenceRoute: Routes = [
agence: AgenceResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.agence.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -54,7 +54,7 @@ export const agenceRoute: Routes = [
agence: AgenceResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.agence.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -66,7 +66,7 @@ export const agenceRoute: Routes = [
agence: AgenceResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.agence.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -81,7 +81,7 @@ export const agencePopupRoute: Routes = [
agence: AgenceResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.agence.home.title'
},
canActivate: [UserRouteAccessService],
......
......@@ -30,7 +30,7 @@ export const reservationRoute: Routes = [
path: 'reservation',
component: ReservationComponent,
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.reservation.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -42,7 +42,7 @@ export const reservationRoute: Routes = [
reservation: ReservationResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.reservation.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -54,7 +54,7 @@ export const reservationRoute: Routes = [
reservation: ReservationResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.reservation.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -66,7 +66,7 @@ export const reservationRoute: Routes = [
reservation: ReservationResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.reservation.home.title'
},
canActivate: [UserRouteAccessService]
......@@ -81,7 +81,7 @@ export const reservationPopupRoute: Routes = [
reservation: ReservationResolve
},
data: {
authorities: ['ROLE_USER'],
authorities: ['ROLE_ADMIN'],
pageTitle: 'myTransportApp.reservation.home.title'
},
canActivate: [UserRouteAccessService],
......
......@@ -13,6 +13,8 @@ type EntityArrayResponseType = HttpResponse<IVehicule[]>;
export class VehiculeService {
private resourceUrl = SERVER_API_URL + 'api/vehicules';
private resourceSearchUrl = SERVER_API_URL + 'api/_search/vehicules';
private resourceUrlAvailable = SERVER_API_URL + 'api/vehiculesAvailable';
private resourceUrlFlex = SERVER_API_URL + 'api/vehiculesAvailableFlex';
constructor(private http: HttpClient) {}
......@@ -33,6 +35,15 @@ export class VehiculeService {
return this.http.get<IVehicule[]>(this.resourceUrl, { params: options, observe: 'response' });
}
queryAvailable(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req);
return this.http.get<IVehicule[]>(this.resourceUrlAvailable, { params: options, observe: 'response' });
}
queryFlex(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req);
return this.http.get<IVehicule[]>(this.resourceUrlFlex, { params: options, observe: 'response' });
}
delete(id: number): Observable<HttpResponse<any>> {
return this.http.delete<any>(`${this.resourceUrl}/${id}`, { observe: 'response' });
}
......
<div class="row">
<div class="col-md-3">
<span class="hipster img-fluid rounded"></span>
<div class="list-group col-3">
<p class="text-center">Choissisez une agence :</p>
<!-- <input type="search" class="form-control" placeholder="Rechercher" (input)="onSearch($event.target.value)"> -->
<select name="ville" id="" class="form-control" (change)="filterVille($event.target.value)">
<option value="">Choissisez une ville</option>
<option *ngFor="let ville of villes" value="{{ville}}">{{ville}}</option>
</select>
<br>
<a *ngFor="let agence of filteredAgencies" href="#" class="list-group-item list-group-item-action"
(click)="onSelect(agence)" [class.active]="agence==selectedAgence">{{agence.nom}} <span class="text-muted">à {{agence.ville}}</span> </a>
</div>
<div class="col-md-9">
<h1 class="display-4" jhiTranslate="home.title">Welcome, Java Hipster!</h1>
<p class="lead" jhiTranslate="home.subtitle">This is your homepage</p>
<div [ngSwitch]="isAuthenticated()">
<div class="alert alert-success" *ngSwitchCase="true">
<span id="home-logged-message" *ngIf="account" jhiTranslate="home.logged.message"
translateValues="{username: '{{account.login}}'}"> You are logged in as user "{{account.login}}". </span>
</div>
<div class="alert alert-warning" *ngSwitchCase="false">
<span jhiTranslate="global.messages.info.authenticated.prefix">If you want to </span>
<a class="alert-link" (click)="login()" jhiTranslate="global.messages.info.authenticated.link">sign in</a><span jhiTranslate="global.messages.info.authenticated.suffix">, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").</span>
</div>
<div class="alert alert-warning" *ngSwitchCase="false">
<span jhiTranslate="global.messages.info.register.noaccount">You don't have an account yet?</span>&nbsp;
<a class="alert-link" routerLink="register" jhiTranslate="global.messages.info.register.link">Register a new account</a>
<div class="col-9">
<form action="" [style.visibility]="queryVehicules == undefined ? 'hidden' : 'visible'">
<fieldset>
<legend>Filtrer les voitures</legend>
<div class="form-row">
Disponible sur la période
<div class="col-3"><input class="form-control" id="daterange" type="text"></div> pendant au moins <div class="col-1"><input
type="number" class="form-control" name="" id="nbDays"></div> jours.
</div>
<div class="form-row">
<div class="form-group col">
<label for="inputType">Type</label>
<select name="" id="inputType" class="form-control">
<option value=""></option>
<option value="Voiture">Voiture</option>
<option value="Scooter">Scooter</option>
<option value="Velo">Velo</option>
</select>
</div>
<div class="form-group col">
<label for="inputMotor">Motorisation</label>
<select name="" id="inputMotor" class="form-control">
<option value=""></option>
<option value="ESSENCE">Essence</option>
<option value="ELECTRIQUE">Electrique</option>
</select>
</div>
</div>
<button class="btn btn-primary" (click)="filter()">Filtrer</button>
</fieldset>
</form>
<div *ngFor="let vehicule of queryVehicules" class="card border-primary" style="width: 15rem;display:inline-block;margin:5px;">
<img class="card-img-top" src="{{vehicule.path_image}}" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">{{vehicule.marque}}</h5>
<h6 class="card-subtitle mb-2 text-muted">{{vehicule.modele}}</h6>
<p class="card-text"> Prix : {{vehicule.prix}} €</p>
<p class="card-text"> {{vehicule.nbPlace}} places</p>
<a href="#/vehicule/{{vehicule.id}}/view" class="card-link">En savoir plus</a>
</div>
</div>
<p jhiTranslate="home.question">
If you have any question on JHipster:
</p>
<ul>
<li><a href="https://www.jhipster.tech/" target="_blank" rel="noopener" jhiTranslate="home.link.homepage">JHipster homepage</a></li>
<li><a href="http://stackoverflow.com/tags/jhipster/info" target="_blank" rel="noopener" jhiTranslate="home.link.stackoverflow">JHipster on Stack Overflow</a></li>
<li><a href="https://github.com/jhipster/generator-jhipster/issues?state=open" target="_blank" rel="noopener" jhiTranslate="home.link.bugtracker">JHipster bug tracker</a></li>
<li><a href="https://gitter.im/jhipster/generator-jhipster" target="_blank" rel="noopener" jhiTranslate="home.link.chat">JHipster public chat room</a></li>
<li><a href="https://twitter.com/java_hipster" target="_blank" rel="noopener" jhiTranslate="home.link.follow">follow @java_hipster on Twitter</a></li>
</ul>
<p>
<span jhiTranslate="home.like">If you like JHipster, don't forget to give us a star on</span> <a href="https://github.com/jhipster/generator-jhipster" target="_blank" rel="noopener" jhiTranslate="home.github">GitHub</a>!
</p>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiEventManager } from 'ng-jhipster';
import { Agence } from 'app/shared/model/agence.model';
import { AgenceService } from 'app/entities/agence/agence.service';
import { Vehicule } from 'app/shared/model/vehicule.model';
import { VehiculeService } from 'app/entities/vehicule/vehicule.service';
import { LoginModalService, Principal, Account } from 'app/core';
import moment = require('moment');
import * as $ from 'jquery';
import 'bootstrap-daterangepicker';
@Component({
selector: 'jhi-home',
......@@ -12,14 +19,36 @@ import { LoginModalService, Principal, Account } from 'app/core';
export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef;
private agencies: Agence[];
private filteredAgencies: Agence[];
private villes: String[];
private selectedAgence: Agence;
private vehicules: Vehicule[];
private queryVehicules: Vehicule[];
constructor(private principal: Principal, private loginModalService: LoginModalService, private eventManager: JhiEventManager) {}
constructor(
private principal: Principal,
private loginModalService: LoginModalService,
private eventManager: JhiEventManager,
private agenceService: AgenceService,
private vehiculeService: VehiculeService
) {}
ngOnInit() {
this.principal.identity().then(account => {
this.account = account;
});
this.registerAuthenticationSuccess();
this.agenceService.query().subscribe(agences => {
this.agencies = agences.body;
this.filteredAgencies = this.agencies;
this.extractVilles();
});
$('#daterange').daterangepicker({
opens: 'left'
});
(<HTMLInputElement>$('#nbDays')[0]).value = '1';
}
registerAuthenticationSuccess() {
......@@ -37,4 +66,110 @@ export class HomeComponent implements OnInit {
login() {
this.modalRef = this.loginModalService.open();
}
extractVilles() {
this.villes = [];
for (const agence of this.agencies) {
if (!this.villes.includes(agence.ville)) {
this.villes.push(agence.ville);
}
}
}
filterVille(value: String) {
console.log('changing ' + value);
this.filteredAgencies = [];
if (value === '') {
this.filteredAgencies = this.agencies;
} else {
for (const agence of this.agencies) {
if (agence.ville === value) {
this.filteredAgencies.push(agence);
}
}
}
}
onSelect(agence: Agence) {
this.selectedAgence = agence;
this.vehiculeService
.queryAvailable({
id: agence.id,
startDate: moment()
.startOf('d')
.toJSON(),
endDate: moment()
.add(1, 'd')
.startOf('d')
.toJSON()
})
.subscribe(vehicules => {
this.vehicules = vehicules.body;
this.queryVehicules = this.vehicules;
});
}
filter() {
const startDate = $('#daterange')
.data('daterangepicker')
.startDate.clone();
const endDate = $('#daterange')
.data('daterangepicker')
.endDate.clone();
const nbDays = (<HTMLInputElement>$('#nbDays')[0]).value;
this.vehiculeService
.queryFlex({
id: this.selectedAgence.id,
startDate: startDate.startOf('d').toJSON(),
endDate: endDate
.add(1, 'd')
.startOf('d')
.toJSON(),
nbJours: nbDays
})
.subscribe(vehicules => {
if (vehicules.body == null) {
this.vehicules = [];
} else {
this.vehicules = vehicules.body;
}
this.queryVehicules = this.vehicules;
const type = (<HTMLInputElement>$('#inputType')[0]).value;
if (type === 'Voiture') {
this.queryVehicules = [];
for (const vehicule of this.vehicules) {
if (vehicule.voiture !== null) {
this.queryVehicules.push(vehicule);
}
}
} else if (type === 'Scooter') {
this.queryVehicules = [];
for (const vehicule of this.vehicules) {
if (vehicule.scooter !== null) {
this.queryVehicules.push(vehicule);
}
}
} else if (type === 'Velo') {
this.queryVehicules = [];
for (const vehicule of this.vehicules) {
if (vehicule.velo !== null) {
this.queryVehicules.push(vehicule);
}
}
}
const motor = (<HTMLInputElement>$('#inputMotor')[0]).value;
if (motor !== '') {
for (let i = this.queryVehicules.length - 1; i >= 0; i--) {
if (this.queryVehicules[i].voiture !== null && this.queryVehicules[i].voiture.motorisation !== motor) {
this.queryVehicules.splice(i, 1);
} else if (this.queryVehicules[i].scooter !== null && this.queryVehicules[i].scooter.motorisation !== motor) {
this.queryVehicules.splice(i, 1);
}
}
}
});
}
}
......@@ -19,7 +19,7 @@
</a>
</li>
<!-- jhipster-needle-add-element-to-menu - JHipster will add new menu items here -->
<li *ngSwitchCase="true" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<li *jhiHasAnyAuthority="'ROLE_ADMIN'" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link dropdown-toggle" ngbDropdownToggle href="javascript:void(0);" id="entity-menu">
<span>
<fa-icon [icon]="'th-list'"></fa-icon>
......@@ -128,7 +128,7 @@
<!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
</ul>
</li>
<li *jhiHasAnyAuthority="'ROLE_USER'" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active"
<li *jhiHasAnyAuthority="['ROLE_MANAGER_AGENCE', 'ROLE_CHEF_MANAGER_AGENCE']" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active"
[routerLinkActiveOptions]="{exact: true}">
<a class="nav-link dropdown-toggle" ngbDropdownToggle href="javascript:void(0);" id="manager-menu">
<span>
......
......@@ -71,7 +71,7 @@ Logo styles
width: 70px;
display: inline-block;
vertical-align: middle;
background: url('../../../content/images/logo-jhipster.png') no-repeat center center;
background: url('../../../content/images/avatar.jpg') no-repeat center center;
background-size: contain;
}
}
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment