Subversion Repositories bacoAlunos

Rev

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

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