Subversion Repositories bacoAlunos

Rev

Rev 1327 | Rev 1332 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1312 jmachado 1
<%@ page import="jomm.utils.MessageResources" %>
1076 jmachado 2
<%@ page import="pt.estgp.estgweb.domain.JobServiceTaskImpl" %>
1312 jmachado 3
<%@ page import="pt.estgp.estgweb.utils.ConfigProperties" %>
1328 jmachado 4
<%@ page import="jomm.utils.BytesUtils" %>
1076 jmachado 5
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
6
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
7
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
8
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
9
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
10
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
11
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
12
<%@ taglib prefix="hmlt" uri="http://jakarta.apache.org/struts/tags-html" %>
13
<jsp:useBean id="UserSession" type="pt.estgp.estgweb.domain.UserSession" scope="request"/>
14
<jsp:useBean id="SchedulleTasksForm" type="pt.estgp.estgweb.web.form.configuration.SchedulleTasksForm" scope="request"/>
15
<jomm:messages/>
16
<html:errors/>
17
 
1328 jmachado 18
<%
19
    String logid = "log" + BytesUtils.generateHexKey();
20
%>
1076 jmachado 21
 
1328 jmachado 22
<%--
23
    TaskLog styles
24
     normal or nothing in attribute
25
     task-log-xs  (only progress bar and log link download url)
26
     task-log-sm  (only progress bar,screen log small and log download url)
27
     task-log-md  (table info, progress bar, screen log small and log download url)
28
     task-log-lg  (panel title, table info, progress bar, screen log small and log download url)
29
---%>
1076 jmachado 30
 
1328 jmachado 31
 
32
<style>
33
    .task-log.task-log-xs *.task-log-panel > .panel-heading,
34
    .task-log.task-log-sm *.task-log-panel > .panel-heading,
35
    .task-log.task-log-md *.task-log-panel > .panel-heading
36
    {
37
        display: none !important;
38
    }
39
    .task-log.task-log-xs *.task-log-table,
40
    .task-log.task-log-sm *.task-log-table
41
    {
42
        display: none !important;
43
    }
44
    .task-log.task-log-sm *.task-log-screens
45
    {
46
        height: 50px !important;
47
        font-size: 0.8em !important;
48
    }
49
    .task-log.task-log-sm *.task-log-screens-toogle,
50
    .task-log.task-log-md *.task-log-screens-toogle,
51
    .task-log.task-log-lg *.task-log-screens-toogle
52
    {
53
        display: none !important;
54
    }
55
 
56
    .task-log.task-log-sm *.task-log-screens .screen,
57
    .task-log.task-log-xs *.task-log-screens .screen
58
    {
59
        height: 150px !important;
60
        width: 100%;
61
        font-size: 0.7em !important;
62
    }
63
    .task-log.task-log-sm *.task-log-screens .header h2, .task-log-sm .task-log-screens .header a,
64
    .task-log.task-log-xs *.task-log-screens .header h2, .task-log-xs .task-log-screens .header a{
65
        font-size: 0.7em !important;
66
    }
67
</style>
1076 jmachado 68
<script>
1328 jmachado 69
    $(document).ready(function(){
1076 jmachado 70
 
1328 jmachado 71
 
72
 
73
        $(".task-log.task-log-sm *.task-log-screens").addClass("in");
74
        $(".task-log.task-log-md *.task-log-screens").addClass("in");
75
        $(".task-log.task-log-lg *.task-log-screens").addClass("in");
76
        /*
77
        $(".task-log-xs .task-log-panel .panel .panel-heading").remove();
78
        $(".task-log-sm .task-log-panel .panel .panel-heading").remove();
79
        $(".task-log-md .task-log-panel .panel .panel-heading").remove();
80
        $(".task-log-xs .task-log-table").remove();
81
        $(".task-log-sm .task-log-table").remove();
82
        $(".task-log-xs .task-log-screens").remove();
83
        */
84
     });
