Subversion Repositories bacoAlunos

Rev

Rev 1925 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1925 Rev 1928
Line 1... Line 1...
1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
2
<%@ page import="jomm.dao.impl.AbstractDao" %>
-
 
3
<%@ page import="pt.estgp.estgweb.domain.CourseImpl" %>
-
 
4
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
-
 
5
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.IServiceManager" %>
-
 
6
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.ServiceManager" %>
-
 
7
<%@ page import="pt.estgp.estgweb.web.utils.RequestUtils" %>
-
 
8
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
2
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
9
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
3
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
10
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
4
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
11
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
5
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
12
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
6
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
13
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
7
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
14
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
8
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
15
 
9
 
16
<%-- http://localhost:8080/baco/user/editCourseReport.do?courseCode=44&year=201617 --%>
-
 
17
 
-
 
18
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.css">
-
 
19
<script src="<%=request.getContextPath()%>/js/jquery-ui-1.12.1/jquery-ui.min.js"></script>
-
 
20
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/flora-commons/flora.resizable.css">
-
 
21
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
-
 
22
<script>
-
 
23
    function demoFromHTML() {
-
 
24
        var pdf = new jsPDF('p', 'pt', 'letter');
-
 
25
        // source can be HTML-formatted string, or a reference
-
 
26
        // to an actual DOM element from which the text will be scraped.
-
 
27
        source = $('#courseReportApp')[0];
-
 
28
 
-
 
29
        // we support special element handlers. Register them with jQuery-style
-
 
30
        // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
-
 
31
        // There is no support for any other type of selectors
-
 
32
        // (class, of compound) at this time.
-
 
33
        specialElementHandlers = {
-
 
34
            // element with id of "bypass" - jQuery style selector
-
 
35
            '#bypassme': function (element, renderer) {
-
 
36
                // true = "handled elsewhere, bypass text extraction"
-
 
37
                return true
-
 
38
            }
-
 
39
        };
-
 
40
        margins = {
-
 
41
            top: 80,
-
 
42
            bottom: 60,
-
 
43
            left: 40,
-
 
44
            width: 522
-
 
45
        };
-
 
46
        // all coords and widths are in jsPDF instance's declared units
-
 
47
        // 'inches' in this case
-
 
48
        pdf.fromHTML(
-
 
49
                source, // HTML string or DOM elem ref.
-
 
50
                margins.left, // x coord
-
 
51
                margins.top, { // y coord
-
 
52
                    'width': margins.width, // max width of content on PDF
-
 
53
                    'elementHandlers': specialElementHandlers
-
 
54
                },
-
 
55
 
-
 
56
                function (dispose) {
-
 
57
                    // dispose: object with X, Y of the last line add to the PDF
-
 
58
                    //          this allow the insertion of new lines after html
-
 
59
                    //var pdfDocument =  pdf.save('Test.pdf');
-
 
60
                    var pdfDocument = pdf.output();
-
 
61
 
-
 
62
                    var boundary = '---------------------------';
-
 
63
                    boundary += Math.floor(Math.random()*32768);
-
 
64
                    boundary += Math.floor(Math.random()*32768);
-
 
65
                    boundary += Math.floor(Math.random()*32768);
-
 
66
 
-
 
67
                    var body = '';
-
 
68
                    body += '--' + boundary + '\r\n' +
-
 
69
                            'Content-Disposition: form-data; name="filesInputId-UPLOAD[]"; filename="20170530_210340.pdf"' + '\r\n';
-
 
70
                    body += 'Content-Type: application/pdf';
-
 
71
                    body += '\r\n\r\n';
-
 
72
                    body += pdfDocument;
-
 
73
                    body += '\r\n'
-
 
74
                    body += '--' + boundary + '--';
-
 
75
 
-
 
76
 
-
 
77
 
-
 
78
                    $.ajax({
-
 
79
                        type: "POST",
-
 
80
                        cache: false,
-
 
81
                        url: "<%=request.getContextPath()%>/filesUpload",
-
 
82
                        data: body ,
-
 
83
                        processData: false,
-
 
84
                        contentType : 'multipart/form-data; boundary=' + boundary,
-
 
85
                        success: function (data) {
-
 
86
                            alert('success');
-
 
87
                            return false;
-
 
88
                        }
-
 
89
                    });
-
 
90
                }, margins
-
 
91
        );
-
 
92
    }
-
 
93
</script>
-
 
94
 
-
 
95
<script>ping()</script>
-
 
96
 
-
 
97
<jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/>
-
 
98
<jsp:useBean id="course" type="pt.estgp.estgweb.domain.CourseImpl" scope="request"/>
-
 
99
 
-
 
100
<%
-
 
101
    //AbstractDao.getCurrentSession().beginTransaction();
-
 
102
%>
-
 
103
<%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%>
-
 
104
 
-
 
105
<div class="container-fluid">
-
 
106
 
-
 
107
<style>
-
 
108
    .separatorSection
-
 
