Subversion Repositories bacoAlunos

Rev

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

Rev 1929 Rev 1930
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
<jsp:useBean id="courseReportJson" type="java.lang.String" scope="request"/>
-
 
97
<jsp:useBean id="course" type="pt.estgp.estgweb.domain.CourseImpl" scope="request"/>
-
 
98
 
-
 
99
<%
-
 
100
    //AbstractDao.getCurrentSession().beginTransaction();
-
 
101
%>
-
 
102
<%--<a href="javascript:demoFromHTML()" class="button">Run Code</a>--%>
-
 
103
 
-
 
104
<div class="container-fluid">
-
 
105
 
-
 
106
    <style>
-
 
107
        .separatorSection
-
 
108
        {
-
 
109
            border: 1px solid #ddd;
-
 
110
        }
-
 
111
    </style>
-
 
112
 
-
 
113
 
-
 
114
    <!-- Apresentacao da Unidade -->
-
 
115
 
-
 
116
    <div class="panel panel-default">
-
 
117
        <div class="panel-heading">
-
 
118
            Relatório Anual do curso: ${course.name}
-
 
119
        </div>
-
 
120
        <div class="panel-body">
-
 
121
 
-
 
122
            <p><b class="label-info">Tipo de Curso:</b> <bean:message key="course.${course.degree}"/></p>
-
 
123
            <p><b class="label-info">Ano Lectivo:</b> ${course.importYear}</p>
-
 
124
            <p><b class="label-info">Departamento:</b> ${course.department.name}</p>
-
 
125
            <p><b class="label-info">Escola:</b> ${course.department.courseSchool.name}</p>
-
 
126
 
-
 
127
 
-
 
128
 
-
 
129
 
-
 
130
            <script>
-
 
131
 
-
 
132
                //Especifico da aplicacao
-
 
133
                var courseReportApp = angular.module('courseReportApp', ['ui.tree']);
-
 
134
                GLOBAL_BacoAngularAppDependencies.push('courseReportApp');
-
 
135
 
-
 
136
 
-
 
137
                courseReportApp.directive('resizable', function () {
-
 
138
                    return {
-
 
139
                        restrict: 'A',
-
 
140
                        scope: {
-
 
141
                            callback: '&onResize'
-
 
142
                        },
-
 
143
                        link: function postLink(scope, elem, attrs) {
-
 
144
                            elem.resizable();
-
 
145
                            elem.on('resize', function (evt, ui, comp) {
-
 
146
                                scope.$apply(function() {
-
 
147
                                    if (scope.callback) {
-
 
148
                                        scope.callback({$evt: evt, $ui: ui, $comp: comp });
-
 
149
                                    }
-
 
150
                                })
-
 
151
                            });
-
 
152
                        }
-
 
153
                    };
-
 
154
                });
-
 
155
 
-
 
156
 
-
 