85
</script>
86
<script>
87
 
88
    var startStatus = "";
1076 jmachado 89
    function updateStatus()
90
    {
91
        $.getJSON( "<%=request.getContextPath()%>/admin/schedullerTasksJson?service=loadLog&id=${SchedulleTasksForm.jobServiceTask.id}", function( data ) {
92
 
93
            $("#serviceStartDateFormated").html(data.serviceStartDateFormated);
94
            $("#serviceLastUpdateDateFormated").html(data.serviceLastUpdateDateFormated);
95
            $("#serviceFinishDateFormated").html(data.serviceFinishDateFormated);
96
            <%
97
                for(JobServiceTaskImpl.JobStatus jS : JobServiceTaskImpl.JobStatus.values())
98
                {
99
            %>
100
                    if(data.status == "<%=jS.name()%>")
101
                    {
102
                        $("#status").html("<%=MessageResources.getInstance(request).getMessage("job.status."+jS.name())%>");
103
                    }
104
            <%
105
                }
106
            %>
107
            $("#status").attr("class", "jobStatus"+data.status);(data.status);
108
            $("#progress").html(data.progress + "%");
109
            $(".progress-bar").css("width",data.progress + "%");
110
            $(".progress-bar").attr("aria-valuenow",data.progress);
111
            $(".progress-bar").html(data.progress + "%");
112
 
1082 jmachado 113
            if(data.status == "STARTED" || data.status == "PENDING")
1076 jmachado 114
                setTimeout("updateStatus()",2000);
1328 jmachado 115
 
116
            if(startStatus == "")
117
                startStatus = data.status;
118
 
119
            if(data.progress >= 100 && startStatus != data.status)
120
            {
121
                window.location.href = $("#<%=logid%>").closest('.task-log').data("href");
122
            }
1076 jmachado 123
        });
124
 
125
    }
126
    $(document).ready(function(){
127
        updateStatus();
128
 
129
    });
130
</script>
131
 
132
<%
133
 
134
%>
135
 
136
 
1328 jmachado 137
 
138
    <div class="panel panel-default task-log-panel" >
1076 jmachado 139
        <div class="panel-heading">
140
            <bean:message key="configuration.taskLog"/>
141
        </div>
142
        <div class="panel-body">
1328 jmachado 143
            <table class="tablesorter tablesortersimple task-log-table">
1076 jmachado 144
                <thead>
145
                    <tr>
146
                        <th><bean:message key="configuration.task"/></th>
147
                        <th>Iniciado</th>
148
                        <th>Última Atualização</th>
149
                        <th>Terminado</th>
150
                        <th>Criado por</th>
151
                        <th>Parametros</th>
152
                        <th>Status</th>
153
                        <th>Progresso</th>
154
                    </tr>
155
                </thead>
156
                <tbody>
157
                        <tr>
158
                            <td><bean:message key="targetService.${SchedulleTasksForm.jobServiceTask.targetService}"/></td>
159
                            <td id="serviceStartDateFormated">${SchedulleTasksForm.jobServiceTask.serviceStartDateFormated}</td>
160
                            <td id="serviceLastUpdateDateFormated">${SchedulleTasksForm.jobServiceTask.serviceLastUpdateDateFormated}</td>
161
                            <td id="serviceFinishDateFormated">${SchedulleTasksForm.jobServiceTask.serviceFinishDateFormated}</td>
162
                            <td>${SchedulleTasksForm.jobServiceTask.createdBy.username}</td>
163
                            <td>
164
                                <table cellspacing="0" cellspadding="0">
165
                                    <logic:iterate id="taskParam" name="SchedulleTasksForm" property="jobServiceTask.serviceTaskParameters" type="pt.estgp.estgweb.domain.JobServiceTaskParameter">
166
                                       <tr>
167
                                           <td>
1312 jmachado 168
                                               <bean:message key="task.param.${taskParam.name}"/>