109
    {
-
 
110
        border: 1px solid #ddd;
-
 
111
    }
-
 
112
</style>
-
 
113
 
-
 
114
 
-
 
115
<!-- Apresentacao da Unidade -->
-
 
116
 
-
 
117
<div class="panel panel-default">
-
 
118
<div class="panel-heading">
-
 
119
    Relatório Anual do curso: ${course.name}
-
 
120
</div>
-
 
121
<div class="panel-body">
-
 
122
 
-
 
123
<p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p>
-
 
124
<p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p>
-
 
125
<p><b class="label-info">Departamento:</b> ${course.department.name}</p>
-
 
126
<p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p>
-
 
127
 
-
 
128
 
-
 
129
 
-
 
130
 
-
 
131
<script>
-
 
132
 
-
 
133
    //Especifico da aplicacao
-
 
134
    var courseReportApp = angular.module('courseReportApp', ['ui.tree']);
-
 
135
    GLOBAL_BacoAngularAppDependencies.push('courseReportApp');
-
 
136
 
-
 
137
 
-
 
138
    courseReportApp.directive('resizable', function () {
-
 
139
        return {
-
 
140
            restrict: 'A',
-
 
141
            scope: {
-
 
142
                callback: '&onResize'
-
 
143
            },
-
 
144
            link: function postLink(scope, elem, attrs) {
-
 
145
                elem.resizable();
-
 
146
                elem.on('resize', function (evt, ui, comp) {
-
 
147
                    scope.$apply(function() {
-
 
148
                        if (scope.callback) {
-
 
149
                            scope.callback({$evt: evt, $ui: ui, $comp: comp });
-
 
150
                        }
-
 
151
                    })
-
 
152
                });
-
 
153
            }
-
 
154
        };
-
 
155
    });
-
 
156
 
-
 
157
 
-
 