157
                courseReportApp.controller('courseReportAppController', function($scope)
-
 
158
                {
-
 
159
 
-
 
160
                    $scope.docAppSelector = "#courseReportApp";
-
 
161
                    $scope.report = ${courseReportJson}
-
 
162
 
-
 
163
                            $scope.resize = function(evt,ui,comp) {
-
 
164
                                //console.log (evt,ui);
-
 
165
                                comp.width = ui.size.width;
-
 
166
                                comp.height = ui.size.height;
-
 
167
                            }
-
 
168
 
-
 
169
                    /**
-
 
170
                     * @classe class to match
-
 
171
                     * @superClasses array of strings
-
 
172
                     * */
-
 
173
                    $scope.contains = function(obj,classe)
-
 
174
                    {
-
 
175
                        if(obj['@class'] && obj['@class'] == classe)
-
 
176
                            return true;
-
 
177
                        if(obj.allSuperClasses)
-
 
178
                        {
-
 
179
                            for(var i in obj.allSuperClasses)
-
 
180
                            {
-
 
181
                                if(classe == obj.allSuperClasses[i])
-
 
182
                                    return true;
-
 
183
                            }
-
 
184
                        }
-
 
185
                        return false;
-
 
186
                    }
-
 
187
 
-
 
188
                    $scope.showSep = function(section,subSection)
-
 
189
                    {
-
 
190
                        var s;
-
 
191
                        for(s in section.sections)
-
 
192
                        {
-
 
193
                            section.sections[s].active = false;
-
 
194
                        }
-
 
195
                        /*$(".separatorSectionNav").each(function()
-
 
196
                         {
-
 
197
                         angular.element($(this)).scope().section.active = false;
-
 
198
                         });*/
-
 
199
                        subSection.active = true;
-
 
200
                    }
-
 
201
 
-
 
202
                    /**
-
 
203
                     * Este metodo devolve o template mais profundo na hierarquia de classes
-
 
204
                     * permitindo emular o override, quanto mais especifica for a classe
-
 
205
                     * e caso exista template é esse o template devolvido
-
 
206
                     * procura um script com o id da classe e se nao existir
-
 
207
                     * vai subindo nas super classes
-
 
208
                     * @param obj
-
 
209
                     * @returns {*}
-
 
210
                     */
-
 
211
                    $scope.class2id = function(obj)
-
 
212
                    {
-
 
213
                        var objClassId = obj["@class"].replaceAll(".","_");
-
 
214
                        if($("script#" + objClassId).length > 0)
-
 
215
                        {
-
 
216
                            return objClassId;
-
 
217
                        }
-
 
218
                        if(obj.allSuperClasses)
-
 
219
                        {
-
 
220
                            var s;
-
 
221
                            for(s in obj.allSuperClasses)
-
 
222
                            {
-
 
223
                                var superClass = obj.allSuperClasses[s];
-
 
224
                                var superClassId = superClass.replaceAll(".","_");
-
 
225
                                if($("script#" + superClassId).length > 0)
-
 
226
                                {
-
 
227
                                    return superClassId;
-
 
228
                                }
-
 
229
                            }
-
 
230
                        }
-
 
231
                        return obj["@class"].replaceAll(".","_");
-
 
232
                    }
-
 
233
 
-
 
234
                    $scope.addText = function(parentCustomPane)
-
 
235
                    {
-
 
236
                        $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.TextComponent")
-
 
237
                    }
-
 
238
 
-
 
239
                    $scope.addImage = function(parentCustomPane)
-
 
240
                    {
-
 
241
                        $scope.addSimpleDocComponent(parentCustomPane,"pt.estgp.estgweb.utils.documentBuilder.ImageComponent")
-
 
242
                    }
-
 
243
 
-
 
244
                    $scope.addSimpleDocComponent = function(parentCustomPane,classComponent)
-
 
245
                    {
-
 
246
                        if(!parentCustomPane.components)
-
 
247
                        {
-
 
248
                            parentCustomPane.components = [];
-
 
249
                        }
-
 
250
                        parentCustomPane.components.push(
-
 
251
                                {
-
 
252
                                    "@class" : classComponent
-
 
253
                                }
-
 
254
                        );
-
 
255
                    }
-
 
256
                    $scope.removeComponent = function(index,array)
-
 
257
                    {
-
 
258
                        array.splice(index,1);
-
 
259
                    }
-
 
260
 
-
 
261
                    $scope.callbackUploadedFiles = function(filesUploadResult,token,targetElement)
-
 
262
                    {
-
 
263
                        var modelObject = BacoAngularUtils.getAngularElementModel(targetElement);
-
 
264
 
-
 
265
                        if(modelObject.image && modelObject.image.identifier)
-
 
266
                        {
-
 
267
                            widgetCallWithActionParameters(
-
 
268
                                    "<%=request.getContextPath()%>/user/json/repository.do",
-
 
269
                                    "replaceRepositoryFileFromTempPrivateDomain",
-
 
270
                                    {
-
 
271
                                        "identifier" : modelObject.image.identifier,
-
 
272
                                        "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0])
-
 
273
                                    },
-
 
274
                                    "#courseReportApp",
-
 
275
                                    function(repositoryFile4JsonView)
-
 
276
                                    {
-
 
277
                                        modelObject.image = repositoryFile4JsonView;
-
 
278
                                        //image URL is generated on reimport just to avoid caching
-
 
279
                                        modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime();
-
 
280
                                        angular.element($("#courseReportApp")).scope().$apply();
-
 
281
                                    },
-
 
282
                                    function(){}
-
 
283
                            );
-
 
284
                        }
-
 
285
                        else
-
 
286
                        {
-
 
287
                            widgetCallWithActionParameters(
-
 
288
                                    "<%=request.getContextPath()%>/user/json/repository.do",
-
 
289
                                    "saveRepositoryFileFromTempPrivateDomain",
-
 
290
                                    {
-
 
291
                                        "fileUploaded" : BacoJS.stringifyOrdered(filesUploadResult.uploadedFiles[0])
-
 
292
                                    },
-
 
293
                                    "#courseReportApp",
-
 
294
                                    function(repositoryFile4JsonView)
-
 
295
                                    {
-
 
296
                                        modelObject.image = repositoryFile4JsonView;
-
 
297
                                        modelObject.imageUrl = "<%=request.getContextPath()%>/repositoryStream/" + modelObject.image.identifier + "?" + new Date().getTime();
-
 
298
                                        angular.element($("#courseReportApp")).scope().$apply();
-
 
299
                                    },
-
 
300
                                    function(){}
-
 
301
                            );
-
 
302
                        }
-
 
303
                    }
-
 
304
 
-
 
305
                    $scope.saveCourseReportDocument = function () {
-
 
306
                        widgetCallWithActionParameters(
-
 
307
                                "<%=request.getContextPath()%>/user/courseReport.do",
-
 
308
                                "saveCourseReportDocument",
-
 
309
                                {
-
 
310
                                    "courseReportDocument" : BacoJS.stringifyOrdered($scope.report)
-
 
311
                                },
-
 
312
                                "#courseReportApp",
-
 
313
                                function(data)
-
 
314
                                {
-
 
315
                                    alert(BacoJS.stringifyOrdered(data));
-
 
316
                                },
-
 
317
                                function(){}
-
 
318
                        );
-
 
319
                    }
-
 
320
 
-
 
321
 
-
 
322
 
-
 
323
                });
