Skip to content

Commit

Permalink
modifiche da demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrycz committed Nov 14, 2018
1 parent 4b17db7 commit 9ecee55
Show file tree
Hide file tree
Showing 21 changed files with 42,045 additions and 30 deletions.
9 changes: 8 additions & 1 deletion gulp/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
swagger: swagger,
images: images,
jstree: jstree,
ace: ace
ace: ace,
customjs: customjs
}

//var yorc = require('../.yo-rc.json')['generator-jhipster'];
Expand Down Expand Up @@ -80,6 +81,12 @@ function ace() {
.pipe(gulp.dest(config.dist + 'content/js/ace/'));
}

function customjs() {
return gulp.src(config.app + 'content/js/*.js')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(gulp.dest(config.dist + 'content/js/'));
}

function common() {
return gulp.src([config.app + 'robots.txt', config.app + 'favicon.ico', config.app + '.htaccess'], { dot: true })
.pipe(plumber({errorHandler: handleErrors}))
Expand Down
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gulp.task('clean', function () {
return del([config.dist], { dot: true });
});

gulp.task('copy', ['copy:i18n', 'copy:fonts', 'copy:common', 'copy:jstree', 'copy:ace']);
gulp.task('copy', ['copy:i18n', 'copy:fonts', 'copy:common', 'copy:jstree', 'copy:ace', 'copy:customjs']);

gulp.task('copy:i18n', copy.i18n);

Expand All @@ -47,6 +47,8 @@ gulp.task('copy:images', copy.images);
// custom Martin
gulp.task('copy:jstree', copy.jstree);
gulp.task('copy:ace', copy.ace);
gulp.task('copy:customjs', copy.customjs);


gulp.task('images', function () {
return gulp.src(config.app + 'content/images/**')
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/it/cnr/si/config/ACERestConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package it.cnr.si.config;


import feign.Feign;
import feign.form.FormEncoder;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;
import it.cnr.si.flows.ng.service.AceAuthService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.security.oauth2.client.OAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;
import org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration;

import javax.inject.Inject;
import java.util.List;

//@Profile("cnr")
//@Configuration
//@EnableOAuth2Client
public class ACERestConfiguration {

@Inject
private OAuth2ClientContext oauth2Context;

@Value("${spring.ace.url}")
private String aceUrl;
@Value("${spring.ace.password}")
private String acePassword;
@Value("${spring.ace.username}")
private String aceUsername;

@Bean(name ="aceRestTemplate")
public OAuth2RestTemplate aceRestTemplate() {

final AceAuthService service = Feign.builder()
.decoder(new GsonDecoder())
.encoder(new FormEncoder(new GsonEncoder()))
.target(AceAuthService.class, aceUrl + "api");

service.getToken(aceUsername, acePassword);

ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
details.setPassword(acePassword);
details.setUsername(aceUsername);
details.setAccessTokenUri(aceUrl);
details.setTokenName("ace_token");

OAuth2RestTemplate rt = new OAuth2RestTemplate(details);
return rt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.stream.Collectors;

import static it.cnr.si.flows.ng.utils.Enum.Azione.Aggiornamento;
import static it.cnr.si.flows.ng.utils.Enum.Azione.Caricamento;

@Controller
@RequestMapping("api/attachments")
Expand Down Expand Up @@ -162,7 +163,14 @@ public void setAttachment(@PathVariable("processInstanceId") String processInsta

FlowsAttachment attachment = runtimeService.getVariable(processInstanceId, attachmentName, FlowsAttachment.class);

attachment.setAzione(Aggiornamento);
if (attachment != null) {
attachment.setAzione(Aggiornamento);
} else {
attachment = new FlowsAttachment();
attachment.setName(attachmentName);
attachment.setAzione(Caricamento);
}

attachment.setBytes(file.getBytes());
attachment.setFilename(file.getOriginalFilename());
attachment.setMimetype(file.getContentType());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/it/cnr/si/flows/ng/service/Ace.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface Ace {
@RequestLine("GET api/ace/v1/ruolo/{sigla}")
RuoloWebDto ruoloBySigla(@Param("sigla") String sigla);

@RequestLine("GET api/ace//v1/entitaorganizzativa/{id}")
@RequestLine("GET api/ace/v1/entitaorganizzativa/{id}")
EntitaOrganizzativaWebDto entitaOrganizzativaById(@Param("id") int id);

@RequestLine("GET api/ace/v1/entitaorganizzativa?term={term}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(function() {
'use strict';

angular.module('sprintApp')
.controller('AddAttachmentModalController', AddAttachmentModalController);


AddAttachmentModalController.$inject = ['$scope', '$uibModalInstance', 'dataService', 'processInstanceId', 'Upload', 'AlertService', '$log'];

function AddAttachmentModalController ($scope, $uibModalInstance, dataService, processInstanceId, Upload, AlertService, $log) {

var vm = this;
vm.data = {processInstanceId: processInstanceId};
$scope.data = {};

$scope.submitDocumento = function(file) {

Upload.upload({
url: 'api/attachments/'+ processInstanceId +'/'+ 'nuovoDocumento' +'/data',
data: $scope.data,
}).then(function (response) {
$scope.loadAttachments();
$uibModalInstance.close();
AlertService.success("Richiesta completata con successo");

}, function (err) {
$log.error(err);
AlertService.error("Richiesta non riuscita<br>"+ err.data.message);
});
}
}
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="modal-header">
<h4 class="modal-title">Carica un ulteriore documento</h4>
</div>
<div class="modal-body">

<div class="row">
<div class="col-md-12">
<h4>Carica Documento</h4>

<form novalidate class="flows-form" name="aggiornaDocumentoForm" ng-submit="submitDocumento(picFile)">

<fileinput name="file" multiple=false cnr-required=true />
<button class="btn btn-primary" type="submit" ng-disabled="aggiornaDocumentoForm.$invalid">
Invia
<span class="glyphicon glyphicon-arrow-right"></span>
</button>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="$dismiss()">Chiudi</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
.controller('AttachmentActionsModalController', AttachmentActionsModalController);


AttachmentActionsModalController.$inject = ['$scope', '$uibModalInstance', 'dataService', 'attachment', 'processInstanceId', 'Upload', 'AlertService'];
AttachmentActionsModalController.$inject = ['$scope', '$uibModalInstance', 'dataService', 'attachment', 'processInstanceId', 'Upload', 'AlertService', '$log'];

function AttachmentActionsModalController ($scope, $uibModalInstance, dataService, attachment, processInstanceId, Upload, AlertService) {
function AttachmentActionsModalController ($scope, $uibModalInstance, dataService, attachment, processInstanceId, Upload, AlertService, $log) {

var vm = this;

vm.attachment = attachment;

vm.pubblicato = vm.attachment.stati.indexOf("Pubblicato") >= 0;
$scope.data = {};

$scope.pubblicaDocumento = function(flag) {
dataService.attachments.pubblicaDocumento(processInstanceId, attachment.name, flag)
Expand All @@ -30,7 +31,7 @@

Upload.upload({
url: 'api/attachments/'+ processInstanceId +'/'+ attachment.name +'/data',
data: vm.data,
data: $scope.data,
}).then(function (response) {
$scope.loadAttachments();
$uibModalInstance.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@
});
};

$scope.addFile = function() {
$uibModal.open({
templateUrl: 'app/components/attachments/addattachment.modal.html',
controller: 'AddAttachmentModalController',
controllerAs: 'vm',
scope: $scope,
resolve: {
processInstanceId: function() {
return $scope.processInstanceId;
}
}
});
};

}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/app/components/attachments/attachments.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
</li>
</ul>

<button class="btn btn-xs btn-primary" ng-if="canUpdateAttachments" ng-click="addFile()">
<span class="glyphicon glyphicon-plus-sign"></span>
Carica un ulteriore documento
</button>

<script type="text/ng-template" id="fileHistoryModal.html">
<div class="modal-header">
<h4 class="modal-title">Storia del file {{name}}</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h4>Stato: {{process.name | get: 'stato'}}</h4>
Avviato il <strong>{{process.startTime | dataora}}</strong> da <strong> {{process.name | get:
'initiator'}} </strong>
</li>
<ng-include src="'api/views/' + process.processDefinitionId.split(':')[0] + '' + process.processDefinitionId.split(':')[1] + '/search'" />
<ng-include src="'api/views/' + process.processDefinitionId.split(':')[0] + '/' + process.processDefinitionId.split(':')[1] + '/search'" />
</ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
resolve: {
variables: function() {
//escludo le variabili di tipo "_json"
return variables.filter(variable => !variable.name.includes("_json"));
return variables.filter(variable >= !variable.name.includes("_json"));
},
title: function() {
return title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Membership.$inject = ['$resource'];

function Membership($resource) {
let resourceUrl = 'api/memberships/:id';
var resourceUrl = 'api/memberships/:id';

return $resource(resourceUrl, {}, {
'query': {
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/app/home/home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@

$q.all([principalPromise, profilePromise]).then(function(data) {
vm.account = data[0];
vm.profile = data[1];
vm.isAuthenticated = Principal.isAuthenticated;
if (vm.isAuthenticated)
if (vm.isAuthenticated && vm.profile == 'cnr')
getTasksCount();
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/app/inputs/fileinput/fileinput.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
$scope.attrs = attrs;
$scope.model = attrs.model;

if ($scope.$parent.attachments === undefined)
$scope.$parent.attachments = [];

if ($scope.attrs.multiple == 'false')
$scope.document = $scope.$parent.attachments.find(function(el) {
return el.name === $scope.attrs.name;
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/app/pages/statistics/statistics.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
//var vm = this;


let vm = this,
var vm = this,
dateFormat = 'yyyy-MM-dd';
vm.processDefinition = $stateParams.processDefinition.split(":")[0];
vm.isNavbarCollapsed = true;
vm.isAuthenticated = Principal.isAuthenticated;

$scope.exportFile = function(isPdf, processDefinitionKey, idStruttura, startDateGreat, startDateLess, filename) {
let url = (isPdf ? '/api/makeStatisticPdf?' : '/api/makeStatisticCsv?') +
var url = (isPdf ? '/api/makeStatisticPdf?' : '/api/makeStatisticCsv?') +
'processDefinitionKey=' + vm.processDefinition +
'&idStruttura=' + vm.exportParams.struttura +
'&startDateGreat=' + $filter('date')(vm.exportParams.startDateGreat, dateFormat) +
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/services/cnr/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
return $http.get('api/users/struttura/' + filter + '/search');
},
exportCsv: function(searchParams, firstResult, maxResults) {
let processDefinitionKey;
var processDefinitionKey;
if (searchParams.processDefinitionKey !== undefined) {
processDefinitionKey = searchParams.processDefinitionKey;
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/main/webapp/content/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,17 @@ input.ng-touched.ng-invalid, button.ng-touched.ng-invalid, textarea.ng-touched.n
flex: 1;
}

.banner {
height: 250px;
}

.cnr-banner {
background: url("../images/cnr-flows-banner.png") center no-repeat;
}

.oiv-banner {
background: url("../images/oiv-flows-banner.png") center no-repeat;
}

/* CSS per editor ACE */
.ace_editor {
Expand Down
Loading

0 comments on commit 9ecee55

Please sign in to comment.