Rev 1710 | Rev 1724 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1703 | jmachado | 1 | <%@ page import="jomm.dao.impl.AbstractDao" %> |
2 | <%@ page import="org.json.JSONArray" %> |
||
3 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentInterfaceImpl" %> |
||
4 | <%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
||
5 | <%@ page import="pt.estgp.estgweb.services.data.repositorydocuments.RepositoryDocumentService" %> |
||
6 | <%@ page import="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.RepositoryInterface" %> |
||
7 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
||
8 | <%@ taglib prefix="bacoTags" tagdir="/WEB-INF/tags" %> |
||
9 | <%@ taglib prefix="logic" uri="/WEB-INF/tlds/struts-logic.tld" %> |
||
10 | <%@ taglib prefix="html" uri="/WEB-INF/tlds/struts-html.tld" %> |
||
11 | <%@ taglib prefix="bean" uri="/WEB-INF/tlds/struts-bean.tld" %> |
||
1711 | jmachado | 12 | <%@ taglib prefix="baco" uri="http://www.estgp.pt/baco/" %> |
13 | <baco:hasNotRole role="admin,all"> |
||
14 | <div class="web-messages"> |
||
15 | <div class="alert alert-warning">Esta funcionalidade só pode ser utilizada por admnistradores</div> |
||
16 | </div> |
||
17 | </baco:hasNotRole> |
||
18 | <baco:hasRole role="admin,all"> |
||
1703 | jmachado | 19 | <% |
20 | AbstractDao.getCurrentSession().beginTransaction(); |
||
21 | |||
22 | JSONArray collectionsArrayOrderedTree = new RepositoryDocumentService().loadCollectionsOrderedAsTree(); |
||
23 | |||
24 | |||
25 | |||
26 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
27 | %> |
||
28 | <div id="appToolsRepositoryApp" ng-app="appToolsRepositoryApp" ng-controller="appToolsRepositoryController"> |
||
29 | |||
30 | <script> |
||
31 | var appToolsRepositoryApp = angular.module('appToolsRepositoryApp', ['ui.tree']); |
||
32 | GLOBAL_BacoAngularAppDependencies.push('appToolsRepositoryApp'); |
||
33 | |||
34 | <!-- estes codigos todos do remove e do toggle e etc's não mechi em nada limitei-me a copiar dos gajos--> |
||
35 | appToolsRepositoryApp.controller('appToolsRepositoryController', function ($scope) |
||
36 | { |
||
37 | $scope.sections = []; |
||
38 | $scope.paragraphSelector = "#plugsection p"; |
||
39 | $scope.urlSource = "http://www.ipportalegre.pt/pt/ipp/regulamentos-e-despachos/"; |
||
40 | $scope.collections = <%=collectionsArrayOrderedTree.toString()%>; |
||
41 | $scope.pushUrlSource = function() |
||
42 | { |
||
43 | widgetCallWithActionParameters( |
||
44 | "<%=request.getContextPath()%>/user/repositoryDoc.do", |
||
45 | "selectObjectsFromURL", |
||
46 | { |
||
47 | "paragraphSelector" : $scope.paragraphSelector, |
||
48 | "urlSource" : $scope.urlSource |
||
49 | }, |
||
50 | "#appToolsRepositoryApp", |
||
51 | function(json) |
||
52 | { |
||
53 | $scope.sections = []; |
||
54 | $scope.sections=json.sections; |
||
55 | $scope.$apply(); |
||
1711 | jmachado | 56 | $('[data-toggle="tooltip"]').tooltip(); |
1703 | jmachado | 57 | } |
58 | ); |
||
59 | } |
||
1711 | jmachado | 60 | $scope.setModified = function(doc) |
61 | { |
||
62 | doc.modified = "true"; |
||
63 | } |
||
1703 | jmachado | 64 | $scope.setInfoFinanceira = function() |
65 | { |
||
66 | $scope.paragraphSelector = "#plugsection p, #plugsection h2"; |
||
67 | $scope.urlSource = "http://www.ipportalegre.pt/pt/ipp/servicos/administrativos-e-financeiros/situacao-financeira/"; |
||
68 | } |
||
69 | $scope.setRecursosHumanos = function() |
||
70 | { |
||
71 | $scope.paragraphSelector = ".doc, h1, h2, h3, h4"; |
||
72 | $scope.urlSource = "http://www.ipportalegre.pt/pt/ipp/servicos/administrativos-e-financeiros/recursos-humanos/"; |
||
73 | } |
||
74 | $scope.setContratacaoPublica = function() |
||
75 | { |
||
76 | $scope.paragraphSelector = ".doc, h1, h2, h3, h4"; |
||
77 | $scope.urlSource = "http://www.ipportalegre.pt/pt/ipp/servicos/administrativos-e-financeiros/servicos-financeiros/"; |
||
78 | } |
||
79 | $scope.setRegulamentacaointerna = function() |
||
80 | { |
||
81 | $scope.paragraphSelector = ".multicolumn4 p, h3, h4, h2"; |
||
82 | $scope.urlSource = "http://www.ipportalegre.pt/pt/ipp/regulamentacao/"; |
||
83 | } |
||
84 | $scope.setDespachosPresidente = function() |
||
85 | { |
||
86 | $scope.paragraphSelector = "#plugsection p"; |
||
87 | $scope.urlSource = "http://www.ipportalegre.pt/pt/ipp/regulamentos-e-despachos/"; |
||
88 | } |
||
1710 | jmachado | 89 | $scope.setCollection = function(section,collectionId) |
1703 | jmachado | 90 | { |
91 | for(var i = 0; i < section.documents.length;i++) |
||
92 | { |
||
1711 | jmachado | 93 | section.documents[i].document.collection = {}; |
94 | section.documents[i].document.collection.id = collectionId; |
||
1703 | jmachado | 95 | } |
96 | } |
||
1711 | jmachado | 97 | //Meotodo necessário para incializar os pickers após serem criados |
98 | $scope.updateDatetimePickers = function() |
||
99 | { |
||
100 | $('.datetimepicker').datetimepicker({ |
||
101 | locale: 'pt', |
||
102 | format: 'YYYY/MM/DD' |
||
103 | }); |
||
104 | } |
||
105 | $scope.setDocPublishDate = function ($event,doc) { |
||
106 | |||
107 | var datetimepicker = $($event.target).parents(".form-group").find(".datetimepicker"); |
||
108 | $(datetimepicker).datetimepicker({locale: 'pt',format: 'YYYY/MM/DD'}) |
||
109 | .on("dp.change", function (data) { |
||
110 | //alert($("#"+datePicker).find("input").val()); |
||
111 | doc.document.publishDateStr = $(datetimepicker).find("input").val(); |
||
112 | doc.modified = true; |
||
113 | $scope.$apply(); |
||
114 | |||
115 | }); |
||
116 | } |
||
117 | |||
118 | $scope.submitDocument = function(docContainer,docContainerId) |
||
119 | { |
||
120 | if(!docContainer.document.collection) |
||
121 | { |
||
122 | alert("Escolha uma colecção por favor"); |
||
123 | } |
||
124 | else |
||
125 | { |
||
126 | docContainer.uploading = "true"; |
||
127 | |||
128 | widgetCallWithActionParameters( |
||
129 | "<%=request.getContextPath()%>/user/repositoryDoc.do", |
||
130 | "saveRepositoryDocument", |
||
131 | { |
||
132 | "doc" : JSON.stringify(docContainer.document), |
||
133 | "uploadedFiles" : JSON.stringify(docContainer.filesUploadResult) |
||
134 | }, |
||
135 | "#"+docContainerId, |
||
136 | function(docJson) |
||
137 | { |
||
138 | docContainer.document = docJson; |
||
139 | docContainer.uploaded = "true"; |
||
140 | docContainer.filesUploadResult = { |
||
141 | "service": null, |
||
142 | "uploadedFiles": [] |
||
143 | }; |
||
144 | delete docContainer.uploading; |
||
145 | if(docContainer.modified) |
||
146 | delete docContainer.modified; |
||
147 | $scope.$apply(); |
||
148 | }, |
||
149 | function(json){ |
||
150 | //onError |
||
151 | alert("ERRO: " + JSON.stringify(json)); |
||
152 | delete docContainer.uploading; |
||
153 | $scope.$apply(); |
||
154 | } |
||
155 | ); |
||
156 | |||
157 | |||
158 | |||
159 | |||
160 | } |
||
161 | } |
||
1703 | jmachado | 162 | }); |
163 | </script> |
||
1711 | jmachado | 164 | <style> |
165 | .uploaded |
||
166 | { |
||
167 | background-color: rgba(0, 255, 0, 0.13); |
||
168 | border: 1px dashed #008000; |
||
169 | } |
||
170 | </style> |
||
1703 | jmachado | 171 | |
172 | |||
173 | <div class="panel panel-default"> |
||
174 | <div class="panel-heading"> |
||
175 | Ferramenta de Importação de Documentos a Partir de Sites WEB |
||
176 | </div> |
||
177 | <div class="panel-body"> |
||
178 | |||
179 | <div class="web-messages"></div> |
||
180 | |||
181 | <button class="btn btn-default" type="button" ng-click="setRegulamentacaointerna()">Regulamentação Interna</button> |
||
182 | <button class="btn btn-default" type="button" ng-click="setDespachosPresidente()">Despachos do Presidente</button> |
||
183 | <button class="btn btn-default" type="button" ng-click="setContratacaoPublica()">Contratação Pública</button> |
||
184 | <button class="btn btn-default" type="button" ng-click="setRecursosHumanos()">Recursos Humanos</button> |
||
185 | <button class="btn btn-default" type="button" ng-click="setInfoFinanceira()">Informação Finânceira</button> |
||
186 | |||
187 | <div> |
||
188 | <p>Regras de Parsing:</p> |
||
189 | <ul> |
||
190 | <li>Considera qualquer elemento selecionado um possivel candidato a documento ou secção</li> |
||
191 | <li>Separa o elemento em linhas partindo nos <br> , se não existir link esse é o titulo do documento</li> |
||
192 | <li>Se existir link o texto será o titulo do ficheiro e o link é guardado</li> |
||
193 | <li>Limpa traços nos inicios das linhas</li> |
||
194 | </ul> |
||
195 | </div> |
||
196 | |||
197 | <div class="form-group"> |
||
198 | <label class="control-label">Selector de Paragrafos HTML</label> |
||
199 | <div> |
||
200 | <input type="text" class="form-control" ng-model="paragraphSelector"/> |
||
201 | </div> |
||
202 | </div> |
||
203 | <div class="form-group"> |
||
204 | <label class="control-label">URL Fonte de Documentos (Arranje o seu HTML para poder ser dividido em elementos todos iguais: exemplo um paragrafo por documento)</label> |
||
205 | <div> |
||
206 | <input type="text" class="form-control" ng-model="urlSource" placeholder="URL"/> |
||
207 | </div> |
||
208 | </div> |
||
209 | |||
210 | <div class="form-group"> |
||
211 | <div> |
||
212 | <button type="button" class="btn btn-info" ng-click="pushUrlSource()">Obter</button> |
||
213 | </div> |
||
214 | </div> |
||
215 | |||
216 | <div class="repository-interface"> |
||
217 | <div class="repository-intro repository-interface-intro"> |
||
218 | <div class="repository-title"> |
||
219 | Documentos Importados |
||
220 | </div> |
||
221 | <div class="repository-description"> |
||
222 | Documentos importados em tempo real para confirmação pelo Administrador antes de importar para o sistema de repositorio digital. |
||
223 | </div> |
||
224 | </div> |
||
225 | |||
226 | <div class="repository-column"> |
||
227 | <div class="repository-block" ng-repeat="section in sections"> |
||
228 | <div class="repository-intro"> |
||
1710 | jmachado | 229 | <div class="repository-title clearfix" style="padding: 10px;background-color: rgba(212, 168, 0, 0.5)"> |
230 | <div class="col-md-6"> |
||
231 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
||
232 | {{section.section}} |
||
233 | </div> |
||
234 | <div class="col-md-1 control-label"> |
||
235 | Colecção: |
||
236 | </div> |
||
237 | <div class="col-md-5"> |
||
238 | <select ng-change="setCollection(section,section.choosedCol)" place-holder="Escolha Colecção" ng-model="section.choosedCol" class="form-control chosenOff" ng-options="collection.id as collection.pathName for collection in collections"> |
||
1703 | jmachado | 239 | |
1710 | jmachado | 240 | </select> |
241 | </div> |
||
1703 | jmachado | 242 | </div> |
243 | </div> |
||
1711 | jmachado | 244 | <div ng-class="{'uploaded':doc.uploaded,'modified':doc.modified}" ng-repeat="doc in section.documents" class="clearfix" ng-attr-id="{{'doc' + $index + '_' + $parent.$index}}" ng-init="sectionIndex = $parent.$index"> |
1703 | jmachado | 245 | |
1711 | jmachado | 246 | <div class="col-md-1"> |
247 | <img ng-if="doc.uploading" src="<%=request.getContextPath()%>/imgs/wait.gif"> |
||
248 | <button ng-if="!(doc.uploaded || doc.uploading)" ng-click="submitDocument(doc,'doc' + $index + '_' + sectionIndex)" type="button" data-toggle="tooltip" title="Depositar" class="btn btn-success" style="width: 100%"> |
||
249 | <span class="icon icon-upload3" style="font-size: 2.0em"></span> |
||
250 | </button> |
||
251 | <a ng-if="doc.document.id" style="width: 100%" target="_blank" class="btn btn-warning" ng-href="<%=request.getContextPath()%>/user/repositoryEditDocument.do?repositoryDocumentId={{doc.document.id}}"> |
||
252 | <span class="glyphicon glyphicon-pencil" style="font-size: 1.5em"></span> |
||
253 | </a> |
||
254 | <button style="margin-top: 5px" ng-if="doc.uploaded && doc.modified" ng-click="submitDocument(doc,'doc' + $index + '_' + sectionIndex)" type="button" data-toggle="tooltip" title="Depositar" class="btn btn-default" style="width: 100%"> |
||
255 | <span class="glyphicon glyphicon-floppy-disk" style="font-size: 1.5em"></span> |
||
256 | </button> |
||
1703 | jmachado | 257 | </div> |
1711 | jmachado | 258 | <div class="col-md-11"> |
259 | <div class="web-messages"></div> |
||
260 | <div class="repository-document clearfix"> |
||
1703 | jmachado | 261 | |
1711 | jmachado | 262 | <div class="repository-title clearfix" style="padding:5px"> |
263 | <span class="title col-md-1"> |
||
264 | <span class="glyphicon glyphicon-file"></span> |
||
265 | </span> |
||
266 | <span class="title col-md-5"> |
||
267 | <input type="text" class="form-control" ng-change="setModified(doc)" ng-model="doc.document.title"> |
||
268 | </span> |
||
269 | <div class="col-md-4"> |
||
270 | <select place-holder="Escolha Colecção" ng-change="setModified(doc)" ng-model="doc.document.collection.id" class="form-control chosenOff" ng-options="collection.id as collection.pathName for collection in collections"> |
||
271 | </select> |
||
272 | </div> |
||
273 | <div class="col-md-2 form-group"> |
||
274 | <div class='input-group date datetimepicker' ng-click="setDocPublishDate($event,doc)"> |
||
275 | <input ng-model="doc.document.publishDateStr" type="text" class="form-control" ng-init="updateDatetimePickers()"/> |
||
276 | <span class="input-group-addon"> |
||
277 | <span class="glyphicon glyphicon-calendar"></span> |
||
278 | </span> |
||
279 | </div> |
||
280 | </div> |
||
281 | </div> |
||
282 | <div class="repository-description"></div> |
||
1703 | jmachado | 283 | |
1711 | jmachado | 284 | <div class="repository-document-files" style="padding-left:20px;width: 100%" ng-repeat="file in doc.filesUploadResult.uploadedFiles"> |
1703 | jmachado | 285 | |
1711 | jmachado | 286 | <div class="repository-document-file clearfix" style="width: 100%;" > |
287 | |||
288 | <div class="repository-title border-radius-bottom clearfix" style="padding: 5px"> |
||
289 | <div class="title col-md-1"> |
||
290 | <span class="glyphicon glyphicon-paperclip"></span> |
||
291 | </div> |
||
292 | <div class="col-md-11"> |
||
293 | <input type="text" class="form-control" ng-model="file.title"> |
||
294 | </div> |
||
295 | <div class="col-md-1"> |
||
296 | <a data-toggle="tooltip" title="Descarregar" class="btn btn-default pull-left repository-file-icon" target="_blank" ng-href="{{file.tmpName}}"><span class="icon icon-file-pdf icon-large"></span></a> |
||
297 | </div> |
||
298 | <div class="col-md-11"> |
||
299 | <input type="text" class="form-control" ng-model="file.tmpName"> |
||
300 | </div> |
||
301 | |||
302 | </div> |
||
1703 | jmachado | 303 | </div> |
304 | </div> |
||
305 | </div> |
||
306 | </div> |
||
307 | </div> |
||
308 | |||
309 | </div> |
||
310 | </div> |
||
311 | |||
312 | </div> |
||
313 | |||
314 | |||
315 | |||
316 | |||
317 | |||
318 | |||
319 | <pre> |
||
320 | {{urlSource}} |
||
321 | </pre> |
||
322 | <pre> |
||
323 | {{sections | json}} |
||
324 | </pre> |
||
325 | </div> |
||
326 | </div> |
||
1711 | jmachado | 327 | </div> |
328 | </baco:hasRole> |