Skip to content

Commit

Permalink
Merge pull request #2338 from sap-labs-france/master-qa
Browse files Browse the repository at this point in the history
Merge master-qa
  • Loading branch information
LucasBrazi06 authored Apr 5, 2021
2 parents d00cc1e + 50d830a commit f6557e5
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 257 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2 class="dialog-title" mat-dialog-title>{{title | translate}}</h2>
<mat-dialog-content>
<div class="row" *ngIf="isAdmin">
<div class="row" *ngIf="canListUsers">
<div class="col-md-12">
<div class="form-group">
<mat-form-field>
Expand Down Expand Up @@ -42,7 +42,10 @@ <h2 class="dialog-title" mat-dialog-title>{{title | translate}}</h2>
{{"general.mandatory_field" | translate}}
</mat-error>
</mat-form-field>
</div>
<mat-error *ngIf="!userDefaultTagCar?.tag?.active">
{{"tags.not_active" | translate}}
</mat-error>
</div>
</div>
</div>
<div class="clearfix"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export class ChargingStationsStartTransactionDialogComponent implements OnInit {
public tag!: AbstractControl;
public tagID!: AbstractControl;

public userDefaultTagCar: UserDefaultTagCar;

public loggedUser: UserToken;
public isAdmin = false;
public canListUsers = false;

public constructor(
private dialog: MatDialog,
Expand All @@ -51,7 +53,7 @@ export class ChargingStationsStartTransactionDialogComponent implements OnInit {
this.title = data.title;
this.chargeBoxID = data.chargeBoxID;
this.loggedUser = centralServerService.getLoggedUser();
this.isAdmin = this.authorizationService.isAdmin();
this.canListUsers = this.authorizationService.canListUsers();
this.isCarComponentActive = this.componentService.isActive(TenantComponents.CAR);
Utils.registerValidateCloseKeyEvents(this.dialogRef,
this.startTransaction.bind(this), this.cancel.bind(this));
Expand Down Expand Up @@ -106,6 +108,7 @@ export class ChargingStationsStartTransactionDialogComponent implements OnInit {
this.spinnerService.show();
this.centralServerService.getUserDefaultTagCar(this.userID.value).subscribe((userDefaultTagCar: UserDefaultTagCar) => {
this.spinnerService.hide();
this.userDefaultTagCar = userDefaultTagCar;
// Set Tag
this.tag.setValue(userDefaultTagCar.tag ? Utils.buildTagName(userDefaultTagCar.tag) : '');
this.tagID.setValue(userDefaultTagCar.tag?.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { ConnectorTableFilter } from 'shared/table/filters/connector-table-filter';

import { AuthorizationService } from '../../../services/authorization.service';
import { CentralServerNotificationService } from '../../../services/central-server-notification.service';
Expand Down Expand Up @@ -213,7 +212,8 @@ export class ChargingStationsListTableDataSource extends TableDataSource<Chargin
headerClass: 'd-none d-xl-table-cell text-center col-10p',
class: 'd-none d-xl-table-cell text-center col-10p',
sortable: false,
formatter: (ocppVersion: string, row: ChargingStation) => `${ocppVersion} / ${row.ocppProtocol}`
formatter: (ocppVersion: string, row: ChargingStation) =>
(ocppVersion && row.ocppProtocol) ? `${ocppVersion} / ${row.ocppProtocol}` : '-'
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,20 @@ export class SiteAreaChargingStationsDataSource extends TableDataSource<Charging
}

public buildTableDef(): TableDef {
if (this.siteArea && (this.canReadSiteArea && this.canCreateSiteArea && this.canUpdateSiteArea && this.canDeleteSiteArea) ||
this.authorizationService.isSiteAdmin(this.siteArea.siteID)) {
return {
class: 'table-dialog-list',
rowSelection: {
enabled: true,
multiple: true,
},
search: {
enabled: true,
},
};
if (this.siteArea?.issuer) {
if ((this.canReadSiteArea && this.canCreateSiteArea && this.canUpdateSiteArea && this.canDeleteSiteArea) ||
this.authorizationService.isSiteAdmin(this.siteArea.siteID)) {
return {
class: 'table-dialog-list',
rowSelection: {
enabled: true,
multiple: true,
},
search: {
enabled: true,
},
};
}
}
return {
class: 'table-dialog-list',
Expand Down Expand Up @@ -134,13 +136,15 @@ export class SiteAreaChargingStationsDataSource extends TableDataSource<Charging

public buildTableActionsDef(): TableActionDef[] {
const tableActionsDef = super.buildTableActionsDef();
if (this.siteArea && ((this.canReadSiteArea && this.canCreateSiteArea && this.canUpdateSiteArea && this.canDeleteSiteArea) ||
this.authorizationService.isSiteAdmin(this.siteArea.siteID))) {
return [
this.addAction,
this.removeAction,
...tableActionsDef,
];
if (this.siteArea?.issuer) {
if (((this.canReadSiteArea && this.canCreateSiteArea && this.canUpdateSiteArea && this.canDeleteSiteArea) ||
this.authorizationService.isSiteAdmin(this.siteArea.siteID))) {
return [
this.addAction,
this.removeAction,
...tableActionsDef,
];
}
}
return tableActionsDef;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { Constants } from 'utils/Constants';

import { CentralServerService } from '../../../../../services/central-server.service';
import { DialogService } from '../../../../../services/dialog.service';
Expand Down Expand Up @@ -239,13 +240,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.push_evse_statuses_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.sendEVSEStatusesOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success > 0) {
if (response.status === Constants.REST_RESPONSE_SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.push_evse_statuses_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.push_evse_statuses_partial',
{ success: response.success, error: response.failure });
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.push_evse_statuses_error');
Expand Down Expand Up @@ -275,13 +272,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.push_tokens_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.sendTokensOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
this.messageService.showSuccessMessage('ocpiendpoints.push_tokens_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.push_tokens_partial',
{ success: response.success, error: response.failure });
if (response.status === Constants.REST_RESPONSE_SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.push_tokens_success');
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.push_tokens_error');
Expand Down Expand Up @@ -311,13 +304,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.pull_locations_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.pullLocationsOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
this.messageService.showSuccessMessage('ocpiendpoints.pull_locations_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.pull_locations_partial',
{ success: response.success, error: response.failure });
if (response.status === Constants.REST_RESPONSE_SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.pull_locations_success');
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.pull_locations_error');
Expand Down Expand Up @@ -347,13 +336,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.get_sessions_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.pullSessionsOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
this.messageService.showSuccessMessage('ocpiendpoints.get_sessions_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.get_sessions_partial',
{ success: response.success, error: response.failure });
if (response.status === Constants.REST_RESPONSE_SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.get_sessions_success');
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.get_sessions_error');
Expand Down Expand Up @@ -383,13 +368,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.pull_tokens_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.pullTokensOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
if (response.status === RestResponse.SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.pull_tokens_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.pull_tokens_partial',
{ success: response.success, error: response.failure });
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.pull_tokens_error');
Expand Down Expand Up @@ -419,13 +400,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.check_locations_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.checkLocationsOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
if (response.status === RestResponse.SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.check_locations_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.check_locations_partial',
{ success: response.success, error: response.failure });
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.check_locations_error');
Expand Down Expand Up @@ -455,13 +432,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.check_sessions_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.checkSessionsOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
this.messageService.showSuccessMessage('ocpiendpoints.check_sessions_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.check_sessions_partial',
{ success: response.success, error: response.failure });
if (response.status === RestResponse.SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.check_sessions_success');
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.check_sessions_error');
Expand Down Expand Up @@ -491,13 +464,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.check_cdrs_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.checkCdrsOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
this.messageService.showSuccessMessage('ocpiendpoints.check_cdrs_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.check_cdrs_partial',
{ success: response.success, error: response.failure });
if (response.status === RestResponse.SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.check_cdrs_success');
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.check_cdrs_error');
Expand Down Expand Up @@ -527,13 +496,9 @@ export class SettingsOcpiEndpointsDetailsTableDataSource extends TableDataSource
this.translateService.instant('ocpiendpoints.pull_cdrs_confirm', { name: ocpiendpoint.name }),
).subscribe((result) => {
if (result === ButtonType.YES) {
this.messageService.showInfoMessage('ocpiendpoints.trigger_ocpi_action');
this.centralServerService.pullCdrsOcpiEndpoint(ocpiendpoint).subscribe((response) => {
if (response.failure === 0 && response.success >= 0) {
if (response.status === RestResponse.SUCCESS) {
this.messageService.showSuccessMessage('ocpiendpoints.pull_cdrs_success', { success: response.success });
} else if (response.failure > 0 && response.success > 0) {
this.messageService.showWarningMessage('ocpiendpoints.pull_cdrs_partial',
{ success: response.success, error: response.failure });
} else {
Utils.handleError(JSON.stringify(response),
this.messageService, 'ocpiendpoints.pull_cdrs_error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ <h3 class="card-title">{{'ocpi.details' | translate}}</h3>
</mat-form-field>
</div>
</div>

<p class="font-weight-bold">{{'ocpi.logo' | translate}}</p>
<div class="row">
<div class="col-md-6">
Expand Down Expand Up @@ -114,11 +113,14 @@ <h3 class="card-title">{{'ocpi.details' | translate}}</h3>
</mat-form-field>
</div>
</div>

<!-- CPO identifier COUNTRY_CODE/PARTY_ID -->
<div class="dropdown-divider"></div>
<p class="font-weight-bold">{{'ocpi.cpo' | translate}}</p>
<div class="row">
<div class="col-md-12 mb-2">
<mat-checkbox [checked]="cpoIsActive" (change)="enableDisableCPO($event.checked)">
{{'ocpi.cpo' | translate}}
</mat-checkbox>
</div>
<div class="col-md-6">
<mat-form-field>
<input matInput type="text" [formControl]="cpoCountryCode"
Expand Down Expand Up @@ -148,11 +150,14 @@ <h3 class="card-title">{{'ocpi.details' | translate}}</h3>
</mat-form-field>
</div>
</div>

<!-- EMSP identifier COUNTRY_CODE/PARTY_ID -->
<div class="dropdown-divider"></div>
<p class="font-weight-bold">{{'ocpi.emsp' | translate}}</p>
<div class="row">
<div class="col-md-12 mb-2">
<mat-checkbox [checked]="emspIsActive" (change)="enableDisableEMSP($event.checked)">
{{'ocpi.emsp' | translate}}
</mat-checkbox>
</div>
<div class="col-md-6">
<mat-form-field>
<input matInput type="text" [formControl]="emspCountryCode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { Utils } from '../../../utils/Utils';
})
export class SettingsOcpiComponent implements OnInit {
public isActive = false;
public cpoIsActive: boolean;
public emspIsActive: boolean;

public formGroup!: FormGroup;
public logoGroup!: FormGroup;
Expand Down Expand Up @@ -144,6 +146,26 @@ export class SettingsOcpiComponent implements OnInit {
}
}

public enableDisableCPO(checked: boolean) {
const cpoFormGroup = this.formGroup.controls['cpo'] as FormGroup;
if (checked) {
cpoFormGroup.enable();
} else {
cpoFormGroup.disable();
}
cpoFormGroup.markAsDirty();
}

public enableDisableEMSP(checked: boolean) {
const emspFormGroup = this.formGroup.controls['emsp'] as FormGroup;
if (checked) {
emspFormGroup.enable();
} else {
emspFormGroup.disable();
}
emspFormGroup.markAsDirty();
}

public loadConfiguration() {
this.spinnerService.show();
this.componentService.getOcpiSettings().subscribe((settings) => {
Expand All @@ -154,12 +176,16 @@ export class SettingsOcpiComponent implements OnInit {
if (settings.ocpi.cpo) {
this.cpoCountryCode.setValue(settings.ocpi.cpo.countryCode);
this.cpoPartyID.setValue(settings.ocpi.cpo.partyID);
this.cpoIsActive = this.cpoCountryCode.value && this.cpoPartyID.value;
}
this.enableDisableCPO(this.cpoIsActive);
// EMSP identifier
if (settings.ocpi.cpo) {
if (settings.ocpi.emsp) {
this.emspCountryCode.setValue(settings.ocpi.emsp.countryCode);
this.emspPartyID.setValue(settings.ocpi.emsp.partyID);
this.emspIsActive = this.emspCountryCode.value &&this.emspPartyID.value;
}
this.enableDisableEMSP(this.emspIsActive);
// Currency
this.currency.setValue(settings.ocpi.currency);
const businessDetails = settings.ocpi.businessDetails;
Expand Down
Loading

0 comments on commit f6557e5

Please sign in to comment.