-
 
324
            </script>
-
 
325
 
-
 
326
            <!--TEMPLATES FOR DOCUMENT BUILDER-->
-
 
327
            <jsp:include page="../utils/documentsBuilder.jsp"/>
-
 
328
            <jsp:include page="coursereport/templates.jsp"/>
-
 
329
 
-
 
330
            <div class="form-vertical">
-
 
331
                <div id="courseReportApp" ng-app="courseReportApp" ng-controller="courseReportAppController">
-
 
332
                    <div class="web-messages"></div>
-
 
333
 
-
 
334
                    <button class="btn btn-success" ng-click="saveCourseReportDocument()">Gravar</button>
-
 
335
 
-
 
336
                    <div ng-init="section=report;" ng-include="'pt_estgp_estgweb_utils_documentBuilder_DocumentSection'">
-
 
337
 
-
 
338
                    </div>
-
 
339
 
-
 
340
                    <!--<pre class="code">{{ report | json }}</pre>-->
-
 
341
 
-
 
342
 
-
 
343
 
-
 
344
                </div><!--App-->
-
 
345
            </div> <!--form-->
-
 
346
 
-
 
347
        </div><!--Panel Body-->
-
 
348
 
-
 
349
    </div><!--Panel-->
-
 
350
 
-
 
351
</div><!--container-fluid-->
-
 
352
 
-
 
353
<%
-
 
354
    //AbstractDao.getCurrentSession().getTransaction().commit();
-
 
355
%>
-
 
356
 
10
<jsp:include page="../utils/reportEdit.jsp"/>
-
 
11
<jsp:include page="coursereport/templates.jsp"/>
-
 
12
 
357
Generated by GNU Enscript 1.6.5.2.
13
Generated by GNU Enscript 1.6.5.2.