r148 - in trunk: faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin faxtomail-ui-web/src/main/webapp/WEB-INF/decorators faxtomail-ui-web/src/main/webapp/js
Author: echatellier Date: 2014-06-08 14:38:26 +0200 (Sun, 08 Jun 2014) New Revision: 148 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/148 Log: Modification des filtres et mail accounts Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-06-08 10:56:31 UTC (rev 147) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-06-08 12:38:26 UTC (rev 148) @@ -50,6 +50,8 @@ import com.franciaflex.faxtomail.persistence.entities.MailFilterTopiaDao; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.google.common.base.Function; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; /** @@ -133,13 +135,26 @@ } /** - * Return all email accounts. + * Return all email accounts (without password info). * * @return all email account */ public List<EmailAccount> getEmailAccounts() { EmailAccountTopiaDao emailAccountTopiaDao = getPersistenceContext().getEmailAccountDao(); - return emailAccountTopiaDao.findAll(); + List<EmailAccount> accounts = emailAccountTopiaDao.findAll(); + + // remove password information from bean + final Binder<EmailAccount, EmailAccount> binderEmailAccount = BinderFactory.newBinder(EmailAccount.class); + List<EmailAccount> result = Lists.transform(accounts, new Function<EmailAccount, EmailAccount>() { + @Override + public EmailAccount apply(EmailAccount input) { + EmailAccount account = new EmailAccountImpl(); + binderEmailAccount.copyExcluding(input, account, EmailAccount.PROPERTY_PASSWORD); + return account; + } + }); + + return result; } /** @@ -147,10 +162,10 @@ * @param newEmailAccounts new email account list to save */ public void saveEmailAccounts(List<EmailAccount> newEmailAccounts) { - List<EmailAccount> emailAccounts = getEmailAccounts(); + EmailAccountTopiaDao emailAccountTopiaDao = getPersistenceContext().getEmailAccountDao(); + List<EmailAccount> emailAccounts = emailAccountTopiaDao.findAll(); Map<String, EmailAccount> emailAccountMap = new HashMap<>(Maps.uniqueIndex(emailAccounts, TopiaEntities.getTopiaIdFunction())); Binder<EmailAccount, EmailAccount> binder = BinderFactory.newBinder(EmailAccount.class); - EmailAccountTopiaDao emailAccountTopiaDao = getPersistenceContext().getEmailAccountDao(); for (EmailAccount newEmailAccount : newEmailAccounts) { EmailAccount emailAccount; @@ -159,12 +174,18 @@ } else { emailAccount = new EmailAccountImpl(); } - + binder.copyExcluding(newEmailAccount, emailAccount, EmailAccount.PROPERTY_TOPIA_ID, EmailAccount.PROPERTY_TOPIA_CREATE_DATE, - EmailAccount.PROPERTY_TOPIA_VERSION); - + EmailAccount.PROPERTY_TOPIA_VERSION, + EmailAccount.PROPERTY_PASSWORD); + + // password is only present for new account (not for edited ones) + if (StringUtils.isNotEmpty(newEmailAccount.getPassword())) { + emailAccount.setPassword(newEmailAccount.getPassword()); + } + if (emailAccount.isPersisted()) { emailAccountTopiaDao.update(emailAccount); } else { Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-08 10:56:31 UTC (rev 147) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-08 12:38:26 UTC (rev 148) @@ -91,7 +91,6 @@ <tr> <th>Extension</th> <th>Commandes</th> - <th>Suppr.</th> </tr> </thead> <tbody> @@ -100,29 +99,27 @@ <div class="form-group"> <input type="text" class="form-control" ng-model="extensionCommand.extension" size="5" placeholder="jpg" required> </div> + <a class="pull-right btn btn-danger btn-xs " ng-click="deleteExtensionRow($index)" title="Supprimer l'extension"> + <span class="glyphicon glyphicon-remove"></span></a> </td> <td> <div class="form-group"> <label for="convertToToPdfField">Conversion en pdf :</label> - <input id="convertToToPdfField" type="email" class="form-control" ng-model="extensionCommand.convertToPdfCommand" placeholder="" /> + <input id="convertToToPdfField" type="text" class="form-control" ng-model="extensionCommand.convertToPdfCommand" placeholder="" /> </div> <div class="form-group"> <label for="openAttachmentCommandField">Ouverture :</label> - <input id="openAttachmentCommandField" type="email" class="form-control" ng-model="extensionCommand.openAttachmentCommand" placeholder="" /> + <input id="openAttachmentCommandField" type="text" class="form-control" ng-model="extensionCommand.openAttachmentCommand" placeholder="" /> </div> </td> - <td> - <a class="pull-right btn btn-danger btn-xs " ng-click="deleteExtensionRow($index)" title="Supprimer l'extension"> - <span class="glyphicon glyphicon-remove"></span></a> - </td> </tr> <tr ng-if="!configuration.extensionCommands || configuration.extensionCommands.length == 0"> - <td colspan="3" class="emptyTable">Aucune extension définie</td> + <td colspan="2" class="emptyTable">Aucune extension définie</td> </tr> </tbody> <tfoot> <tr> - <td colspan="3"> + <td colspan="2"> <a class="pull-right btn btn-success btn-xs" ng-click="addExtensionRow()" > <span class="glyphicon glyphicon-plus"></span> Ajouter une ligne</a> </td> @@ -489,13 +486,73 @@ </div> </div> </div> - + + <!-- Liste des emails expéditeur --> + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <a data-toggle="collapse" data-parent="#accordion" href="#collapse5"> + Actions possibles du menu contextuel pour ce dossier + </a> + </h4> + </div> + <div id="collapse5" class="panel-collapse collapse"> + <div class="panel-body"> + <label class="checkbox" ng-repeat="(folderAction,label) in folderActions"> + <input type="checkbox" ng-checked="selectedMailFolder.folderActions.indexOf(folderAction) != -1" + ng-click="changeFolderAction(folderAction)"> {{label}} + </label> + </div> + </div> + </div> + + <!-- configuration des colonnes a afficher --> + <div class="panel panel-default"> + <div class="panel-heading"> + <h4 class="panel-title"> + <a data-toggle="collapse" data-parent="#accordion" href="#collapse6"> + Configuration des colonnes à afficher + </a> + </h4> + </div> + <div id="collapse6" class="panel-collapse collapse"> + <div class="panel-body"> + + <label> + <input type="checkbox" ng-model="selectedMailFolder.useCurrentLevelTableColumns" ng-value="true" /> Définir un ordre + différent du dossier parent à ce niveau.</label> + <hr /> + + <div class="control-group"> + <label class="control-label" for="tableColumns">Champs à afficher dans le tableau (l'ordre peut être changé en faisant un glisser/déposer sur les champs)</label> + + <div class="controls"> + <input type="hidden" ui-select2-sortable ng-model="folderTableColumns" + simple-query="getObjectsData" multiple sortable ng-disabled="!selectedMailFolder.useCurrentLevelTableColumns"> + </div> + </div> + + <div> + <table id='table-snapshot' class="table table-bordered"> + <caption>Aperçu</caption> + <thead> + <tr> + <th ng-repeat="etatAttenteField in folderTableColumns">{{mailFields[etatAttenteField.id]}}</th> + </tr> + </thead> + </table> + </div> + </div> + </div> + </div> + + <!-- Droits --> <div class="panel panel-default" ng-controller="ConfigurationRigthsController"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse4"> - Groupes/personnes ayant droit d'écriture sur le dossier + Droits </a> </h4> </div> @@ -581,65 +638,6 @@ </div> </div> </div> - - <!-- Liste des emails expéditeur --> - <div class="panel panel-default"> - <div class="panel-heading"> - <h4 class="panel-title"> - <a data-toggle="collapse" data-parent="#accordion" href="#collapse5"> - Actions possibles du menu contextuel pour ce dossier - </a> - </h4> - </div> - <div id="collapse5" class="panel-collapse collapse"> - <div class="panel-body"> - <label class="checkbox" ng-repeat="(folderAction,label) in folderActions"> - <input type="checkbox" ng-checked="selectedMailFolder.folderActions.indexOf(folderAction) != -1" - ng-click="changeFolderAction(folderAction)"> {{label}} - </label> - </div> - </div> - </div> - - <!-- configuration des colonnes a afficher --> - <div class="panel panel-default"> - <div class="panel-heading"> - <h4 class="panel-title"> - <a data-toggle="collapse" data-parent="#accordion" href="#collapse6"> - Configuration des colonnes à afficher - </a> - </h4> - </div> - <div id="collapse6" class="panel-collapse collapse"> - <div class="panel-body"> - - <label> - <input type="checkbox" ng-model="selectedMailFolder.useCurrentLevelTableColumns" ng-value="true" /> Définir un ordre - différent du dossier parent à ce niveau.</label> - <hr /> - - <div class="control-group"> - <label class="control-label" for="tableColumns">Champs à afficher dans le tableau (l'ordre peut être changé en faisant un glisser/déposer sur les champs)</label> - - <div class="controls"> - <input type="hidden" ui-select2-sortable ng-model="folderTableColumns" - simple-query="getObjectsData" multiple sortable ng-disabled="!selectedMailFolder.useCurrentLevelTableColumns"> - </div> - </div> - - <div> - <table id='table-snapshot' class="table table-bordered"> - <caption>Aperçu</caption> - <thead> - <tr> - <th ng-repeat="etatAttenteField in folderTableColumns">{{mailFields[etatAttenteField.id]}}</th> - </tr> - </thead> - </table> - </div> - </div> - </div> - </div> </div> </div> </div> @@ -666,11 +664,11 @@ <th/> </tr> </thead> - <tbody ui-sortable ng-model="mailFilters"> - <tr ng-repeat="mailFilter in mailFilters|filter:subFolderFilter(mailFolder)"> + <tbody ui-sortable="sortableOptions" ng-model="rootFolderMailFilters[mailFolder.topiaId]"> + <tr ng-repeat="mailFilter in rootFolderMailFilters[mailFolder.topiaId]"> <td>{{mailFilter.expression}}</td> <td>{{mailFilter.mailFolder.$fullPath}}</td> - <td><a class="btn btn-danger btn-xs" ng-click="removeFilter(mailFilter)"> + <td><a class="btn btn-danger btn-xs" ng-click="removeFilter(mailFolder, mailFilter)"> <span class="glyphicon glyphicon-remove"></span> </a></td> </tr> @@ -687,7 +685,7 @@ <select class="form-control" ng-model="newFilter.mailFolder" ng-options="mailFolder.$fullPath for mailFolder in flatMailFolders[mailFolder.topiaId]"></select> </div> </div> - <button type="button" class="btn btn-success" ng-disabled="!newFilter.expression || !newFilter.mailFolder" ng-click="addNewFilter()"> + <button type="button" class="btn btn-success" ng-disabled="!newFilter.expression || !newFilter.mailFolder" ng-click="addNewFilter(mailFolder)"> <i class="glyphicon glyphicon-plus"></i> Ajouter </button> </div> @@ -728,7 +726,6 @@ <th>Serveur</th> <th>Port</th> <th>Utilisateur</th> - <th>Mot de passe</th> <th/> </tr> </thead> @@ -738,7 +735,6 @@ <td>{{emailAccount.host}}</td> <td>{{emailAccount.port}}</td> <td>{{emailAccount.login}}</td> - <td>{{emailAccount.password}}</td> <td> <a class="btn btn-danger btn-xs" ng-click="removeEmailAccount($index)"> <span class="glyphicon glyphicon-remove"></span> @@ -761,7 +757,7 @@ ng-class="{'has-error': addEmailAccountForm.newAccountPort.$dirty && addEmailAccountForm.newAccountPort.$invalid, 'has-success': addEmailAccountForm.newAccountPort.$dirty && addEmailAccountForm.newAccountPort.$valid}"> <label for="emailAccountPort" class="control-label">Port:</label> - <input id="emailAccountPort" name="newAccountPort" type="text" class="form-control" ng-model="newAccount.port" ng-pattern="/^\d+$/" ng-minlength="1" /> + <input id="emailAccountPort" name="newAccountPort" type="text" class="form-control" ng-model="newAccount.port" ng-pattern="/^\d+$/" /> </div> <div class="form-group col-xs-2"> <label for="emailAccountUser" class="control-label">Utilisateur:</label> @@ -769,12 +765,16 @@ </div> <div class="form-group col-xs-2"> <label for="emailAccountPassword" class="control-label">Mot de passe:</label> - <input id="emailAccountPassword" type="text" class="form-control" ng-model="newAccount.password"> + <input id="emailAccountPassword" type="password" class="form-control" ng-model="newAccount.password"> </div> - <div class="form-group col-xs-1"> + <div class="form-group col-xs-2"> <br /> + <button type="button" class="btn btn-info" ng-disabled="!newAccount.host || !newAccount.port || addEmailAccountForm.$invalid" + tooltip="Fonctionnalité à venir"> + <i class="fa fa-cogs"></i> Test + </button> <button type="button" class="btn btn-success" ng-disabled="!newAccount.host || !newAccount.port || addEmailAccountForm.$invalid" ng-click="addEmailAccount()"> - <i class="glyphicon glyphicon-plus"></i> Ajouter + <i class="fa fa-plus"></i> Ajouter </button> </div> </div> Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-08 10:56:31 UTC (rev 147) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-08 12:38:26 UTC (rev 148) @@ -58,13 +58,13 @@ <nav class="collapse navbar-collapse" role="navigation"> <ul class="nav navbar-nav"> <li><a href="<s:url action='ldap-input' namespace="/admin" />"> - <span class="glyphicon glyphicon-retweet"></span> Ldap</a></li> + <span class="fa fa-database"></span> Ldap</a></li> <li><a href="<s:url action='configuration-input' namespace="/admin" />"> - <span class="glyphicon glyphicon-cog"></span> Configuration</a></li> + <span class="fa fa-cog"></span> Configuration</a></li> <li><a href="<s:url action='import-input' namespace="/admin" />"> - <span class="glyphicon glyphicon-upload"></span> Import</a></li> + <span class="fa fa-upload"></span> Import</a></li> <li><a href="<s:url action='user-folder-input' namespace="/admin" />"> - <span class="glyphicon glyphicon-th-list"></span> Dossiers utilisateur</a></li> + <span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li> </ul> </nav> </div> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-08 10:56:31 UTC (rev 147) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-08 12:38:26 UTC (rev 148) @@ -460,7 +460,6 @@ // add reply address $scope.addWriteRightGroup = function() { - console.log("dd") $scope.selectedMailFolder.writeRightGroups.push($scope.newWriteRightGroup); delete $scope.newWriteRightGroup; }; @@ -501,47 +500,71 @@ function($scope, $window, ConfigurationData) { //{Array} Current mail filter list $scope.mailFilters = ConfigurationData.mailFilters; + //{Map} Folder mail fiters + $scope.rootFolderMailFilters = {}; //{Object} New accout empty filter $scope.newFilter = {}; // replace filter instance with mailFolder filter instance to use same objects - angular.forEach($scope.mailFilters, function(filter) { - // root folder - angular.forEach($scope.mailFolders, function(mailFolder) { - if (mailFolder.topiaId == filter.mailFolder.topiaId) { - filter.mailFolder = mailFolder; - } else { + var updateMetaFilter = function() { + angular.forEach($scope.mailFilters, function(filter) { + // root folder + angular.forEach($scope.mailFolders, function(mailFolder) { + if (!$scope.rootFolderMailFilters.hasOwnProperty(mailFolder.topiaId)) { + $scope.rootFolderMailFilters[mailFolder.topiaId] = []; + } angular.forEach($scope.flatMailFolders[mailFolder.topiaId], function(subFolder) { if (subFolder.topiaId == filter.mailFolder.topiaId) { filter.mailFolder = subFolder; + + $scope.rootFolderMailFilters[subFolder.$rootFolder.topiaId].push(filter); } }); - } + }); }); + }; + // update when root folder collection changes (and for init) + $scope.$watchCollection("mailFolders", function(news, olds) { + console.log("Udpate MetaFilter"); + $scope.rootFolderMailFilters = {}; + updateMetaFilter(); }); + // option de la configuration 'sortable' + $scope.sortableOptions = { + stop: function(e, ui) { + $scope.mailFilters = []; + // update global $scope.mailFilters list + angular.forEach($scope.rootFolderMailFilters, function(folderFilters, rootFolderId) { + $scope.mailFilters = $scope.mailFilters.concat(folderFilters); + }); + } + }; + // add new filter action - $scope.addNewFilter = function() { + $scope.addNewFilter = function(rootMailFolder) { $scope.mailFilters.push($scope.newFilter); - + $scope.rootFolderMailFilters[rootMailFolder.topiaId].push($scope.newFilter); // clear form $scope.newFilter = {}; }; // remove filter - $scope.removeFilter = function(filter) { - if ($window.confirm("Êtes-vous sûr de vouloir supprimer ce filter ?")) { + $scope.removeFilter = function(rootMailFolder, filter) { + if ($window.confirm("Êtes-vous sûr de vouloir supprimer ce filtre ?")) { var index = $scope.mailFilters.indexOf(filter); $scope.mailFilters.splice(index, 1); + var index2 = $scope.rootFolderMailFilters[rootMailFolder.topiaId].indexOf(filter); + $scope.rootFolderMailFilters[rootMailFolder.topiaId].splice(index2, 1); } }; // define angular filter used to group mailFilters by rootFolders - $scope.subFolderFilter = function(mailFolder) { + /*$scope.subFolderFilter = function(mailFolder) { return function(item) { return item.mailFolder == mailFolder || item.mailFolder.$rootFolder == mailFolder; }; - }; + };*/ }]);
participants (1)
-
echatellier@users.forge.codelutin.com