Subversion Repositories bacoAlunos

Rev

Rev 1580 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@ page import="jomm.dao.impl.AbstractDao" %>
<%@ page import="jomm.utils.MessageResources" %>
<%@ page import="pt.estgp.estgweb.domain.JobServiceTaskImpl" %>
<%@ page import="pt.estgp.estgweb.domain.QuestionarioReportFileGroupImpl" %>
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
<%@ page import="pt.estgp.estgweb.web.form.configuration.SchedulleTasksForm" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
<%--
  Created by IntelliJ IDEA.
  User: jorgemachado
  Date: 29/12/16
  Time: 11:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String id = request.getParameter("questionarioReportFileGroup.id");
    AbstractDao.getCurrentSession().beginTransaction();
    QuestionarioReportFileGroupImpl group = (QuestionarioReportFileGroupImpl) DaoFactory.getQuestionarioReportFileGroupDaoImpl().load(Long.parseLong(id));
    request.setAttribute("group",group);


    JobServiceTaskImpl job = group.getReportGenerationTaskId() > 0 ?
            (JobServiceTaskImpl) DaoFactory.getJobServiceTaskDaoImpl().load(group.getReportGenerationTaskId()) :
            null;
    request.setAttribute("Job", job);

%>


<div class="panel panel-default" id="reportParameterInputsApp" ng-app="reportParameterInputsApp" ng-controller="reportParameterInputsAppController">
    <div class="panel-heading">
        Administração do Report ${group.id}
    </div>
    <div class="panel-body">
        <html:form styleClass="form-horizontal"  action="/user/questionariosReportsPae">
            <div class="web-messages"></div><!--For Widgets Use-->
            <html:errors/>
            <jomm:messages/>
            <jsp:useBean id="QuestionarioReportGroupForm" type="pt.estgp.estgweb.web.form.questionarios.QuestionarioReportGroupForm" scope="request"/>

            <%
                QuestionarioReportGroupForm.setQuestionarioReportFileGroup(group);
            %>
            <html:hidden property="questionarioReportFileGroup.id"/>
            <html:hidden property="parametersArrayObtainedFromWidget" value="{{ inputsJson }}"/>
            <html:hidden property="questionarioReportFileGroup.reportProcessorClass"/>
            <input type="hidden" name="dispatch" value="save"/>
            <div class="form-group">
                <label class="col-md-2 control-label">Titulo do Grupo de Relatórios</label>
                <div class="col-md-10">
                    <html:text styleClass="form-control" property="questionarioReportFileGroup.title"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">Tipo</label>
                <div class="col-md-10">
                    <label class="bg-info" style="padding:2px"><bean:message key="${group.reportProcessorClass}"/></label>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label">Parametros de Serviço</label>
                <div class="col-md-6">
                    <div class="list-group">
                        <div class="list-group-item" ng-repeat="i in inputsJson">
                            <div class="list-group-item"><label class="bg-info"/>{{ i.name }}</label>: {{ i.value }}</div>
                        </div>
                    </div>
                </div>
                <script>

                    //DECLARACAO DA APLICACAO LOCAL EM ANGULAR
                    var reportParameterInputsApp = angular.module('reportParameterInputsApp', []);
                    GLOBAL_BacoAngularAppDependencies.push('reportParameterInputsApp');

                    reportParameterInputsApp.controller('reportParameterInputsAppController', function($scope) {
                        $scope.inputsJson = <%=group.getInputsJson()%>;//apenas para a vista
                    });

                    function reloadInputs()
                    {

                        widgetCallWithParameters("reloadInputs",

                                { "questionarioReportFileGroup.id" : ${group.id} },

                                $("#reportParameterInputsApp form")[0], //tem d ser com [0] para obter o JavaScript Object original e nao o prototype do JQUERY
                                                                        // apenas para uso do div web-messages

                                function(response)
                                {
                                    angular.element($("#reportParameterInputsApp")).scope().inputsJson = response.jsonInputs;
                                    angular.element($("#reportParameterInputsApp")).scope().$apply();
                                }
                        );
                    }
                </script>
                <div class="col-md-4">
                    <a class="btn btn-default" href="#"
                       data-callback-target-function="reloadInputs"
                       data-href="<%=request.getContextPath()%>${group.reportGeneratorInstance.widgetAdminInterface}?questionarioReportFileGroup.id=${group.id}" data-title="Administração de Parametros de Serviço" data-toggle="modal" data-target="#modalAjaxRequest">
                        <span class="glyphicon glyphicon-wrench"> </span> Parametros
                    </a>
                </div>



                <div class="col-sm-12">
                    <%
                        if(job != null)
                        {
                            SchedulleTasksForm schedulleTasksForm = new SchedulleTasksForm();
                            schedulleTasksForm.setJobServiceTask(job);
                            schedulleTasksForm.setId(job.getId());
                            request.setAttribute("SchedulleTasksForm",schedulleTasksForm);
                            if(job.getStatusEnum() == JobServiceTaskImpl.JobStatus.FAILED ||
                                    job.getStatusEnum() == JobServiceTaskImpl.JobStatus.UNKNOWN_ERROR ||
                                    job.getStatusEnum() == JobServiceTaskImpl.JobStatus.FINISHED_ERRORS )
                            {
                    %>
                    <div class="alert alert-danger"><%=MessageResources.getInstance(request).getMessage("job.status."+job.getStatus())%>, Consulte o Log</div>
                    <%
                        }
                    %>
                    <div class="task-log task-log-xs" data-href="<%=request.getContextPath()%>/user/startAdminQuestionariosReportsGroup.do?questionarioReportFileGroup.id=${group.id}">
                        <jsp:include page="/admin/configuration/taskLog.jsp"/>
                    </div>
                    <%
                    }
                    else
                    {
                    %>
                    <div class="alert alert-danger">O sistema não conseguiu encontrar a tarefa de atribuição nas tarefas agendadas, por favor verifique em todos os logs de tarefas <html:link action="/user/configurationJobTasks">Aqui</html:link> </div>
                    <%
                        }
                    %>
                    </div>

            </div>
            <button type="button" class="btn btn-warning" onclick="set(form,'runJobGenerate'),form.submit();">Gerar Relatórios</button>
        </html:form>
    </div>
</div>

<%
    AbstractDao.getCurrentSession().getTransaction().commit();
%>

Generated by GNU Enscript 1.6.5.2.