Skip to content
Snippets Groups Projects
Verified Commit ac77f2aa authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #8218 home v2 with last five ressources

parent a7e31ac9
No related branches found
No related tags found
No related merge requests found
Showing
with 371 additions and 51 deletions
<mat-nav-list class="homeBasketList">
<mat-divider>
</mat-divider>
<mat-expansion-panel expanded style="box-shadow:none;">
<mat-expansion-panel-header>
<mat-panel-title style="color: rgba(0,0,0,0.54);font-size: 14px;font-weight: 500;">
{{lang.myBaskets}}
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field floatLabel="never">
<input matInput placeholder="Filtrer" #listFilter>
</mat-form-field>
<ng-container *ngFor="let regroupedBasket of homeData.regroupedBaskets">
<h4 *ngIf="regroupedBasket.baskets[0]" class="mat-toolbar mat-primary" style="padding-left:5px">
<mat-icon mat-list-icon class="fa fa-users"></mat-icon> {{regroupedBasket.groupDesc}}</h4>
<mat-nav-list>
<ng-container *ngFor="let basket of regroupedBasket.baskets | filterList:listFilter.value">
<a mat-list-item [disableRipple]="basket.redirected" [ngStyle]="{'cursor': basket.redirected ? 'not-allowed' : 'pointer'}">
<mat-icon [ngStyle]="{'color': basket.color}" *ngIf="!basket.redirected && !mobileMode" mat-list-icon class="fa fa-inbox"></mat-icon>
<mat-icon [ngStyle]="{'color': basket.color}" *ngIf="basket.redirected && !mobileMode" mat-list-icon class="fa fa-share"></mat-icon>
<span *ngIf="basket.resourceNumber==0" class="badge">{{basket.resourceNumber}}</span>
<span *ngIf="basket.resourceNumber!=0" bgcolor="warn" class="badge">{{basket.resourceNumber}}</span>
<p mat-line (click)="goTo(basket.basket_id,regroupedBasket.groupId)" *ngIf="!basket.redirected" title="{{basket.basket_name}}" [ngStyle]="{'color': basket.color}">
{{basket.basket_name}}
</p>
<p mat-line *ngIf="basket.redirected" title="{{basket.basket_name}}" [ngStyle]="{'color': basket.color}">
{{basket.basket_name}}<br/><small color="primary">({{lang.redirectedTo}} {{basket.redirectedUser}})</small>
</p>
</a>
</ng-container>
</mat-nav-list>
</ng-container>
<ng-container *ngIf="homeData.assignedBaskets.length>0">
<h4 class="mat-toolbar mat-primary" style="padding-left:5px">{{lang.othersBaskets}}</h4>
<mat-nav-list>
<a mat-list-item *ngFor="let basket of homeData.assignedBaskets | filterList:listFilter.value">
<mat-icon *ngIf="!mobileMode" style="color:#666" mat-list-icon class="fa fa-inbox"></mat-icon>
<span *ngIf="basket.resourceNumber==0" class="badge">{{basket.resourceNumber}}</span>
<span *ngIf="basket.resourceNumber!=0" bgcolor="warn" class="badge">{{basket.resourceNumber}}</span>
<p mat-line (click)="goToRedirect(basket.basket_id,basket.basket_owner)" title="{{basket.basket_name}}" style="color:#666">
{{basket.basket_name}}<br/><small color="primary">({{basket.userToDisplay}})</small>
</p>
</a>
</mat-nav-list>
</ng-container>
</mat-expansion-panel>
<mat-divider></mat-divider>
<!--<mat-nav-list class="homeBasketList">
Nouveau courrier
<mat-list>
<ng-container *ngFor="let regroupedBasket of homeData.regroupedBaskets">
<h4 *ngIf="regroupedBasket.baskets[0]" class="mat-toolbar mat-primary" style="padding-left:5px"><mat-icon mat-list-icon class="fa fa-users"></mat-icon> {{regroupedBasket.groupDesc}}</h4>
<h4 *ngIf="regroupedBasket.baskets[0]" class="mat-toolbar mat-primary" style="padding-left:5px">
<mat-icon mat-list-icon class="fa fa-users"></mat-icon> {{regroupedBasket.groupDesc}}</h4>
<mat-list-item *ngFor="let basket of regroupedBasket.baskets" [ngStyle]="{'color': basket.color}">
<mat-icon mat-list-icon *ngIf="!basket.redirected" class="fa fa-inbox" matBadge="{{basket.resourceNumber}}" matBadgePosition="before" matBadgeColor="warn" [matBadgeHidden]="basket.resourceNumber==0" matTooltip="{{basket.resourceNumber}}"></mat-icon>
<mat-icon mat-list-icon *ngIf="basket.redirected" class="fa fa-share" matBadge="{{basket.resourceNumber}}" matBadgePosition="before" matBadgeColor="warn" [matBadgeHidden]="basket.resourceNumber==0" matTooltip="{{basket.resourceNumber}}"></mat-icon>
<mat-icon mat-list-icon *ngIf="!basket.redirected" class="fa fa-inbox" matBadge="{{basket.resourceNumber}}" matBadgePosition="before"
matBadgeColor="warn" [matBadgeHidden]="basket.resourceNumber==0" matTooltip="{{basket.resourceNumber}}">
<span class="badge">{{basket.resourceNumber}}</span>
</mat-icon>
<mat-icon mat-list-icon *ngIf="basket.redirected" class="fa fa-share" matBadge="{{basket.resourceNumber}}" matBadgePosition="before"
matBadgeColor="warn" [matBadgeHidden]="basket.resourceNumber==0" matTooltip="{{basket.resourceNumber}}">
<span class="badge">{{basket.resourceNumber}}</span>
</mat-icon>
<a *ngIf="!basket.redirected" href="index.php?page=view_baskets&module=basket&baskets={{basket.basket_id}}&groupId={{regroupedBasket.groupId}}">
<span mat-line matTooltip="{{basket.basket_desc}}">&nbsp;{{basket.basket_name}}</span>
</a>
......@@ -20,7 +74,8 @@
<ng-container *ngIf="homeData.assignedBaskets.length>0">
<h4 class="mat-toolbar mat-primary" style="padding-left:5px">{{lang.othersBaskets}}</h4>
<mat-list-item *ngFor="let basket of homeData.assignedBaskets" style="color:#666">
<mat-icon mat-list-icon class="fa fa-inbox" matBadge="{{basket.resourceNumber}}" matBadgePosition="before" matBadgeColor="warn" [matBadgeHidden]="basket.resourceNumber==0" matTooltip="{{basket.resourceNumber}}"></mat-icon>
<mat-icon mat-list-icon class="fa fa-inbox" matBadge="{{basket.resourceNumber}}" matBadgePosition="before" matBadgeColor="warn"
[matBadgeHidden]="basket.resourceNumber==0" matTooltip="{{basket.resourceNumber}}"></mat-icon>
<a href="index.php?page=view_baskets&module=basket&baskets={{basket.basket_id}}_{{basket.basket_owner}}&groupId=">
<span mat-line matTooltip="{{basket.basket_desc}} ({{basket.userToDisplay}})">&nbsp;{{basket.basket_name}} ({{basket.userToDisplay}})</span>
</a>
......@@ -31,4 +86,4 @@
<h4 *ngIf="homeData.regroupedBaskets.length==0 && homeData.assignedBaskets.length==0">{{lang.noAvailableBasket}}</h4>
</mat-nav-list>
</mat-nav-list>-->
\ No newline at end of file
......@@ -12,22 +12,86 @@
</mat-toolbar>
<mat-sidenav-container class="admin-sidenav-container" [style.marginTop.px]="mobileMode ? 56 : 0">
<mat-sidenav #snav [mode]="mobileMode ? 'over' : 'side'" [fixedInViewport]="mobileMode" fixedTopGap="56" [opened]="mobileMode ? false : true"
autoFocus="false">
<menu-nav *ngIf="mobileMode"></menu-nav>
<basket-home *ngIf="homeData && !mobileMode" [homeData]="homeData"></basket-home>
autoFocus="false" style="overflow-x:hidden;" [ngStyle]="{'width': mobileMode ? '80%' : '400px'}">
<basket-home *ngIf="homeData" [homeData]="homeData"></basket-home>
<mat-divider></mat-divider>
</mat-sidenav>
<mat-sidenav-content>
<div *ngIf="loading" style="display:flex;height:100%;">
<mat-spinner style="margin:auto;"></mat-spinner>
</div>
<basket-home *ngIf="homeData && mobileMode && !loading" [homeData]="homeData"></basket-home>
<mat-card *ngIf="!loading" class="card-app-content">
Aucune bannette sélectionnée
<mat-tab-group>
<mat-tab label="Mes derniers courriers">
<table mat-table [dataSource]="dataSource" matSort matSortActive="res_id" matSortDisableClear matSortDirection="asc" style="width:100%;table-layout: fixed;">
<!-- Number Column -->
<ng-container matColumnDef="res_id">
<td mat-cell *matCellDef="let row" style="text-align:center;width:15%;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;padding: 5px;">
<div style="overflow: hidden;text-overflow: ellipsis;">
<mat-icon [ngStyle]="{'color': row.priority_color}" color="primary" class="fm {{row.status_icon}} fm-2x"
title="{{row.status_label}}"></mat-icon>
</div>
<div style="padding-top: 5px;color: rgba(0,0,0,0.4);font-size: 90%;overflow: hidden;text-overflow: ellipsis;">
{{row.alt_identifier}}
</div>
</td>
</ng-container>
<ng-container matColumnDef="subject">
<td mat-cell *matCellDef="let row" style="width:45%;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;padding: 5px;">
<div style="overflow: hidden;text-overflow: ellipsis;" title="{{row.subject}}">
<span class="label" [ngStyle]="{'background': row.priority_color}">{{row.priority_label}}</span>&nbsp;
<span>{{row.subject}}</span>
</div>
</td>
</ng-container>
<ng-container matColumnDef="contact_society">
<td mat-cell *matCellDef="let row" style="width:25%;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;padding: 5px;">
<div style="overflow: hidden;text-overflow: ellipsis;">
<i class="fa fa-address-card" color="primary"></i>&nbsp;
<span *ngIf="row.contact_lastname==''">{{row.contact_society}}</span>
<span *ngIf="row.contact_society==''">{{row.contact_lastname}}</span> &nbsp;
<i class="fa fa-arrow-right"></i>&nbsp;
<i class="fa fa-sitemap" color="primary"></i>&nbsp;
<span title="{{row.entity_label}}">{{row.destination}}</span>
</div>
<div style="padding-top: 5px;color: rgba(0,0,0,0.4);font-size: 90%;overflow: hidden;text-overflow: ellipsis;">
{{row.dest_user}}
</div>
</td>
</ng-container>
<ng-container matColumnDef="creation_date">
<td mat-cell *matCellDef="let row" style="text-align: right;width:15%;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;padding: 5px;">
<div *ngIf="row.closing_date == null" id="{{row.res_id}}_creation_date" style="color: rgba(0,0,0,0.4);font-size: 90%;overflow: hidden;text-overflow: ellipsis;"
title='{{row.creation_date | date : "le dd/MM/y à HH:mm"}}'>
<i class="fa fa-calendar" title="date d'enregistrement"></i> {{row.creation_date | timeAgo}}
</div>
<div *ngIf="row.closing_date == null" style="color: rgba(0,0,0,0.4);font-size: 90%;overflow: hidden;text-overflow: ellipsis;"
>
<i class="fa fa-stopwatch" title="date limite de traitement"></i>&nbsp;
<span [innerHTML]="row.process_limit_date | timeLimit" title='{{row.process_limit_date | date : "le dd/MM/y à HH:mm"}}'></span>
</div>
<div *ngIf="row.closing_date != null" style="color: rgba(0,0,0,0.4);font-size: 90%;overflow: hidden;text-overflow: ellipsis;"
>
<i class="fa fa-lock" title="date de clôture"></i>&nbsp;<span title='{{row.process_limit_date | date : "le dd/MM/y à HH:mm"}}'>{{row.closing_date | timeAgo}}</span>
</div>
<div>
<button mat-icon-button (click)="$event.stopPropagation();goTo(row);">
<mat-icon color="primary" class="fa fa-eye"></mat-icon>
</button>
</div>
</td>
</ng-container>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="goToDetail(row);" style="cursor: pointer;"></tr>
</table>
</mat-tab>
</mat-tab-group>
</mat-card>
</mat-sidenav-content>
<mat-sidenav #snav2 [mode]="mobileQuery.matches ? 'over' : 'side'" [fixedInViewport]="mobileQuery.matches" fixedTopGap="56"
position='end' [opened]="mobileQuery.matches ? false : true" style="overflow-x:hidden;max-width:500px;">
position='end' [opened]="mobileQuery.matches ? false : false" style="overflow-x:hidden;" [ngStyle]="{'width': mobileMode ? '80%' : '40%'}">
<div *ngIf="innerHtml" [innerHTML]="innerHtml" style="height: 100%;overflow: hidden;"></div>
</mat-sidenav>
</mat-sidenav-container>
</div>
\ No newline at end of file
</div>
\ No newline at end of file
<button mat-button [matMenuTriggerFor]="lastresource" *ngIf="!mobileMode && homeData" style="min-width: unset" matTooltip="{{lang.myLastResources}}">
<mat-icon mat-list-icon class="fa fa-list-ul fa-lg" style="color:white; margin:0px 0px -11px 0px;"></mat-icon></button>
<mat-menu #lastresource="matMenu" class="headerMaarchShortcut">
<mat-nav-list *ngIf="homeData">
<mat-list-item *ngFor="let resource of homeData.lastResources">
<a matLine href="index.php?page=details&dir=indexing_searching&id={{resource.res_id}}" matTooltip="{{resource.subject}}" style="color:#135F7F">{{resource.alt_identifier}}<br>{{resource.subject}}</a>
<mat-divider></mat-divider>
</mat-list-item>
</mat-nav-list>
</mat-menu>
<button mat-button [matMenuTriggerFor]="applications" *ngIf="!mobileMode && homeData" style="min-width: unset" matTooltip="{{lang.shortcut}}">
<mat-icon mat-list-icon class="fa fa-th fa-lg" style="color:white; margin:0px 0px -11px 0px;"></mat-icon></button>
<mat-menu #applications="matMenu" class="headerMaarchShortcut">
<!-- TODO -->
<button style="white-space:inherit;height: 100px;line-height:20px;" class="col-md-4 col-xs-6" mat-button color="primary">
<i class="fa fa-users fa-2x"></i>
<br/>Utilisateurs
</button>
<button style="white-space:inherit;height: 100px;line-height:20px;" class="col-md-4 col-xs-6" mat-button color="primary">
<i class="fa fa-users fa-2x"></i>
<br/>Utilisateurs
</button>
<button style="white-space:inherit;height: 100px;line-height:20px;" class="col-md-4 col-xs-6" mat-button color="primary">
<i class="fa fa-users fa-2x"></i>
<br/>Utilisateurs
</button>
<button style="white-space:inherit;height: 100px;line-height:20px;" class="col-md-4 col-xs-6" mat-button color="primary">
<i class="fa fa-users fa-2x"></i>
<br/>Utilisateurs
</button>
<div style="text-align:center;font-size: 20px;font-weight: bolder;opacity: 0.2;">
Menu
</div>
<ng-container *ngFor="let shortcut of user.menu">
<button style="white-space:inherit;height: 100px;line-height:20px;" class="col-md-4 col-xs-6" mat-button color="primary">
<i class="fa {{shortcut.icon}} fa-2x"></i>
<br/>{{shortcut.label}}
</button>
</ng-container>
</mat-menu>
<button mat-button [matMenuTriggerFor]="menu" *ngIf="!mobileMode">
<mat-icon mat-list-icon class="fa fa-user fa-2x" style="color:white; margin:0px 12px 8px 0px;"></mat-icon>{{user.firstname.charAt(0) | uppercase}}. {{user.lastname | uppercase}}</button>
......
<mat-nav-list>
<ng-container *ngIf="mobileMode">
<canvas class="header-bg" width="250" height="70" style="margin-top:-8px;background-image: url('static.php?filename=login-banner.jpg');background-size:cover;border-bottom: solid 1px white;"></canvas>
<canvas class="header-bg" style="margin-top:-8px;background-image: url('static.php?filename=login-banner.jpg');background-size:cover;border-bottom: solid 1px white;width: 100%;height: 70px;"></canvas>
<i title="{{lang.myProfileAccess}}" routerLink="/profile" style="cursor:pointer;z-index:1;color:white;position: absolute;left: 85px;top: 17px;background-image: url('static.php?filename=logo_only.svg');width: 70px;height: 70px;background-size: cover;background-position: top center;border-radius: 50%;border: solid white;background-color:white;"></i>
<mat-expansion-panel style="margin-top:-7px;">
<mat-expansion-panel-header>
......
......@@ -3,7 +3,7 @@
<input type="hidden" name="meta[]" value="baskets_clause#baskets_clause#select_simple">
<input type="hidden" name="meta[]" value="welcome#welcome#welcome">
<input type="hidden" name="baskets_clause" value="true">
<input id="text" type="text" name="welcome" placeholder="{{lang.searchMails}}" class="searchInput">
<input id="text" type="text" name="welcome" placeholder="{{lang.searchMails}}" class="searchInput" style="width:100%">
<!-- <span matSuffix><mat-icon class="fa fa-search"></mat-icon></span> -->
<input type="submit" name="submit" value="" style="display:none">
</form>
This diff is collapsed.
......@@ -61,6 +61,18 @@ $theme: mat-light-theme($primary, $accent, $warn);
color: mat-color($accent, 500);
}
[bgcolor=primary] {
background-color: mat-color($primary, 500);
}
[bgcolor=warn] {
background-color: mat-color($warn, 500);
}
[bgcolor=accent] {
background-color: mat-color($accent, 500);
}
.jstree-proton .jstree-clicked {
background : mat-color($primary, 100) !important;
}
......@@ -121,7 +133,6 @@ $theme: mat-light-theme($primary, $accent, $warn);
border-radius: 100px;
background-color: #fafafa;
padding: 5px 16px;
margin-left: 8px;
width: 400px;
max-width: 400px;
height: 36px;
......
......@@ -12,6 +12,8 @@ import { RouterModule } from '@angular/router';
/*PLUGINS IMPORTS*/
import { TimeAgoPipe } from '../plugins/timeAgo.pipe';
import { TimeLimitPipe } from '../plugins/timeLimit.pipe';
import { FilterListPipe } from '../plugins/filterList.pipe';
/*FRONT IMPORTS*/
import { AppMaterialModule } from './app-material.module';
......@@ -45,7 +47,9 @@ import { BasketHomeComponent } from './basket/basket-home
MenuShortcutComponent,
SearchHomeComponent,
BasketHomeComponent,
TimeAgoPipe
TimeAgoPipe,
TimeLimitPipe,
FilterListPipe,
],
exports: [
CommonModule,
......@@ -62,7 +66,9 @@ import { BasketHomeComponent } from './basket/basket-home
HttpClientModule,
RouterModule,
AppMaterialModule,
TimeAgoPipe
TimeAgoPipe,
TimeLimitPipe,
FilterListPipe,
]
})
export class SharedModule { }
......@@ -14,13 +14,23 @@ export class BasketHomeComponent implements OnInit {
lang: any = LANG;
coreUrl : string;
mobileMode : boolean = false;
@Input() homeData: any;
constructor(public http: HttpClient) {
this.mobileMode = angularGlobals.mobileMode;
}
ngOnInit(): void {
this.coreUrl = angularGlobals.coreUrl;
}
goTo(basketId:any,groupId:any) {
window.location.href="index.php?page=view_baskets&module=basket&baskets="+basketId+"&groupId="+groupId;
}
goToRedirect(basketId:any,owner:any) {
window.location.href="index.php?page=view_baskets&module=basket&baskets="+basketId+"_"+owner+"&groupId=";
}
}
......@@ -3,9 +3,10 @@ import { MediaMatcher } from '@angular/cdk/layout';
import { HttpClient } from '@angular/common/http';
import { LANG } from './translate.component';
import { NotificationService } from './notification.service';
import { MatDialog, MatSidenav, MatExpansionPanel } from '@angular/material';
import { MatDialog, MatSidenav, MatExpansionPanel, MatTableDataSource } from '@angular/material';
import { AutoCompletePlugin } from '../plugins/autocomplete.plugin';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
declare function $j(selector: any): any;
......@@ -25,13 +26,17 @@ export class HomeComponent extends AutoCompletePlugin implements OnInit {
lang: any = LANG;
loading: boolean = false;
docUrl : string = '';
public innerHtml: SafeHtml;
@ViewChild('snav2') sidenav: MatSidenav;
@ViewChildren(MatExpansionPanel) viewPanels: QueryList<MatExpansionPanel>;
homeData: any;
dataSource: any;
displayedColumns: string[] = ['res_id', 'subject', 'creation_date'];
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, public dialog: MatDialog) {
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, public dialog: MatDialog, private sanitizer: DomSanitizer) {
super(http, ['users']);
this.mobileMode = angularGlobals.mobileMode;
$j("link[href='merged_css.php']").remove();
......@@ -64,8 +69,31 @@ export class HomeComponent extends AutoCompletePlugin implements OnInit {
.subscribe((data: any) => {
this.homeData = data;
this.loading = false;
setTimeout(() => {
this.dataSource = new MatTableDataSource(this.homeData.lastResources);
}, 0);
});
}
goTo(row:any){
if (this.docUrl == this.coreUrl+'rest/res/'+row.res_id+'/content' && this.sidenav.opened) {
this.displayedColumns = ['res_id', 'subject', 'creation_date'];
this.sidenav.close();
} else {
this.displayedColumns = ['res_id', 'subject', 'creation_date'];
this.docUrl = this.coreUrl+'rest/res/'+row.res_id+'/content';
this.innerHtml = this.sanitizer.bypassSecurityTrustHtml(
"<object style='height:100%;width:100%;' data='" + this.docUrl + "' type='application/pdf' class='embed-responsive-item'>" +
"<div>Le document "+row.res_id+" ne peut pas être chargé</div>" +
"</object>");
this.sidenav.open();
}
//window.open(this.coreUrl+'rest/res/'+row.res_id+'/content');
}
goToDetail(row:any){
location.href = "index.php?page=details&dir=indexing_searching&id="+row.res_id;
}
}
......@@ -24,5 +24,19 @@ export class MenuTopComponent implements OnInit {
ngOnInit(): void {
this.coreUrl = angularGlobals.coreUrl;
this.user = angularGlobals.user;
this.user.menu = [
{"label":"Administration","url":"zefpokezf","icon":"fa-cogs"},
{"label":"Impression des séparateurs","url":"zefpokezf","icon":"fa-print"},
{"label":"Enregistrer un courrier","url":"zefpokezf","icon":"fa-plus"},
{"label":"Rechercher un courrier","url":"zefpokezf","icon":"fa-search"},
{"label":"Rechercher un contact","url":"zefpokezf","icon":"fa-user"},
{"label":"Mes contacts","url":"zefpokezf","icon":"fa-book"},
{"label":"Plan de classement","url":"zefpokezf","icon":"fa-copy"},
{"label":"Créer un dossier","url":"zefpokezf","icon":"fa-folder-open"},
{"label":"Consulter un dossier","url":"zefpokezf","icon":"fa-code-branch"},
{"label":"Rechercher un dossier","url":"zefpokezf","icon":"fa-folder"},
{"label":"Statistique","url":"zefpokezf","icon":"fa-chart-area"},
{"label":"Enregistrer un pli numérique","url":"zefpokezf","icon":"fa-file-archive"},
]
}
}
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
name: 'filterList'
})
export class FilterListPipe implements PipeTransform {
transform(value: any, args: string): any {
let filter = args.toLocaleLowerCase();
return filter ? value.filter((basket:any) => basket.basket_name.toLocaleLowerCase().indexOf(filter) != -1) : value;
}
}
@Pipe({
name: 'filterShortcut'
})
export class FilterShortcutPipe implements PipeTransform {
transform(value: any, args: string): any {
let filter = args.toLocaleLowerCase();
return filter ? value.filter((shortcut:any) => shortcut.label.toLocaleLowerCase().indexOf(filter) != -1) : value;
}
}
import {Pipe, PipeTransform, NgZone, ChangeDetectorRef, OnDestroy} from "@angular/core";
@Pipe({
name:'timeLimit',
pure:false
})
export class TimeLimitPipe implements PipeTransform, OnDestroy {
private timer: number;
constructor(private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) {}
transform(value:string) {
this.removeTimer();
let d = new Date(value);
let dayNumber = ('0' + d.getDate()).slice(-2)
let monthNumber = ('0' + d.getMonth()).slice(-2)
let hourNumber = ('0' + d.getHours()).slice(-2)
let minuteNumber = ('0' + d.getMinutes()).slice(-2)
let now = new Date();
let month = new Array();
month[0] = "Jan.";
month[1] = "Fév.";
month[2] = "Mars";
month[3] = "Avr.";
month[4] = "Mai";
month[5] = "Juin";
month[6] = "Juil.";
month[7] = "Août";
month[8] = "Sept.";
month[9] = "Oct.";
month[10] = "Nov.";
month[11] = "Déc.";
let seconds = Math.round(Math.abs((now.getTime() - d.getTime())/1000));
let timeToUpdate = (Number.isNaN(seconds)) ? 1000 : this.getSecondsUntilUpdate(seconds) *1000;
this.timer = this.ngZone.runOutsideAngular(() => {
if (typeof window !== 'undefined') {
return window.setTimeout(() => {
this.ngZone.run(() => this.changeDetectorRef.markForCheck());
}, timeToUpdate);
}
return null;
});
let minutes = Math.round(Math.abs(seconds / 60));
let hours = Math.round(Math.abs(minutes / 60));
let days = Math.round(Math.abs(hours / 24));
let months = Math.round(Math.abs(days/30.416));
let years = Math.round(Math.abs(days/365));
if(now > d) {
return '<span class="timeDanger" color="warn">dépassée !</span>';
} else {
if (Number.isNaN(seconds)){
return '';
} else if (days <= 3) {
return '<span color="warn">'+days + ' jour(s)'+'</span>';
} else if (days <= 7) {
return '<span class="timeWarn">'+days + ' jour(s)'+'</span>';
} else if (days <= 345) {
return '<span color="accent">'+d.getDate()+' '+ month[d.getMonth()]+'</span>';
} else if (days <= 545) {
return dayNumber + '/' + monthNumber + '/' + d.getFullYear();
} else { // (days > 545)
return dayNumber + '/' + monthNumber + '/' + d.getFullYear();
}
}
/*if (Number.isNaN(seconds)){
return '';
} else if (seconds <= 45) {
return seconds + ' secondes';
} else if (seconds <= 90) {
//return 'une minute';
} else if (minutes <= 45) {
return minutes + ' minutes';
} else if (minutes <= 90) {
//return 'une heure';
} else if (hours <= 22) {
return hourNumber+':'+minuteNumber;
//return hours + ' heures';
} else if (hours <= 36) {
return dayNumber+' '+ month[d.getMonth()];
//return 'un jour';
} else if (days <= 25) {
return d.getDate()+' '+ month[d.getMonth()];
//return days + ' jours';
} else if (days <= 45) {
return d.getDate()+' '+ month[d.getMonth()];
//return 'un mois';
} else if (days <= 345) {
return d.getDate()+' '+ month[d.getMonth()];
//return months + ' mois';
} else if (days <= 545) {
return dayNumber + '/' + monthNumber + '/' + d.getFullYear();
//return 'un an';
} else { // (days > 545)
return dayNumber + '/' + monthNumber + '/' + d.getFullYear();
//return years + ' ans';
}*/
}
ngOnDestroy(): void {
this.removeTimer();
}
private removeTimer() {
if (this.timer) {
window.clearTimeout(this.timer);
this.timer = null;
}
}
private getSecondsUntilUpdate(seconds:number) {
let min = 60;
let hr = min * 60;
let day = hr * 24;
if (seconds < min) { // less than 1 min, update every 2 secs
return 2;
} else if (seconds < hr) { // less than an hour, update every 30 secs
return 30;
} else if (seconds < day) { // less then a day, update every 5 mins
return 300;
} else { // update every hour
return 3600;
}
}
}
\ No newline at end of file
......@@ -76,7 +76,7 @@ class HomeController
}
$lastResources = ResModel::getLastResources([
'select' => ['res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.creation_date', 'mlb_coll_ext.alt_identifier'],
'select' => ['res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.creation_date', 'res_letterbox.destination', 'res_letterbox.dest_user', 'mlb_coll_ext.alt_identifier', 'mlb_coll_ext.closing_date', 'mlb_coll_ext.process_limit_date', 'status.label_status as status_label', 'status.img_filename as status_icon', 'priorities.color as priority_color'],
'limit' => 5,
'userId' => $GLOBALS['userId']
]);
......
......@@ -178,16 +178,18 @@ abstract class ResModelAbstract
$resources = DatabaseModel::select([
'select' => $aArgs['select'],
'table' => ['history, res_letterbox, mlb_coll_ext'],
'table' => ['history, res_letterbox, mlb_coll_ext, status, priorities'],
'where' => [
'history.user_id = ?', 'history.table_name IN (?)',
'history.record_id IS NOT NULL', 'history.record_id != ?',
'history.event_id != ?', 'history.event_id NOT LIKE ?',
'CAST(history.record_id AS INT) = res_letterbox.res_id',
'mlb_coll_ext.res_id = res_letterbox.res_id', 'res_letterbox.status != ?'
'mlb_coll_ext.res_id = res_letterbox.res_id', 'res_letterbox.status != ?',
'res_letterbox.status = status.id',
'res_letterbox.priority = priorities.id',
],
'data' => [$aArgs['userId'], ['res_letterbox', 'res_view_letterbox'], 'none', 'linkup', 'attach%', 'DEL'],
'group_by' => ['res_letterbox.res_id', 'mlb_coll_ext.alt_identifier'],
'group_by' => ['res_letterbox.res_id', 'mlb_coll_ext.alt_identifier', 'mlb_coll_ext.closing_date', 'mlb_coll_ext.process_limit_date', 'status.label_status', 'status.img_filename', 'priorities.color'],
'order_by' => ['MAX(history.event_date) DESC'],
'limit' => $aArgs['limit']
]);
......
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