<%@page session="true"%><%@ page language="java"%> <%@ page import="com.edeal.frontline.Utils" language="java" import="java.util.*" import="com.edeal.frontline.*,com.edeal.frontline.helper.custom.*" pageEncoding="UTF-8"%><%@ page import="com.edeal.frontline.FrontlineException" %><%@ page import="com.edeal.frontline.FlContext" %><%@ page import="com.edeal.frontline.navigation.FlRequest" %> <%@page import="com.edeal.frontline.controller.actions.ReprogramAlarmAction"%><%@page import="com.edeal.frontline.controller.actions.DeleteAlarmAction"%><%@page import="com.edeal.frontline.controller.actions.MarkInformationPanelAsReadAction"%><%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><% response.setContentType("application/x-javascript"); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); DataDictionary dico = context.getDataDictionary(); String idAdmin = dico.getRefIdByCode("DocRolesID", "ADMIN"); /* Recherche des roles de l'acteur */ String sessionActorID = ActorHelper.getSessionActorID(session); boolean isAdmin = ActorHelper.isAdmin(flRequest); // can create info panel ? InformationPanelBean ibp = new InformationPanelBean(session); boolean canCreateInfoPanel = false; try { canCreateInfoPanel = ibp.enforceAccess(AccessControlManager.CREATE, sessionActorID); } catch (FrontlineException fe) { } boolean canEditInfoPanel = false; try { canEditInfoPanel = ibp.enforceAccess(AccessControlManager.EDIT, sessionActorID); } catch (FrontlineException fe) { } %> /* The shape of the json string is : { "body":"Grande salle de réunion formation administrati...", "dat":"16:50", "from":"", "id":"00000000000ac979", "subject":"Formation UNIX", "type":"Alarm" } */ var defaultMessage = ''; var withScoll = "false"; <% if (canCreateInfoPanel) { %> var doCreateInformationPanelFunction = 'javascript:doCreateInformationPanel();' var link = '<fl:getMessage code=" title="" class="infobar-icon">'; defaultMessage = '
' + defaultMessage + '' + link + '
'; <% } %> var objectDisplayFunction = new Object(); //Construction of the information to be displayed . Objects : Alarm and InformationPanel ... objectDisplayFunction["Alarm"] = function(information) { // attributes var infoId = "'" + information.id + "'"; var infoType = "'" + information.type + "'"; var infoBody = decodeURIComponent(information.body); var infoSubject = decodeURIComponent(information.subject); var infoDate = information.dat; // functions var openPopupFunction = 'javascript:openPopup(' + infoId + ',' + infoType + ');' var doReprogramAlarmFunction = 'javascript:doReprogramAlarm(' + infoId + ');' var doDeleteAlarmFunction = 'javascript:doDeleteAlarm(' + infoId + ');' var doReadInformationPanelFunction = 'javascript:doReadInformationPanel(' + infoId + ');' // links var link_1 = '<fl:getMessage code=" title="" class="infobar-icon">'; var link_2 = '<fl:getMessage code=" title="" class="infobar-icon">'; // informations var informationToDisplay = '
' + infoDate + ' - ' + infoSubject + '' + link_1 + '
' + infoBody +'' + link_2 + '
'; informationToDisplay = addCommonElement(informationToDisplay, 'Alarme" >'); //Save withScoll withScoll = information.refresh; return informationToDisplay; }; objectDisplayFunction["InformationPanel"] = function(information) { // attributes var infoId = "'" + information.id + "'"; var infoType = "'" + information.type + "'"; var infoBody = decodeURIComponent(information.body); var infoSubject = decodeURIComponent(information.subject); var infoDate = information.dat; // functions var openPopupFunction = 'javascript:openPopup(' + infoId + ',' + infoType + ');' var doReprogramAlarmFunction = 'javascript:doReprogramAlarm(' + infoId + ');' var doDeleteAlarmFunction = 'javascript:doDeleteAlarm(' + infoId + ');' var doReadInformationPanelFunction = 'javascript:doReadInformationPanel(' + infoId + ');' var doCreateInformationPanelFunction = 'javascript:doCreateInformationPanel();' // links and informations <% if (canCreateInfoPanel) { %> var link_1 = '<fl:getMessage code=" title="" class="infobar-icon">'; var link_2 = '<fl:getMessage code=" title="" class="infobar-icon">'; informationToDisplay = '
' + infoDate + ' - ' + infoSubject + '' + link_1 + '
' + infoBody +'' + link_2 + '
'; <% } else {%> var link = '<fl:getMessage code=" title="" class="infobar-icon">'; informationToDisplay = '
' + infoDate + ' - ' + infoSubject + '
' + infoBody +'' + link + '
'; <% }%> informationToDisplay = addCommonElement(informationToDisplay, 'Panneau d\\\'information" />'); //Save withScoll withScoll = information.refresh; return informationToDisplay; }; function getInformationToDisplay(information){ return ((information.type != null) && (information.type != '')) ? objectDisplayFunction[information.type](information) : ''; } function displayInformationOnInfoBar(info){ $("#infobar_information").html(info); if (withScoll == "true"){ $("#infobar_information").slideUp("normal"); $("#infobar_information").slideDown("normal"); } } function getInfoBarInformation(forceupdate) { if ((forceupdate == null) || (typeof forceupdate == 'undefined')){ forceupdate = "false"; } else { forceupdate = "true"; } $.ajax({ url:"/get_infobar_information.fl?forceupdate=" + forceupdate, dataType: 'json', success: analyseResponse, type: "POST", timeout: 20000 }); function analyseResponse(information) { if ((information != null) && (information.type != null) && (information.type != '')) { var informationToDisplay = getInformationToDisplay(information); if (informationToDisplay == '') displayInformationOnInfoBar(addCommonElement(defaultMessage)); else displayInformationOnInfoBar(getInformationToDisplay(information)); } else { displayInformationOnInfoBar(addCommonElement(defaultMessage)); } } } function addCommonElement(info, imag){ if (imag == null) imag = ''; contentHTML = '
'+ imag + '' + info + '
'; return contentHTML; } $.setupJMPopups({ screenLockerBackground: "#222222", screenLockerOpacity: "0.3" }); function openPopup(id, type) { if ((id == null) || (type == null)) return; if (type == "Alarm") { namePopup = "alarmPopup"; urlPopup = "/open_popup_alarm.fl?id=" + id; openAjaxPopup(namePopup, urlPopup); } else if (type == "InformationPanel") { <% if (canEditInfoPanel) { %> //modification namePopup = "informationpanelPopup"; urlPopup = "/open_popup_informationpanel.fl?id=" + id; openJSPopup(namePopup, urlPopup); <% } else { %> //consultation namePopup = "informationpanelPopup"; urlPopup = "/open_popup_informationpanel_ajax.fl?id=" + id; openAjaxPopup(namePopup, urlPopup); <% } %> } } function openAjaxPopup(namePopup, urlPopup){ jQuery.openPopupLayer({ name: namePopup, width: 800, height: 250, url: urlPopup, cache: true, success: function (data) { }, error: function () { alert("Erreur lors de l'ouverture de la popup !"); } }); } function openJSPopup(namePopup, urlPopup){ var win = window.open(urlPopup, namePopup, 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=850,height=650'); } function doDeleteAlarm(id) { urlAjax("/delete_alarm_shortcut.fl?id=" + id); } function doReprogramAlarm(id, newdate) { url = "/reprogram_alarm_shortcut.fl?id=" + id if (newdate != null) url = url + "&newdate=" + newdate; urlAjax(url); } function doReadInformationPanel(id) { urlAjax("/mark_read_informationpanel.fl?id=" + id); } function doCreateInformationPanel() { namePopup = "informationpanelPopup"; urlPopup = "/open_popup_informationpanel.fl"; openJSPopup(namePopup, urlPopup); } function urlAjax(url){ $.ajax({ url: url, dataType:'text', async: false, success: analyseResponse }); function analyseResponse(response) { if (response != null){ switch(response) { case '<%= DeleteAlarmAction.ALARM_OK_DELETE %>': //displayMessage(''); break; case '<%= DeleteAlarmAction.ALARM_NO_DELETE %>': displayMessage(''); break; case '<%= ReprogramAlarmAction.ALARM_OK_REPROGRAM %>': //displayMessage(''); break; case '<%= ReprogramAlarmAction.ALARM_NO_REPROGRAM %>': displayMessage(''); break; case '<%= MarkInformationPanelAsReadAction.INFORMATIONPANEL_OK_READ %>': //displayMessage(''); break; case '<%= MarkInformationPanelAsReadAction.INFORMATIONPANEL_NO_READ %>': displayMessage(''); break; default: break; } } } //forcer la mise à jour des infos getInfoBarInformation("force_update"); } function displayMessage(message) { window.alert(message); }