Skip to content
Snippets Groups Projects
Commit 9db23774 authored by Pegane Nestor's avatar Pegane Nestor
Browse files

FEAT #7739 Merged batch history with normal history

parent 39029a38
No related branches found
No related tags found
No related merge requests found
......@@ -14,68 +14,129 @@
[opened]="mobileQuery.matches ? false : true">
<menu-nav></menu-nav>
<mat-divider></mat-divider>
</mat-sidenav>
</mat-sidenav>
<mat-sidenav-content>
<div *ngIf="loading" style="display:flex;height:100%;">
<mat-spinner style="margin:auto;"></mat-spinner>
</div>
<mat-card *ngIf="!loading" class="card-app-content">
<div class="alert alert-warning" role="alert" [innerHTML]="lang.limitDataReached" *ngIf="limitExceeded">
</div>
<div class="row">
<div class="col-md-6 col-xs-6">
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}">
</mat-form-field>
</div>
<div class="col-md-6 col-xs-6">
<mat-paginator #paginator [length]="100" [pageSize]="10">
</mat-paginator>
</div>
</div>
<div class="row">
<div class="col-sm-6" style="padding-top:10px;">
<mat-form-field>
<input matInput [(ngModel)]="startDate" [max]="endDate" [matDatepicker]="pickerStart" placeholder="{{lang.since}}" (dateChange)="refreshHistory()" (focus)="pickerStart.open()">
<mat-datepicker-toggle matSuffix [for]="pickerStart"></mat-datepicker-toggle>
<mat-datepicker #pickerStart touchUi="true" [startAt]="startDate"></mat-datepicker>
</mat-form-field>
</div>
<div class="col-sm-6" style="padding-top:10px;">
<mat-form-field>
<input matInput [(ngModel)]="endDate" [min]="startDate" [matDatepicker]="pickerEnd" placeholder="{{lang.until}}" (dateChange)="refreshHistory()" (focus)="pickerEnd.open()">
<mat-datepicker-toggle matSuffix [for]="pickerEnd"></mat-datepicker-toggle>
<mat-datepicker #pickerEnd touchUi="true" [startAt]="endDate"></mat-datepicker>
</mat-form-field>
</div>
</div>
<mat-table #table [dataSource]="dataSource" matSort matSortActive="event_date" matSortDirection="desc">
<ng-container matColumnDef="event_date">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;">{{lang.date}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;">{{element.event_date | date : "dd/MM/y HH:mm"}}</mat-cell>
</ng-container>
<ng-container matColumnDef="event_type">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches">{{lang.event}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches"> {{element.event_type}} </mat-cell>
</ng-container>
<ng-container matColumnDef="user_id">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches">{{lang.user}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches"> {{element.user_id}} </mat-cell>
</ng-container>
<ng-container matColumnDef="info">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:3;">{{lang.description}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:3;"> {{element.info}} </mat-cell>
</ng-container>
<ng-container matColumnDef="remote_ip">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches">{{lang.ip}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches"> {{element.remote_ip}} </mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card>
<mat-tab-group (selectedIndexChange)="_setDataSource($event)">
<mat-tab label="{{lang.history}}" *ngIf="accessHistory">
<mat-card *ngIf="!loading" class="card-app-content">
<div class="alert alert-warning" role="alert" [innerHTML]="lang.limitDataReached" *ngIf="limitExceeded">
</div>
<div class="row">
<div class="col-md-6 col-xs-6">
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value, 'normal')" placeholder="{{lang.filterBy}}">
</mat-form-field>
</div>
<div class="col-md-6 col-xs-6">
<mat-paginator #paginator [length]="100" [pageSize]="10">
</mat-paginator>
</div>
</div>
<div class="row">
<div class="col-sm-6" style="padding-top:10px;">
<mat-form-field>
<input matInput [(ngModel)]="startDate" [max]="endDate" [matDatepicker]="pickerStart" placeholder="{{lang.since}}" (dateChange)="refreshHistory('normal')" (focus)="pickerStart.open()">
<mat-datepicker-toggle matSuffix [for]="pickerStart"></mat-datepicker-toggle>
<mat-datepicker #pickerStart touchUi="true" [startAt]="startDate"></mat-datepicker>
</mat-form-field>
</div>
<div class="col-sm-6" style="padding-top:10px;">
<mat-form-field>
<input matInput [(ngModel)]="endDate" [min]="startDate" [matDatepicker]="pickerEnd" placeholder="{{lang.until}}" (dateChange)="refreshHistory('normal')" (focus)="pickerEnd.open()">
<mat-datepicker-toggle matSuffix [for]="pickerEnd"></mat-datepicker-toggle>
<mat-datepicker #pickerEnd touchUi="true" [startAt]="endDate"></mat-datepicker>
</mat-form-field>
</div>
</div>
<mat-table #table [dataSource]="dataSource" matSort matSortActive="event_date" #sort="matSort" matSortDirection="desc">
<ng-container matColumnDef="event_date">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;">{{lang.date}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;">{{element.event_date | date : "dd/MM/y HH:mm"}}</mat-cell>
</ng-container>
<ng-container matColumnDef="event_type">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches">{{lang.event}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches"> {{element.event_type}} </mat-cell>
</ng-container>
<ng-container matColumnDef="user_id">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches">{{lang.user}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches"> {{element.user_id}} </mat-cell>
</ng-container>
<ng-container matColumnDef="info">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:3;">{{lang.description}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:3;"> {{element.info}} </mat-cell>
</ng-container>
<ng-container matColumnDef="remote_ip">
<mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches">{{lang.ip}}</mat-header-cell>
<mat-cell *matCellDef="let element" style="flex:1;" [class.hide-for-mobile]="mobileQuery.matches"> {{element.remote_ip}} </mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card>
</mat-tab>
<mat-tab label="{{lang.historyBatch}}" *ngIf="accessBatchHistory">
<mat-card *ngIf="!loading" class="card-app-content">
<div class="alert alert-warning" role="alert" [innerHTML]="lang.limitDataReached" *ngIf="limitExceeded"></div>
<div class="row">
<div class="col-md-6 col-xs-6">
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value, 'batch')" placeholder="{{lang.filterBy}}">
</mat-form-field>
</div>
<div class="col-md-6 col-xs-6">
<mat-paginator #batchPaginator [length]="100" [pageSize]="10">
</mat-paginator>
</div>
</div>
<div class="row">
<div class="col-sm-6" style="padding-top:10px;">
<mat-form-field>
<input matInput [(ngModel)]="batchStartDate" [max]="batchEndDate" [matDatepicker]="pickerStart" placeholder="{{lang.since}}" (dateChange)="refreshHistory('batch')" (focus)="pickerStart.open()">
<mat-datepicker-toggle matSuffix [for]="pickerStart"></mat-datepicker-toggle>
<mat-datepicker #pickerStart touchUi="true" [startAt]="batchStartDate"></mat-datepicker>
</mat-form-field>
</div>
<div class="col-sm-6" style="padding-top:10px;">
<mat-form-field>
<input matInput [(ngModel)]="batchEndDate" [min]="batchStartDate" [matDatepicker]="pickerEnd" placeholder="{{lang.until}}" (dateChange)="refreshHistory('batch')" (focus)="pickerEnd.open()">
<mat-datepicker-toggle matSuffix [for]="pickerEnd"></mat-datepicker-toggle>
<mat-datepicker #pickerEnd touchUi="true" [startAt]="batchEndDate"></mat-datepicker>
</mat-form-field>
</div>
</div>
<mat-table #table [dataSource]="batchDataSource" #batchSort="matSort" matSort matSortActive="event_date" matSortDirection="desc">
<ng-container matColumnDef="event_date">
<mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.date}}</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.event_date | date : "dd/MM/y HH:mm"}}</mat-cell>
</ng-container>
<ng-container matColumnDef="total_processed">
<mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches">{{lang.totalProcessed}}</mat-header-cell>
<mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches"> {{element.total_processed}} </mat-cell>
</ng-container>
<ng-container matColumnDef="total_errors">
<mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches">{{lang.totalErrors}}</mat-header-cell>
<mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches"> {{element.total_errors}} </mat-cell>
</ng-container>
<ng-container matColumnDef="info">
<mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.description}}</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.info}} </mat-cell>
</ng-container>
<ng-container matColumnDef="module_name">
<mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches">{{lang.module}}</mat-header-cell>
<mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches"> {{element.module_name}} </mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="batchDisplayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: batchDisplayedColumns;"></mat-row>
</mat-table>
</mat-card>
</mat-tab>
</mat-tab-group>
</mat-sidenav-content>
<mat-sidenav #snav2 [mode]="mobileQuery.matches ? 'over' : 'side'" [fixedInViewport]="mobileQuery.matches" fixedTopGap="56"
position='end' [opened]="mobileQuery.matches ? false : false">
......
......@@ -21,22 +21,41 @@ export class HistoryAdministrationComponent implements OnInit {
coreUrl : string;
lang : any = LANG;
loading : boolean = false;
loading1 : boolean = false;
loading2 : boolean = false;
limitExceeded : boolean = false;
batchLimitExceeded : boolean = false;
data : any[] = [];
batchData : any[] = [];
startDate : Date = new Date();
endDate : Date = new Date();
batchStartDate : Date = new Date();
batchEndDate : Date = new Date();
dataSource = new MatTableDataSource(this.data);
batchDataSource = new MatTableDataSource(this.batchData);
displayedColumns = ['event_date', 'event_type', 'user_id', 'info', 'remote_ip'];
batchDisplayedColumns = ['event_date', 'total_processed', 'total_errors', 'info', 'module_name'];
accessBatchHistory : boolean = true;
accessHistory : boolean = true;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
applyFilter(filterValue: string) {
@ViewChild('paginator') paginator: MatPaginator;
@ViewChild('batchPaginator') batchPaginator: MatPaginator;
@ViewChild('sort') sort: MatSort;
@ViewChild('batchSort') batchSort: MatSort;
applyFilter(filterValue: string, historyType : string) {
console.log(historyType);
filterValue = filterValue.trim();
filterValue = filterValue.toLowerCase();
this.dataSource.filter = filterValue;
if(historyType == 'normal'){
this.dataSource.filter = filterValue;
} else {
this.batchDataSource.filter = filterValue
}
}
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient) {
......@@ -46,6 +65,10 @@ export class HistoryAdministrationComponent implements OnInit {
this.startDate.setMonth(this.endDate.getMonth()-1);
this.endDate.setHours(23,59,59,59);
this.batchStartDate.setHours(0,0,0,0);
this.batchStartDate.setMonth(this.endDate.getMonth()-1);
this.batchEndDate.setHours(23,59,59,59);
this.mobileQuery = media.matchMedia('(max-width: 768px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
this.mobileQuery.addListener(this._mobileQueryListener);
......@@ -65,20 +88,70 @@ export class HistoryAdministrationComponent implements OnInit {
this.limitExceeded = data['limitExceeded'];
this.loading = false;
setTimeout(() => {
this.accessHistory = true;
this.dataSource = new MatTableDataSource(this.data);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}, 0);
}, () => {
location.href = "index.php";
}, (data: any) => {
if(data['error'].errors == 'Service forbidden'){
this.loading = false;
this.accessHistory = false;;
} else {
location.href = "index.php";
}
});
this.http.get(this.coreUrl + 'rest/batchHistories', {params: {"startDate" : (this.batchStartDate.getTime() / 1000).toString(), "endDate" : (this.batchEndDate.getTime() / 1000).toString()}})
.subscribe((data: any) => {
this.batchData = data['batchHistories'];
this.batchLimitExceeded = data['limitExceeded'];
this.loading = false;
setTimeout(() => {
this.accessBatchHistory = true;
this.batchDataSource = new MatTableDataSource(this.batchData);
this.batchDataSource.paginator = this.batchPaginator;
this.batchDataSource.sort = this.batchSort;
}, 0);
}, (data: any) => {
if(data['error'].errors == 'Service forbidden'){
this.loading = false
this.accessBatchHistory = false;
} else {
location.href = "index.php";
}
});
}
refreshHistory() {
this.startDate.setHours(0,0,0,0);
this.endDate.setHours(23,59,59,59);
ngAfterViewInit() {
this.batchDataSource.paginator = this.batchPaginator;
this.batchDataSource.sort = this.batchSort;
}
_setDataSource(indexNumber : any) {
console.log("datasource");
setTimeout(() => {
switch (indexNumber) {
case 0:
!this.dataSource.paginator ? this.dataSource.paginator = this.paginator : null;
!this.dataSource.sort ? this.dataSource.sort = this.sort : null;
break;
case 1:
!this.batchDataSource.paginator ? this.batchDataSource.paginator = this.batchPaginator : null;
!this.batchDataSource.sort ? this.batchDataSource.sort = this.batchSort : null;
}
});
}
refreshHistory(historyType : string) {
this.http.get(this.coreUrl + 'rest/histories', {params: {"startDate" : (this.startDate.getTime() / 1000).toString(), "endDate" : (this.endDate.getTime() / 1000).toString()}})
//console.log(historyType)
if(historyType == 'normal'){
this.startDate.setHours(0,0,0,0);
this.endDate.setHours(23,59,59,59);
this.http.get(this.coreUrl + 'rest/histories', {params: {"startDate" : (this.startDate.getTime() / 1000).toString(), "endDate" : (this.endDate.getTime() / 1000).toString()}})
.subscribe((data: any) => {
this.data = data['histories'];
this.limitExceeded = data['limitExceeded'];
......@@ -91,5 +164,30 @@ export class HistoryAdministrationComponent implements OnInit {
}, () => {
location.href = "index.php";
});
} else {
console.log(historyType)
this.batchStartDate.setHours(0,0,0,0);
this.batchEndDate.setHours(23,59,59,59);
this.http.get(this.coreUrl + 'rest/batchHistories', {params: {"startDate" : (this.batchStartDate.getTime() / 1000).toString(), "endDate" : (this.batchEndDate.getTime() / 1000).toString()}})
.subscribe((data: any) => {
this.batchData = data['batchHistories'];
this.batchLimitExceeded = data['limitExceeded'];
this.loading = false;
setTimeout(() => {
this.accessBatchHistory = true;
this.batchDataSource = new MatTableDataSource(this.batchData);
this.batchDataSource.paginator = this.batchPaginator;
this.batchDataSource.sort = this.batchSort;
}, 0);
}, (data: any) => {
if(data['error'].errors == 'Service forbidden'){
this.loading = false
this.accessBatchHistory = false;
} else {
location.href = "index.php";
}
});
}
}
}
......@@ -321,8 +321,16 @@ abstract class ServiceModelAbstract
$administrationApplication = ServiceModel::getApplicationAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]);
$administrationModule = ServiceModel::getModulesAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]);
foreach($administrationApplication['supervision'] as $key => $value){
if($value['name'] == "Historique des batchs"){
array_splice($administrationApplication['supervision'], $key, 1);
}
}
unset($key);
$administration['administrations'] = array_merge_recursive($administrationApplication, $administrationModule);
// $administration = array_merge_recursive($administration, $administrationMenu);
return $administration;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment