From 20394790ecd1ffdf71fe56a93d4a7fbdb24ea156 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Mon, 28 Aug 2017 11:58:20 +0200 Subject: [PATCH] FEAT #5692 add md2 component angular --- .../Views/header.component.html | 125 +++++++-------- .../css/header.component.css | 144 ++---------------- .../js/angular/app/header.component.js | 32 +++- .../js/angular/app/header.component.ts | 39 +++-- core/Models/ServiceModelAbstract.php | 134 ++++++++++++++++ 5 files changed, 250 insertions(+), 224 deletions(-) diff --git a/apps/maarch_entreprise/Views/header.component.html b/apps/maarch_entreprise/Views/header.component.html index bbbd7325deb..33828d8a852 100755 --- a/apps/maarch_entreprise/Views/header.component.html +++ b/apps/maarch_entreprise/Views/header.component.html @@ -1,72 +1,53 @@ -<nav id="headerV2" class="navbar navbar-default"> - <div class="container-fluid"> - <!-- Brand and toggle get grouped for better mobile display --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> - <span class="sr-only">Toggle navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <a id="headerLogo" class="navbar-brand" href="index.php"></a> - </div> - - <!-- Collect the nav links, forms, and other content for toggling --> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <form class="navbar-form navbar-left"> - <div class="form-group"> - <div class="input-group"> - <div class="input-group-btn"> - <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="fa fa-bars"></span> Courriers</button> - <ul class="dropdown-menu"> - <li><a href="#">Courriers</a></li> - <li><a href="#">Contacts</a></li> - <li><a href="#">Pièces jointes</a></li> - <li role="separator" class="divider"></li> - <li><a href="#">Globale</a></li> - </ul> - </div><!-- /btn-group --> - <input style="width:400px;" type="text" class="form-control" placeholder="Search for..."> - <span class="input-group-btn"> - <button class="btn btn-default" type="button"><i class="fa fa-search"></i></button> - </span> - </div><!-- /input-group --> - </div> - </form> - <ul class="nav navbar-nav navbar-right"> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-gears fa-2x"></i> <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="#">Gestion utlisateurs</a></li> - <li><a href="#">Gestion groupes</a></li> - <li><a href="#">Gestion statuts</a></li> - <li><a href="#">...</a></li> - <li role="separator" class="divider"></li> - <li><a href="#">Panneau d'administration</a></li> - </ul> - </li> - <li class="dropdown" id="headerNotification"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-bell fa-2x"></i><sup class="notification"><span color="red" class="badge">5</span></sup> <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li class="alert-info"><a><b>3</b> nouveau(x) courrier(s) dans <i class="link">courrier à traiter</i></a></li> - <li class="alert-info"><a><b class="link">2017/A/123</b> nouvelle note ajoutée</a></li> - <li class="alert-warning"><a><b class="link">2017/A/123</b> arrive bientôt à échéance ! <i class="badge">1 jour(s)</i></a></li> - <li class="alert-warning"><a><b class="link">2017/A/21</b> arrive bientôt à échéance ! <i class="badge">2 jour(s)</i></a></li> - <li class="alert-danger"><a><b class="link">2017/A/21</b> est arrivé à échéance ! <i class="badge">- 4 jour(s)</i></a></li> - <li role="separator" class="divider"></li> - <li><a href="#">Voir la liste des notifications</a></li> - </ul> - </li> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user fa-2x"></i> <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="#">Mon profile</a></li> - <li role="separator" class="divider"></li> - <li><a href="#">Déconnexion</a></li> - </ul> - </li> - </ul> - </div><!-- /.navbar-collapse --> - </div><!-- /.container-fluid --> -</nav> -<router-outlet></router-outlet> \ No newline at end of file +<md-toolbar color="primary"> + <button tooltip="Menu" tooltip-delay="1000" md-button mdInput [mdMenuTriggerFor]="mySetting">{{applicationName}}</button> + <span id="globalSearch"> + <form class="example-form"> + <md-input-container> + <button md-button mdPrefix [mdMenuTriggerFor]="searchTarget"><i class="fa fa-bars fa-2x"></i></button> + <input type="tel" mdInput placeholder="Rechercher dans : global"> + </md-input-container> + </form> + </span> + <span style="flex: 1 1 auto;"></span> + <button tooltip="Administration" tooltip-delay="1000" md-icon-button [mdMenuTriggerFor]="myAdmin"> + <i class="fa fa-cogs fa-2x"></i> + </button> + <button tooltip="Mes notifications" tooltip-delay="1000" md-icon-button [mdMenuTriggerFor]="myNotif"> + <i class="fa fa-bell fa-2x"></i> + <sub class="badge text-warning">0</sub> + </button> + <button tooltip="Mes paramètres" tooltip-delay="1000" md-icon-button [mdMenuTriggerFor]="myProfil"> + <i class="fa fa-user fa-2x"></i> + </button> + <md-menu #mySetting="mdMenu"> + <button *ngFor="let menu of menuList" routerLink="{{menu.link}}" md-menu-item> + <span><i class="fa {{menu.icon}}"></i> {{menu.label}}</span> + </button> + </md-menu> + <md-menu #myNotif="mdMenu"> + <button md-menu-item disabled> + <span style="opacity:0.5;"><i class="fa fa-times"></i> Aucune notification</span> + </button> + </md-menu> + <md-menu #myProfil="mdMenu"> + <button *ngFor="let profil of profilList" routerLink="{{profil.link}}" md-menu-item> + <span><i class="fa {{profil.style}}"></i> {{profil.label}}</span> + </button> + </md-menu> + <md-menu #myAdmin="mdMenu"> + <button *ngFor="let admin of adminList" routerLink="{{admin.servicepage}}" tooltip="{{admin.comment}}" tooltip-position="before" tooltip-delay="1000" md-menu-item [disabled]="admin.angular == 'false'"> + <span><i class="fa {{admin.style}}"></i> {{admin.name}}</span> + </button> + <button *ngFor="let adminMod of adminListModule" routerLink="{{adminMod.servicepage}}" tooltip="{{adminMod.comment}}" tooltip-position="before" tooltip-delay="1000" md-menu-item [disabled]="adminMod.angular == 'false'"> + <span><i class="fa {{adminMod.style}}"></i> {{adminMod.name}}</span> + </button> + </md-menu> + <md-menu #searchTarget="mdMenu"> + <button md-menu-item> + <span>Courriers</span> + </button> + <button md-menu-item> + <span>Contacts</span> + </button> + </md-menu> +</md-toolbar> diff --git a/apps/maarch_entreprise/css/header.component.css b/apps/maarch_entreprise/css/header.component.css index e4f9566d8a4..172279e0977 100755 --- a/apps/maarch_entreprise/css/header.component.css +++ b/apps/maarch_entreprise/css/header.component.css @@ -1,140 +1,14 @@ -#headerV2{ - border-radius:0px; - margin-left: -10px; - margin-top: 0px; - margin-right: -10px; - border: solid 2px #009DC5; - background: #009DC5; - color:white; +/deep/ .mat-toolbar-row .mat-icon-button { + margin-left: 5px; + margin-right: 5px; } -#headerV2 .navbar-right .dropdown-toggle{ - color:white !important; +/deep/ .mat-toolbar-row #globalSearch { + margin-left: 20px; } -#headerV2 .breadcrumb{ - padding:0px; - margin-bottom:0px; - background:none; - position:initial; +/deep/ .mat-toolbar-row .badge{ + margin-left: -15px; + margin-top: 10px; + background-color: #a94442 } -#ariane{ - position:initial; -} -#headerV2 .divider{ - background-color: #009DC5 !important; -} -#headerPos{ - margin-top: 3px; -} -#menuList{ - font-size:20px; - height: 40px; -} -#menuList .dropdown-toggle{ - padding-bottom: 8px; - color:white; - font-weight:bold; -} -#menuListContent{ - background-color: #CEE9F1; - border: solid 2px #009DC5; - box-shadow: none; - width: 247px; - padding-bottom: 0px; -} - -#menuListContent a{ - color: #0094D0; - font-size: 12px; - font-weight: normal; - letter-spacing: 0.02em; -} - -#headerPos .navbar-text{ - position: absolute; - margin: 0px; - padding: 15px; - padding-top: 5px; - background: #f2f2f2; - width: 80%; - height: 44px; - top: 26px; - border-top-left-radius: 3px; - left: 262px; - color: #009dc5; - font-weight: bold; - font-size: 1.3em; -} -#headerLogoPos{ - background-color:#f2f2f2; - margin-right:-30px; - margin-top:-34px; -} -#headerLogo{ - margin: 0px; - padding-right: 0px; - padding-top: 0px; - height: 56px; - width: 176px; - background: url(static.php?filename=default_nav_logo_maarch.gif) #f2f2f2; - background-size: 90%; - background-position: center; - background-repeat: no-repeat; -} - -#headerNotification .link{ - text-decoration: underline; - cursor: pointer; -} -#headerNotification .dropdown-menu .badge{ - font-size: 70%; -} -#headerNotification .alert-info a{ - color: #31708f !important; -} -#headerNotification .alert-warning a{ - color: #8a6d3b !important; -} -#headerNotification .alert-danger a{ - color: #a94442 !important; -} - -#menuListContentInfoUser{ - background-color: #1B91BA; - height: 15px; - width: 100%; - font-weight: bold; - font-size: 0.8em; - padding-right: 5px; - padding-left: 5px; - padding-top: 0px; - border-top: 2px solid #FFFFFF; - position: relative; - bottom: 0; -} - -#menuListContentInfoUser span{ - float:left; - font-weight: bold; - font-size: 0.8em; -} -#menuListContentInfoUser a{ - float:right; - font-weight: bold; - font-size: 0.8em; - clear: none; - color: white; - padding: 0px; -} -#menuListContentInfoUser a:hover,#menuListContentInfoUser a:focus{ - background-color: initial; -} - -.notification .badge { - background-color: #a94442; - font-size: 9px; - position: relative; - left: -10px; - top: 5px; -} \ No newline at end of file diff --git a/apps/maarch_entreprise/js/angular/app/header.component.js b/apps/maarch_entreprise/js/angular/app/header.component.js index 37e2700ffd6..de807b59a8a 100755 --- a/apps/maarch_entreprise/js/angular/app/header.component.js +++ b/apps/maarch_entreprise/js/angular/app/header.component.js @@ -14,17 +14,38 @@ var http_1 = require("@angular/common/http"); var HeaderComponent = (function () { function HeaderComponent(http) { this.http = http; - this.lang = {}; - this.resultInfo = ""; - this.loading = false; + this.applicationName = ""; + this.adminList = []; + this.adminListModule = []; + this.menuList = []; + this.profilList = []; + this.notifList = []; } HeaderComponent.prototype.prepareHeader = function () { - $j('#header').remove(); + $j('#maarch_content').remove(); }; HeaderComponent.prototype.ngOnInit = function () { + var _this = this; this.prepareHeader(); this.coreUrl = angularGlobals.coreUrl; - this.loading = true; + this.http.get(this.coreUrl + 'rest/administration') + .subscribe(function (data) { + _this.menuList = data.menu.menuList; + _this.applicationName = data.menu.applicationName[0]; + _this.adminList = data.application; + _this.adminListModule = data.modules; + }); + this.profilList = [ + { + label: 'Mon profil', + link: '/profile', + style: 'fa-user' + }, + { label: 'Déconnexion', + link: '/logout', + style: 'fa-sign-out' + } + ]; }; return HeaderComponent; }()); @@ -34,7 +55,6 @@ HeaderComponent = __decorate([ templateUrl: angularGlobals["headerView"], styleUrls: [ 'css/header.component.css', - '../../node_modules/bootstrap/dist/css/bootstrap.min.css' //load bootstrap css ] }), __metadata("design:paramtypes", [http_1.HttpClient]) diff --git a/apps/maarch_entreprise/js/angular/app/header.component.ts b/apps/maarch_entreprise/js/angular/app/header.component.ts index 711c272d854..e3015adc887 100755 --- a/apps/maarch_entreprise/js/angular/app/header.component.ts +++ b/apps/maarch_entreprise/js/angular/app/header.component.ts @@ -10,26 +10,26 @@ declare var angularGlobals : any; selector: 'menu-app', templateUrl : angularGlobals["headerView"], styleUrls : [ - 'css/header.component.css', //load specific custom css - '../../node_modules/bootstrap/dist/css/bootstrap.min.css' //load bootstrap css - ] + 'css/header.component.css', //load specific custom css + ] }) export class HeaderComponent implements OnInit { coreUrl : string; - lang : any = {}; - table : any; - - resultInfo : string = ""; - loading : boolean = false; + applicationName : string = ""; + adminList : any[] = []; + adminListModule : any[] = []; + menuList : any[] = []; + profilList : any[] = []; + notifList : any[] = []; constructor(public http: HttpClient) { } prepareHeader() { - $j('#header').remove(); + $j('#maarch_content').remove(); } ngOnInit(): void { @@ -37,7 +37,24 @@ export class HeaderComponent implements OnInit { this.coreUrl = angularGlobals.coreUrl; - this.loading = true; - + this.http.get(this.coreUrl + 'rest/administration') + .subscribe((data : any) => { + this.menuList = data.menu.menuList; + this.applicationName = data.menu.applicationName[0]; + this.adminList = data.application; + this.adminListModule = data.modules; + }); + + this.profilList = [ + { + label : 'Mon profil', + link : '/profile', + style : 'fa-user' + }, + { label : 'Déconnexion', + link : '/logout', + style : 'fa-sign-out' + } + ] } } diff --git a/core/Models/ServiceModelAbstract.php b/core/Models/ServiceModelAbstract.php index 59354d3cfde..4808ce27811 100755 --- a/core/Models/ServiceModelAbstract.php +++ b/core/Models/ServiceModelAbstract.php @@ -41,6 +41,7 @@ class ServiceModelAbstract return $applicationServices; } + public static function getApplicationAdministrationServicesByUserServices(array $aArgs = []) { ValidatorModel::notEmpty($aArgs, ['userServices']); @@ -145,6 +146,138 @@ class ServiceModelAbstract return $modulesServices; } + public static function getApplicationAdministrationMenuByXML() + { + $customId = CoreConfigModel::getCustomId(); + + if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/menu.xml")) { + $path = "custom/{$customId}/apps/maarch_entreprise/xml/menu.xml"; + } else { + $path = 'apps/maarch_entreprise/xml/menu.xml'; + } + + $modulesServices = []; + + $xmlfile = simplexml_load_file($path); + foreach ($xmlfile->MENU as $value) { + + $label = defined((string)$value->libconst) ? constant((string)$value->libconst) : (string)$value->libconst; + + $modulesServices['menuList'][] = [ + 'id' => (string) $value->id, + 'label' => $label, + 'link' => (string) $value->url, + 'icon' => (string)$value->style, + 'angular' => empty((string)$value->angular) ? 'false' : (string)$value->angular + ]; + + } + if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { + $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; + } else { + $path = 'apps/maarch_entreprise/xml/config.xml'; + } + $xmlfile = simplexml_load_file($path); + $modulesServices['applicationName'] = $xmlfile->CONFIG->applicationname; + foreach ($xmlfile->MODULES as $mod) { + $path = false; + $module = (string)$mod->moduleid; + + if (file_exists("custom/{$customId}/modules/{$module}/xml/menu.xml")) { + $path = "custom/{$customId}/modules/{$module}/xml/menu.xml"; + } else if (file_exists("modules/{$module}/xml/menu.xml")) { + $path = "modules/{$module}/xml/menu.xml"; + } + if ($path) { + $xmlfile = simplexml_load_file($path); + foreach ($xmlfile->MENU as $value) { + $id = (string) $value->id; + + $label = defined((string)$value->libconst) ? constant((string)$value->libconst) : (string)$value->libconst; + + $modulesServices['menuList'][] = [ + 'id' => (string) $value->id, + 'label' => $label, + 'link' => (string) $value->url, + 'icon' => (string)$value->style, + 'angular' => empty((string)$value->angular) ? 'false' : (string)$value->angular + ]; + + } + } + } + return $modulesServices; + } + + public static function getApplicationAdministrationMenuByUserServices(array $aArgs = []) + { + ValidatorModel::notEmpty($aArgs, ['userServices']); + ValidatorModel::arrayType($aArgs, ['userServices']); + + $customId = CoreConfigModel::getCustomId(); + + if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/menu.xml")) { + $path = "custom/{$customId}/apps/maarch_entreprise/xml/menu.xml"; + } else { + $path = 'apps/maarch_entreprise/xml/menu.xml'; + } + + $modulesServices = []; + + $xmlfile = simplexml_load_file($path); + foreach ($xmlfile->MENU as $value) { + if (in_array((string) $value->id, $aArgs['userServices'])) { + + $label = defined((string)$value->libconst) ? constant((string)$value->libconst) : (string)$value->libconst; + + $modulesServices['menuList'][] = [ + 'id' => (string) $value->id, + 'label' => $label, + 'link' => (string) $value->url, + 'icon' => (string)$value->style, + 'angular' => empty((string)$value->angular) ? 'false' : (string)$value->angular + ]; + } + } + if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { + $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; + } else { + $path = 'apps/maarch_entreprise/xml/config.xml'; + } + $xmlfile = simplexml_load_file($path); + $modulesServices['applicationName'] = $xmlfile->CONFIG->applicationname; + foreach ($xmlfile->MODULES as $mod) { + $path = false; + $module = (string)$mod->moduleid; + + if (file_exists("custom/{$customId}/modules/{$module}/xml/menu.xml")) { + $path = "custom/{$customId}/modules/{$module}/xml/menu.xml"; + } else if (file_exists("modules/{$module}/xml/menu.xml")) { + $path = "modules/{$module}/xml/menu.xml"; + } + if ($path) { + $xmlfile = simplexml_load_file($path); + foreach ($xmlfile->MENU as $value) { + $id = (string) $value->id; + + if (in_array((string) $value->id, $aArgs['userServices'])) { + + $label = defined((string)$value->libconst) ? constant((string)$value->libconst) : (string)$value->libconst; + + $modulesServices['menuList'][] = [ + 'id' => (string) $value->id, + 'label' => $label, + 'link' => (string) $value->url, + 'icon' => (string)$value->style, + 'angular' => empty((string)$value->angular) ? 'false' : (string)$value->angular + ]; + } + } + } + } + return $modulesServices; + } + public static function getAdministrationServicesByUserId(array $aArgs = []) { ValidatorModel::notEmpty($aArgs, ['userId']); @@ -157,6 +290,7 @@ class ServiceModelAbstract } $administration = []; + $administration['menu'] = ServiceModel::getApplicationAdministrationMenuByUserServices(['userServices' => $servicesStoredInDB]); $administration['application'] = ServiceModel::getApplicationAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]); $administration['modules'] = ServiceModel::getModulesAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]); -- GitLab