From 59d43069acc8dee0dc57f2cff3a2dd9560ea5599 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 30 Aug 2017 16:54:10 +0200 Subject: [PATCH] FEAT #5834 add MVC history --- .../history-administration.component.html | 84 ++++++++++++++++++ .../history-administration.component.js | 83 ++++++++++++++++++ .../history-administration.component.ts | 85 +++++++++++++++++++ 3 files changed, 252 insertions(+) create mode 100644 apps/maarch_entreprise/Views/history-administration.component.html create mode 100644 apps/maarch_entreprise/js/angular/app/administration/history-administration.component.js create mode 100644 apps/maarch_entreprise/js/angular/app/administration/history-administration.component.ts diff --git a/apps/maarch_entreprise/Views/history-administration.component.html b/apps/maarch_entreprise/Views/history-administration.component.html new file mode 100644 index 00000000000..dd807a1db4c --- /dev/null +++ b/apps/maarch_entreprise/Views/history-administration.component.html @@ -0,0 +1,84 @@ +<div class="page-header"> + <h1>{{lang.administration}} {{lang.history}} <small>{{data.length}} {{lang.entries}}</small></h1> +</div> +<div *ngIf="loading"> + <md-spinner style="margin:auto;"></md-spinner> +</div> +<div *ngIf="!loading" class="container-fluid"> + <div class="col-md-12"> + <table id="usersTable" class="table table-hover table-condensed" [md2Data]="data | dataPipe : 'info' : search | dataPipe : 'user_id' : filterUser | dataPipe : 'event_type' : filterEventType" + #md2="md2DataTable" [sortBy]='event_date' [rowsPerPage]="10"> + <thead> + <tr> + <td colspan="5"> + <md2-pagination></md2-pagination> + </td> + <td style="text-align:right;"> + <md2-datepicker name="mindate" placeholder="{{lang.dataOfMonth}} :" type="month" [(ngModel)]="minDate" #minDateControl="ngModel" + (change)="refreshHistory()"> + </md2-datepicker> + + </td> + </tr> + <tr class="filters"> + <td colspan="6"> + <md2-accordion> + <md2-accordion-tab> + <md2-accordion-header class="text-primary">{{lang.filterBy}} : </md2-accordion-header> + <div class="panel panel-default"> + <div class="panel-body"> + <div class="col-sm-4"> + <md-input-container> + <input mdInput placeholder="{{lang.desc}}" [(ngModel)]="search" /> + </md-input-container> + </div> + <div class="col-sm-4"> + <md2-select placeholder="Utilisateur cible" [(ngModel)]="filterUser" #filterUsersSelect="ngModel" style="padding:0px;padding-top: 15px;"> + <md2-select-header> + <md-input-container> + <input mdInput name="search" type="text" placeholder="Filtre" [(ngModel)]="_search" autocomplete="off" /> + </md-input-container> + </md2-select-header> + <md2-option style="font-style:italic;color:grey;">{{lang.noSelection}}</md2-option> + <md2-option *ngFor="let filter of filterUsers | dataPipe : 'user_id' : _search" [value]="filter.user_id">{{filter.user_id}}</md2-option> + </md2-select> + </div> + <div class="col-sm-4"> + <md2-select placeholder="Evenement cible" [(ngModel)]="filterEventType" #filterUsersSelect="ngModel" style="padding:0px;padding-top: 15px;"> + <md2-select-header> + <md-input-container> + <input mdInput name="search" type="text" placeholder="Filtre" [(ngModel)]="_search" autocomplete="off" /> + </md-input-container> + </md2-select-header> + <md2-option style="font-style:italic;color:grey;">{{lang.noSelection}}</md2-option> + <md2-option *ngFor="let filter of filterEventTypes | dataPipe : 'event_type' : _search" [value]="filter.event_type">{{filter.event_type}}</md2-option> + </md2-select> + </div> + </div> + </div> + </md2-accordion-tab> + </md2-accordion> + </td> + </tr> + <tr> + <th md2SortBy="event_date" style="width:10%;">{{lang.date}}</th> + <th md2SortBy="event_type" style="width:10%;">{{lang.event}}</th> + <th md2SortBy="user_id" style="width:15%;">{{lang.user}}</th> + <th md2SortBy="table_name" style="width:15%;">{{lang.table}}</th> + <th md2SortBy="info" style="width:40%;">{{lang.desc}}</th> + <th md2SortBy="info" style="width:10%;">{{lang.ip}}</th> + </tr> + </thead> + <tbody> + <tr *ngFor="let history of md2.data"> + <td style="vertical-align:middle;">{{history.event_date | date : "dd/MM/y HH:mm"}}</td> + <td style="vertical-align:middle;">{{history.event_type}}</td> + <td style="vertical-align:middle;">{{history.user_id}}</td> + <td style="vertical-align:middle;">{{history.table_name}}</td> + <td style="vertical-align:middle;">{{history.info}}</td> + <td style="vertical-align:middle;">{{history.remote_ip}}</td> + </tr> + </tbody> + </table> + </div> +</div> diff --git a/apps/maarch_entreprise/js/angular/app/administration/history-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/history-administration.component.js new file mode 100644 index 00000000000..fd6adb4d6eb --- /dev/null +++ b/apps/maarch_entreprise/js/angular/app/administration/history-administration.component.js @@ -0,0 +1,83 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var core_1 = require("@angular/core"); +var http_1 = require("@angular/common/http"); +var translate_component_1 = require("../translate.component"); +var notification_service_1 = require("../notification.service"); +var HistoryAdministrationComponent = (function () { + function HistoryAdministrationComponent(http, notify) { + this.http = http; + this.notify = notify; + this.lang = translate_component_1.LANG; + this.search = null; + this._search = ''; + this.filterEventTypes = []; + this.filterEventType = ''; + this.filterUsers = []; + this.filterUser = ''; + this.filterByDate = ''; + this.loading = false; + this.data = []; + this.CurrentYear = new Date().getFullYear(); + this.currentMonth = new Date().getMonth() + 1; + this.minDate = new Date(); + } + HistoryAdministrationComponent.prototype.updateBreadcrumb = function (applicationName) { + if ($j('#ariane')[0]) { + $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.history; + } + }; + HistoryAdministrationComponent.prototype.ngOnInit = function () { + var _this = this; + this.coreUrl = angularGlobals.coreUrl; + this.loading = true; + this.updateBreadcrumb(angularGlobals.applicationName); + $j('#inner_content').remove(); + this.minDate = new Date(this.CurrentYear + '-' + this.currentMonth + '-01'); + console.log(this.minDate.toJSON()); + this.http.get(this.coreUrl + 'rest/administration/history/eventDate/' + this.minDate.toJSON()) + .subscribe(function (data) { + _this.data = data.historyList; + _this.filterEventTypes = data.filters.eventType; + _this.filterUsers = data.filters.users; + _this.loading = false; + setTimeout(function () { + $j("[md2sortby='event_date']").click().click(); + }, 0); + }, function (err) { + console.log(err); + location.href = "index.php"; + }); + }; + HistoryAdministrationComponent.prototype.refreshHistory = function () { + var _this = this; + this.http.get(this.coreUrl + 'rest/administration/history/eventDate/' + this.minDate.toJSON()) + .subscribe(function (data) { + _this.data = data.historyList; + _this.filterEventTypes = data.filters.eventType; + _this.filterUsers = data.filters.users; + }, function (err) { + console.log(err); + location.href = "index.php"; + }); + }; + return HistoryAdministrationComponent; +}()); +HistoryAdministrationComponent = __decorate([ + core_1.Component({ + templateUrl: angularGlobals["history-administrationView"], + styleUrls: [], + providers: [notification_service_1.NotificationService] + }), + __metadata("design:paramtypes", [http_1.HttpClient, notification_service_1.NotificationService]) +], HistoryAdministrationComponent); +exports.HistoryAdministrationComponent = HistoryAdministrationComponent; diff --git a/apps/maarch_entreprise/js/angular/app/administration/history-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/history-administration.component.ts new file mode 100644 index 00000000000..8e0a1489db8 --- /dev/null +++ b/apps/maarch_entreprise/js/angular/app/administration/history-administration.component.ts @@ -0,0 +1,85 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { LANG } from '../translate.component'; +import { NotificationService } from '../notification.service'; + +declare function $j(selector: any) : any; + +declare var angularGlobals : any; + + +@Component({ + templateUrl : angularGlobals["history-administrationView"], + styleUrls : [], + providers : [NotificationService] +}) + +export class HistoryAdministrationComponent implements OnInit { + coreUrl : string; + lang : any = LANG; + search : string = null; + _search : string = ''; + + filterEventTypes : any = []; + filterEventType : string = ''; + filterUsers : any = []; + filterUser : string = ''; + filterByDate : string = ''; + + loading : boolean = false; + data : any = []; + CurrentYear : number = new Date().getFullYear(); + currentMonth : number = new Date().getMonth()+1; + minDate : Date = new Date(); + + + constructor(public http: HttpClient, private notify: NotificationService) { + } + + updateBreadcrumb(applicationName: string) { + if ($j('#ariane')[0]) { + $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > <a onclick='location.hash = \"/administration\"' style='cursor: pointer'>"+this.lang.administration+"</a> > "+this.lang.history; + } + } + + ngOnInit(): void { + this.coreUrl = angularGlobals.coreUrl; + + this.loading = true; + + this.updateBreadcrumb(angularGlobals.applicationName); + $j('#inner_content').remove(); + + this.minDate = new Date(this.CurrentYear+'-'+this.currentMonth+'-01'); + console.log(this.minDate.toJSON()); + this.http.get(this.coreUrl + 'rest/administration/history/eventDate/'+this.minDate.toJSON()) + .subscribe((data:any) => { + this.data = data.historyList; + + this.filterEventTypes = data.filters.eventType; + this.filterUsers = data.filters.users; + this.loading = false; + setTimeout(() => { + + $j("[md2sortby='event_date']").click().click(); + }, 0); + }, (err) => { + console.log(err); + location.href = "index.php"; + }); + } + + refreshHistory() { + this.http.get(this.coreUrl + 'rest/administration/history/eventDate/'+this.minDate.toJSON()) + .subscribe((data:any) => { + this.data = data.historyList; + this.filterEventTypes = data.filters.eventType; + this.filterUsers = data.filters.users; + + }, (err) => { + console.log(err); + location.href = "index.php"; + }); + } + +} \ No newline at end of file -- GitLab