158
    courseReportApp.controller('courseReportAppController', function($scope)
-
 
159
    {
-
 
160
 
-
 
161
        $scope.docAppSelector = "#courseReportApp";
-
 
162
        $scope.report = ${courseReportJson}
-
 
163
 
-
 
164
                $scope.resize = function(evt,ui,comp) {
-
 
165
                    //console.log (evt,ui);
-
 
166
                    comp.width = ui.size.width;
-
 
167
                    comp.height = ui.size.height;
-
 
168
                }
-
 
169
 
-
 
170
        /**
-
 
171
         * @classe class to match
-
 
172
         * @superClasses array of strings
-
 
173
         * */
-
 
174
        $scope.contains = function(obj,classe)
-
 
175
        {
-
 
176
            if(obj['@class'] && obj['@class'] == classe)
-
 
177
                return true;
-
 
178
            if(obj.allSuperClasses)
-
 
179
            {
-
 
180
                for(var i in obj.allSuperClasses)
-
 
181
                {
-
 
182
                    if(classe == obj.allSuperClasses[i])
-
 
183
                        return true;
-
 
184
                }
-
 
185
            }
-
 
186
            return false;
-
 
187
        }
-
 
188
 
-
 
189
        $scope.showSep = function(section,subSection)
-
 
190
        {
-
 
191
            var s;
-
 
192
            for(s in section.sections)
-
 
193
            {
-
 
194
                section.sections[s].active = false;
-
 
195
            }
-
 
196
            /*$(".separatorSectionNav").each(function()
-
 
197
             {
-
 
198
             angular.element($(this)).scope().section.active = false;
-
 
199
             });*/
-
 
200
            subSection.active = true;
-
 
201
        }
-
 
202
 
-
 
203
        /**
-
 
204
         * Este metodo devolve o template mais profundo na hierarquia de classes
-
 
205
         * permitindo emular o override, quanto mais especifica for a classe
-
 
206
         * e caso exista template é esse o template devolvido
-
 
207
         * procura um script com o id da classe e se nao existir
-
 
208
         * vai subindo nas super classes
-
 
209
         * @param obj
-
 
210
         * @returns {*}
-
 
211
         */
-
 
212
        $scope.class2id = function(obj)
-
 
213
        {
-
 
214
            var objClassId = obj["@class"].replaceAll(".","_");
-
 
215
            if($("script#" + objClassId).length > 0)
-
 
216
            {
-
 
217
                return objClassId;
-
 
218
            }
-
 
219
            if(obj.allSuperClasses)
-
 
220
            {
-
 
221
                var s;
-
 
222
                for(s in obj.allSuperClasses)
-
 
223
                {
-
 
224
                    var superClass = obj.allSuperClasses[s];
-
 
225
                    var superClassId = superClass.replaceAll(".","_");
-
 
226
                    if($("script#" + superClassId).length > 0)
-
 
227
                    {
-
 
228
                        return superClassId;
-
 
229
                    }
-
 
230
                }
-
 
231
            }
-
 
232
            return obj["@class"].replaceAll(".","_");
-
 
233
        }
-
 
234
 
-
 
235
        $scope.addText = function(parentCustomPane)
-
 
236
        {
-
 
237
            $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent")
-
 
238
        }
-
 
239
 
-
 
240
        $scope.addImage = function(parentCustomPane)
-
 
241
        {
-
 
242
            $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent")
-
 
243
        }
-
 
244
 
-
 
245
        $scope.addSimpleDocComponent = function(parentCustomPane,classComponent)
-
 
246
        {
-
 
247
            if(!parentCustomPane.components)
-
 
248
            {
-
 
249
                parentCustomPane.components = [];
-
 
250
            }
-
 
251
            parentCustomPane.components.push(
-
 
252
                    {
-
 
253
                        "@class" : classComponent
-
 
254
                    }
-
 
255
            );
-
 
256
        }
-
 
257
        $scope.removeComponent = function(index,array)
-
 
258
        {
-
 
259
            array.splice(index,1);
-
 
260
        }
-
 
261
 
-
 
262
        $scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement)
-
 
263
        {
-
 
264
            var modelObject = BacoAngularUtils.getAngularElementModel(targetElement);
-
 
265
 
-
 
266
            if(modelObject.image && modelObject.image.identifier)
-
 
267
            {
-
 
268
                widgetCallWithActionParameters(
-
 
269
                        "<%=request.getContextPath()%>/user/json/repository.do",
-
 
270
                        "replaceRepositoryFileFromTempPrivateDomain",
-
 
271
                        {
-
 
272
                            "identifier" : modelObject.image.identifier,
-
 
273
                            "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0])
-
 
274
                        },
-
 
275
                        "#courseReportApp",
-
 
276
                        function(repositoryFile4JsonView)
-
 
277
                        {
-
 
278
                            modelObject.image = repositoryFile4JsonView;
-
 
279
                            //image URL is generated on reimport just to avoid caching
-
 
280
                            modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime();
-
 
281
                            angular.element($("#courseReportApp")).scope().$apply();
-
 
282
                        },
-
 
283
                        function(){}
-
 
284
                );
-
 
285
            }
-
 
286
            else
-
 
287
            {
-
 
288
                widgetCallWithActionParameters(
-
 
289
                        "<%=request.getContextPath()%>/user/json/repository.do",
-
 
290
                        "saveRepositoryFileFromTempPrivateDomain",
-
 
291
                        {
-
 
292
                            "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0])
-
 
293
                        },
-
 
294
                        "#courseReportApp",
-
 
295
                        function(repositoryFile4JsonView)
-
 
296
                        {
-
 
297
                            modelObject.image = repositoryFile4JsonView;
-
 
298
                            modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime();
-
 
299
                            angular.element($("#courseReportApp")).scope().$apply();
-
 
300
                        },
-
 
301
                        function(){}
-
 
302
                );
-
 
303
            }
-
 
304
        }
-
 
305
 
-
 
306
        $scope.saveCourseReportDocument = function () {
-
 
307
            widgetCallWithActionParameters(
-
 
308
                "<%=request.getContextPath()%>/user/courseReport.do",
-
 
309
                "saveCourseReportDocument",
-
 
310
                {
-
 
311
                    "courseReportDocument" : BacoJS.stringifyOrdered($scope.report)
-
 
312
                },
-
 
313
                "#courseReportApp",
-
 
314
                function(data)
-
 
315
                {
-
 
316
                    alert(BacoJS.stringifyOrdered(data));
-
 
317
                },
-
 
318
                function(){}
-
 
319
            );
-
 
320
        }
-
 
321
 
-
 
322
 
-
 
323
 
-
 
324
    });
-
 
325
</script>
-
 
326
 
-
 
327
<!--TEMPLATES FOR DOCUMENT BUILDER-->
-
 
328
<jsp:include page="../utils/documentsBuilder.jsp"/>
10
<jsp:include page="../utils/reportEdit.jsp"/>
329
<jsp:include page="coursereport/templates.jsp"/>
11
<jsp:include page="coursereport/templates.jsp"/>
330
 
-
 
331
<div class="form-vertical">
-
 
332
    <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController">
-
 
333
        <div class="web-messages"></div>
-
 
334
 
-
 
335
        <button class="btn btn-success" ng-click="saveCourseReportDocument()">Gravar</button>
-
 
336
 
-
 
337
        <div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'">
-
 
338
 
-
 
339
        </div>
-
 
340
 
-
 
341
        <!--<pre class="code">{{ report | json }}</pre>-->
-
 
342
 
-
 
343
 
-
 
344
 
-
 
345
    </div><!--App-->
-
 
346
</div> <!--form-->
-
 
347
 
-
 
348
</div><!--Panel Body-->
-
 
349
 
-
 
350
</div><!--Panel-->
-
 
351
 
-
 
352
</div><!--container-fluid-->
-
 
353
 
-
 
354
<%
-
 
355
    //AbstractDao.getCurrentSession().getTransaction().commit();
-
 
356
%>
-
 
357
 
12