460 lines
19 KiB
Twig
460 lines
19 KiB
Twig
|
|
{% extends '@CadolesCore/base.html.twig' %}
|
|
|
|
{% block localstyle %}
|
|
body{overflow-y:hidden}
|
|
{% endblock %}
|
|
|
|
{% block appmenu %}
|
|
<ul class="nav navbar-top-links navbar-left">
|
|
{% for page in pagesadmin %}
|
|
{% set forcereload=true %}
|
|
{% if page.pagecategory.id==1 %}
|
|
{% set forcereload=false %}
|
|
{% endif %}
|
|
|
|
{% if entity.id is defined and page.id==entity.id %}
|
|
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer"><a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{forcereload}}')">{{ page.name }}</a></li>
|
|
{% else %}
|
|
<li id="menupage-{{page.id}}"><a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','portal','{{forcereload}}')">{{ page.name }}</a></li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
|
|
<ul id="pagesuser" class="nav navbar-top-links navbar-left">
|
|
{% for page in pagesuser %}
|
|
{% set forcereload=true %}
|
|
{% if page.pagecategory.id==1 %}
|
|
{% set forcereload=false %}
|
|
{% endif %}
|
|
|
|
{% if entity.id is defined and page.id==entity.id %}
|
|
<li id="menupage-{{page.id}}" class="active" style="cursor:pointer"><a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{forcereload}}')"><i class="fa fa-user fa-fw"></i> {{ page.name }}</a></li>
|
|
{% else %}
|
|
<li id="menupage-{{page.id}}"><a style="cursor:pointer" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','user','{{forcereload}}')"><i class="fa fa-user fa-fw"></i> {{ page.name }}</a></li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
|
|
<ul id="pagesgroup" class="nav navbar-top-links navbar-left">
|
|
{% for groupshared in groupsshared %}
|
|
{% if groupshared.pagesshared|length == 1 %}
|
|
{% set page = groupshared.pagesshared[0] %}
|
|
{% set forcereload=true %}
|
|
{% if page.pagecategory.id==1 %}
|
|
{% set forcereload=false %}
|
|
{% endif %}
|
|
|
|
{% set isactive="" %}
|
|
{% if entity.id is defined and page.id==entity.id %}
|
|
{% set isactive="class='active'" %}
|
|
{% endif %}
|
|
|
|
<li id="menupage-{{page.id}}" {{ isactive }} style="cursor:pointer">
|
|
<a data-group="{{groupshared.id}}" onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','group','{{forcereload}}','{{groupshared.id}}')">
|
|
<i class="fa fa-users fa-fw"></i> {{ groupshared.label }}
|
|
{% if page.counterread > 0 %}
|
|
<span id="badge-{{groupshared.id}}" class="badge">{{page.counterread}}</span>
|
|
{% endif %}
|
|
</a>
|
|
</li>
|
|
{% else %}
|
|
<ul id="pagesshared" class="nav navbar-top-links navbar-left">
|
|
<li class="dropdown">
|
|
<a data-group="{{groupshared.id}}" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
|
<i class="fa fa-users fa-fw"></i> {{ groupshared.label }}
|
|
<span class="caret"></span>
|
|
{% if groupshared.pagesshared[0].counterread > 0 %}
|
|
<span id="badge-{{groupshared.id}}" class="badge">{{groupshared.pagesshared[0].counterread}}</span>
|
|
{% endif %}
|
|
</a>
|
|
|
|
<ul class="dropdown-menu">
|
|
{% for page in groupshared.pagesshared %}
|
|
{% set forcereload=true %}
|
|
{% if page.pagecategory.id==1 %}
|
|
{% set forcereload=false %}
|
|
{% endif %}
|
|
|
|
{% set isactive="" %}
|
|
{% if entity.id is defined and page.id==entity.id %}
|
|
{% set isactive="class='active'" %}
|
|
{% endif %}
|
|
|
|
<li id="menupage-{{page.id}}" {{isactive}} style="cursor:pointer">
|
|
<a onClick="showPage({{ page.id }},{{ page.pagecategory.id }},'{{ page.canupdate }}','group','{{forcereload}}','{{groupshared.id}}')">
|
|
{{ page.name }}
|
|
</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
|
|
|
|
<div id="menupageaction">
|
|
{% if canadd %}
|
|
<a id="menusubmit" style="cursor:pointer" onclick="submitPage()" title='Ajouter une page'><i class='fa fa-plus fa-fw'></i></a>
|
|
{% endif %}
|
|
<a id="menuupdate" style="cursor:pointer;display:none" onclick="updatePage()" title='Modifier une page'><i class='fa fa-file fa-fw'></i></a>
|
|
<a id="menushare" style="cursor:pointer;display:none" onclick="sharePage()" title='Partager une page'><i class='fa fa-share-alt fa-fw'></i></a>
|
|
<a id="menudelete" style="cursor:pointer;display:none" onclick="deletePage()" title='Supprimer une page'><i class='fa fa-trash fa-fw'></i></a>
|
|
<a id="menuwidgetuser" style='cursor:pointer;display:none' data-toggle='modal' data-target='#selwidgetuser' title='Ajouter un widget'><i class='fa fa-cubes fa-fw'></i></a>
|
|
<a id="menuwidgetgroup" style='cursor:pointer;display:none' data-toggle='modal' data-target='#selwidgetgroup' title='Ajouter un widget'><i class='fa fa-cubes fa-fw'></i></a>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block pagewrapper %}
|
|
<div id="pagecontainer" style="margin: 0px -30px;"></div>
|
|
|
|
<div id="selwidgetuser" class="modal fade bs-item-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
<h4 class="modal-title">SELECTIONNER UN WIDGET</h4>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
<div class="form-group row clearfix">
|
|
<div class="col-md-12" style="margin-bottom:15px">
|
|
<a onclick="$('#selwidgetuser').modal('hide');" class="btn btn-default">
|
|
Annuler
|
|
</a>
|
|
</div>
|
|
|
|
<div class="dataTable_wrapper col-md-12">
|
|
<table id="dataTables" class="table table-bordered table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th width="100px">#</th>
|
|
<th>Nom</th>
|
|
<th class="no-sort">Description</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
{% for widget in widgetsuser %}
|
|
<tr>
|
|
<td>
|
|
<a onClick="selWidget({{ widget.id }})" style="cursor:pointer;">
|
|
<img id="widgettype-{{ widget.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ widget.icon.label }}" style="padding:2px">
|
|
</a>
|
|
</td>
|
|
<td>{{ widget.name }}</td>
|
|
<td>{{ widget.description }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="selwidgetgroup" class="modal fade bs-item-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
<h4 class="modal-title">SELECTIONNER UN WIDGET</h4>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
<div class="form-group row clearfix">
|
|
<div class="col-md-12" style="margin-bottom:15px">
|
|
<a onclick="$('#selwidgetgroup').modal('hide');" class="btn btn-default">
|
|
Annuler
|
|
</a>
|
|
</div>
|
|
|
|
<div class="dataTable_wrapper col-md-12">
|
|
<table id="dataTables" class="table table-bordered table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th width="100px">#</th>
|
|
<th>Nom</th>
|
|
<th class="no-sort">Description</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
{% for widget in widgetsgroup %}
|
|
<tr>
|
|
<td>
|
|
<a onClick="selWidget({{ widget.id }})" style="cursor:pointer;">
|
|
<img id="widgettype-{{ widget.id }}" class="grid-item-img" height="40" src="/{{ alias }}/{{ widget.icon.label }}" style="padding:2px">
|
|
</a>
|
|
</td>
|
|
<td>{{ widget.name }}</td>
|
|
<td>{{ widget.description }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{%if app.user %}
|
|
<a id="refreshcounter" data-event=""></a>
|
|
{% endif %}
|
|
|
|
{% endblock %}
|
|
|
|
{% block localexternalscript %}
|
|
{% if app.user %}
|
|
<script src="/{{alias}}/bundles/goswebsocket/js/vendor/autobahn.min.js"></script>
|
|
<script src="/{{alias}}/bundles/goswebsocket/js/gos_web_socket_client.js"></script>
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block localjavascript %}
|
|
var idpage;
|
|
|
|
$('document').ready(function(){
|
|
{% for page in pagesadmin %}
|
|
{% if page.id==entity.id %}
|
|
showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','portal');
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% for page in pagesuser %}
|
|
{% if page.id==entity.id %}
|
|
showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','user');
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% for groupshared in groupsshared %}
|
|
{% for page in groupshared.pagesshared %}
|
|
{% if page.id==entity.id %}
|
|
showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','group',true,{{groupshared.id}});
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
|
|
// Rendre les pages user déplacable
|
|
$("#pagesuser").sortable({
|
|
axis: "x",
|
|
forcePlaceholderSize: true,
|
|
placeholder: "placeholder",
|
|
update: function( event, ui ) {
|
|
$('#pagesuser li').each(function(order) {
|
|
var idpage=$(this).attr('id').replace("menupage-","");
|
|
$.ajax({
|
|
method: "POST",
|
|
url: "{{ path('cadoles_portal_'~access~'_page_order') }}",
|
|
data: {
|
|
id:idpage,
|
|
order:order
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
// Initialisation du tableau des widgets selectionnable à la création
|
|
$('.table').DataTable({
|
|
columnDefs: [ { "targets": 'no-sort', "orderable": false }, { "targets": 0, "className": "text-center" } ],
|
|
responsive: true,
|
|
iDisplayLength: 10,
|
|
order: [[ 1, "asc" ]],
|
|
});
|
|
|
|
// Init socket de counter
|
|
{% if websocket_activate %}
|
|
var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}";
|
|
|
|
var webSocket = WS.connect(_WS_URI);
|
|
|
|
webSocket.on("socket/connect", function (session) {
|
|
// The callback function in "subscribe" is called everytime an event is published in that channel.
|
|
session.subscribe("websocket/counter", function (uri, payload) {
|
|
if(payload.log) {
|
|
console.log("Received message", payload.log);
|
|
}
|
|
if(payload.alert) {
|
|
alert(payload.alert);
|
|
}
|
|
if(payload.from!={{app.user.id}}) {
|
|
menu=$("a[data-group='"+payload.group+"']");
|
|
if(menu.length) {
|
|
if(payload.add) {
|
|
console.log("Ajout counter pour group "+payload.group+" by "+payload.from);
|
|
if(menu.children(".badge").length) {
|
|
menu.children(".badge").html(+(menu.children(".badge").html())+1);
|
|
}
|
|
else menu.append("<span id='badge-"+payload.group+"' class='badge'>1</span");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$(document).on('click', '#refreshcounter', function(){
|
|
event=$(this).data("event");
|
|
event.userid={{app.user.id}}
|
|
session.publish("websocket/counter", event);
|
|
});
|
|
});
|
|
{% endif %}
|
|
});
|
|
|
|
$(window).resize(function() {
|
|
resizeFrame();
|
|
});
|
|
|
|
function resizeFrame() {
|
|
var iFrame = document.getElementById('frameContent');
|
|
|
|
var heightbody = $('html').height();
|
|
var heightheader = $('.header').height();
|
|
if($('#appmenu').css("display")=="none")
|
|
var heightmenu = 0;
|
|
else
|
|
var heightmenu = $('#appmenu').height();
|
|
|
|
|
|
var heightframe = heightbody-heightheader-heightmenu;
|
|
|
|
$(".pageframe").each(function( index ) {
|
|
$(this).height(heightframe);
|
|
});
|
|
}
|
|
|
|
|
|
// Affichage des frames associés aux items de bureau
|
|
function showFrameitem(id,url,forcereload) {
|
|
$(".pageframe").hide();
|
|
|
|
// Si force le rechargement et frame existante on la détruit
|
|
if(forcereload&&$("#frameitem-"+id).length)
|
|
$("#frameitem-"+id).remove();
|
|
|
|
// Si la frame en cours existe déjà on l'affiche
|
|
if($("#frameitem-"+id).length)
|
|
$("#frameitem-"+id).show();
|
|
// Sinon on la génère
|
|
else
|
|
$("#pagecontainer").append("<iframe id='frameitem-"+id+"' class='pageframe' src='"+url+"' style='border:none; width:100%'></iframe>");
|
|
|
|
|
|
resizeFrame();
|
|
}
|
|
|
|
// Affichages des pages
|
|
function showPage(id,catid,canupdate,usage,forcereload,groupid) {
|
|
// Sauvegarder la page en cours
|
|
idpage=id;
|
|
|
|
// Cacher toutes les pages
|
|
$(".pageframe").hide();
|
|
|
|
// Rendre actif le page en cours dans le menu
|
|
$(".navbar-top-links li").removeClass("active");
|
|
$("#menupage-"+id).addClass("active");
|
|
|
|
var url="{{ path('cadoles_portal_user_page_view',{id:'xx',usage:'yy','group':'zz'}) }}";
|
|
url=url.replace('xx',id);
|
|
url=url.replace('yy',usage);
|
|
url=url.replace('zz',groupid);
|
|
|
|
// Si force le rechargement et frame existante on la détruit
|
|
if(forcereload&&$("#page-"+id).length)
|
|
$("#page-"+id).remove();
|
|
|
|
// Si la frame en cours existe déjà on l'affiche
|
|
if($("#page-"+id).length)
|
|
$("#page-"+id).show();
|
|
// Sinon on la génère
|
|
else
|
|
$("#pagecontainer").append("<iframe id='page-"+id+"' data-category='"+catid+"' class='pageframe' src='"+url+"' style='border:none; width:100%'></iframe>");
|
|
|
|
// Détruire le badge associé car normalement de fait on a lu les notif
|
|
if(usage=="group") {
|
|
$("#badge-"+groupid).remove()
|
|
}
|
|
|
|
|
|
// Cacher les actions possibles sur la page
|
|
$("#menuupdate").hide();
|
|
$("#menushare").hide();
|
|
$("#menudelete").hide();
|
|
$("#menuwidgetuser").hide();
|
|
$("#menuwidgetgroup").hide();
|
|
|
|
if(canupdate) {
|
|
$("#menuupdate").show();
|
|
$("#menushare").show();
|
|
$("#menudelete").show();
|
|
}
|
|
|
|
// Si page de type widget on affiche la selection des widgets à insérer
|
|
if($("#page-"+id).data('category')==2&&canupdate) {
|
|
if(usage=="user") $("#menuwidgetuser").show();
|
|
if(usage=="group") $("#menuwidgetgroup").show();
|
|
|
|
}
|
|
|
|
|
|
// On resize les frame
|
|
resizeFrame();
|
|
}
|
|
|
|
function submitPage() {
|
|
var url="{{ path('cadoles_portal_'~access~'_page_submit') }}";
|
|
$(location).attr('href',url);
|
|
}
|
|
|
|
function updatePage() {
|
|
if($("#page-"+idpage).length) {
|
|
var url="{{ path('cadoles_portal_'~access~'_page_update',{id:'xx'}) }}";
|
|
url=url.replace('xx',idpage);
|
|
|
|
$(location).attr('href',url);
|
|
}
|
|
}
|
|
|
|
function sharePage() {
|
|
if($("#page-"+idpage).length) {
|
|
var url="{{ path('cadoles_portal_'~access~'_page_share',{id:'xx'}) }}";
|
|
url=url.replace('xx',idpage);
|
|
|
|
$(location).attr('href',url);
|
|
}
|
|
}
|
|
|
|
function deletePage() {
|
|
if($("#page-"+idpage).length) {
|
|
if (confirm('Êtes-vous sûr de vouloir supprimer ?')) {
|
|
var url="{{ path('cadoles_portal_'~access~'_page_delete',{id:'xx'}) }}";
|
|
url=url.replace('xx',idpage);
|
|
|
|
$(location).attr('href',url);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Création d'un widget selectionné
|
|
function selWidget(idwidgettype) {
|
|
var url="{{ path('cadoles_portal_user_pagewidget_widget_sumbit',{idpage:'yy',idwidgettype:'xx'})}}";
|
|
url=url.replace('xx',idwidgettype);
|
|
url=url.replace('yy',idpage);
|
|
|
|
$(location).attr('href', url);
|
|
};
|
|
|
|
// Permet de déclencher l'évenement de modification des counter
|
|
function counter(event) {
|
|
$('#refreshcounter').data("event",event);
|
|
$('#refreshcounter').click();
|
|
};
|
|
{% endblock %}
|