1076 jmachado 169
                                           </td>
170
                                           <td>
1312 jmachado 171
                                               <logic:equal value="JOB_institution_KEY" name="taskParam" property="name">
172
                                                   <%=ConfigProperties.getProperty("institution.code.prefix." + taskParam.getObject())%>
173
                                               </logic:equal>
174
                                               <logic:notEqual value="JOB_institution_KEY" name="taskParam" property="name">
175
                                                   ${taskParam.object}
176
                                               </logic:notEqual>
1076 jmachado 177
                                           </td>
178
                                        </tr>
179
                                    </logic:iterate>
180
                                </table>
181
                            </td>
182
                            <logic:notEmpty name="SchedulleTasksForm" property="jobServiceTask">
183
                                <td id="status" class="jobStatus${SchedulleTasksForm.jobServiceTask.status}">
184
                                    <bean:message key="job.status.${SchedulleTasksForm.jobServiceTask.status}"/>
185
                                </td>
186
                                <td id="progress" style="text-align: right">
187
                                    ${SchedulleTasksForm.jobServiceTask.progress} %
188
                                </td>
189
                            </logic:notEmpty>
190
                            <logic:empty name="SchedulleTasksForm" property="jobServiceTask">
191
                                <td></td>
192
                                <td></td>
193
                            </logic:empty>
194
                        </tr>
195
                </tbody>
196
 
197
            </table>
1328 jmachado 198
            <div class="progress task-log-progress">
1076 jmachado 199
                <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0"
200
                     aria-valuemin="0" aria-valuemax="100" style="width:0%">
201
                    70%
202
                </div>
203
            </div>
1328 jmachado 204
 
205
            <div class="task-log-screens-toogle">
206
                <button type="button" class="btn btn-default" data-toggle="collapse" data-target="#<%=logid%>">Mostrar Log</button>
207
            </div>
208
            <div id="<%=logid%>" class="task-log-screens collapse">
209
                <div id="screens"></div>
210
                <a href="<%=request.getContextPath()%>/logServiceStream/${SchedulleTasksForm.jobServiceTask.logFilePath}">Download Log Completo</a>
211
            </div>
1076 jmachado 212
        </div>
213
    </div>
214
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/logtailer/logtail.js"></script>
215
 
216
    <style>
217
 
218
        .header {
219
            background-color: #ccc;
220
            padding: 0.5em;
221
            font-family: sans-serif;
222
        }
1328 jmachado 223
        .header h2{
224
            font-size: 1em;
225
        }
1076 jmachado 226
 
227
        .header .buttons {
228
            float: right;
229
        }
230
 
231
        .header h2 {
232
            margin: 0;
233
        }
234
 
235
        .screen {
1312 jmachado 236
            height: 512px;
1076 jmachado 237
            background-color: black;
238
            padding: 4px;
239
            overflow: auto;
240
            margin-bottom: 20px;
241
        }
242
 
243
        .screen div {
244
            padding: 0;
245
            margin: 0;
246
            border: 0;
247
            background-color: black;
248
            color: #bbb;
249
            line-height: 1.2;
250
            white-space: pre-wrap;
251
            font-family: monospace;
252
        }
253
    </style>
254
    <script>
255
        $(document).ready(function(){
256
            //
257
            // this is a list of logs we want to tail on this page. make sure these
258
            // point to your own server instead of mine ;)
259
            //
260
            var logs = {
1079 jmachado 261
                'Messages'	: '<%=request.getContextPath()%>/logServiceStream/${SchedulleTasksForm.jobServiceTask.logFilePath}'
1076 jmachado 262
            };
263
            //
264
            // for each one we create a log_handler() object, passed it a title,
265
            // log URL and a parent element to put the log tailer into.
266
            //
267
            for (var i in logs){
268
                new log_handler(i, logs[i], $('#screens'));
269
            }
270
        });
271
    </script>
272