diff --git a/docs-core/src/main/java/com/sismics/docs/core/service/InboxService.java b/docs-core/src/main/java/com/sismics/docs/core/service/InboxService.java index d1622b95..2df5c6e5 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/service/InboxService.java +++ b/docs-core/src/main/java/com/sismics/docs/core/service/InboxService.java @@ -21,7 +21,6 @@ import javax.mail.*; import java.util.Date; import java.util.Properties; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; /** * Inbox scanning service. @@ -57,6 +56,9 @@ public class InboxService extends AbstractScheduledService { syncInbox(); } + /** + * Synchronize the inbox. + */ public void syncInbox() { TransactionUtil.handle(new Runnable() { @Override @@ -98,36 +100,34 @@ public class InboxService extends AbstractScheduledService { }); } + /** + * Test the inbox configuration. + * + * @return Number of messages currently in the remote inbox + */ public int testInbox() { - final AtomicInteger count = new AtomicInteger(-1); - TransactionUtil.handle(new Runnable() { - @Override - public void run() { - Boolean enabled = ConfigUtil.getConfigBooleanValue(ConfigType.INBOX_ENABLED); - if (!enabled) { - return; - } + Boolean enabled = ConfigUtil.getConfigBooleanValue(ConfigType.INBOX_ENABLED); + if (!enabled) { + return -1; + } - Folder inbox = null; - try { - inbox = openInbox(); - count.set(inbox.getMessageCount()); - } catch (Exception e) { - log.error("Error testing inbox", e); - } finally { - try { - if (inbox != null) { - inbox.close(false); - inbox.getStore().close(); - } - } catch (Exception e) { - // NOP - } + Folder inbox = null; + try { + inbox = openInbox(); + return inbox.getMessageCount(); + } catch (Exception e) { + log.error("Error testing inbox", e); + return -1; + } finally { + try { + if (inbox != null) { + inbox.close(false); + inbox.getStore().close(); } + } catch (Exception e) { + // NOP } - }); - - return count.get(); + } } @Override @@ -139,6 +139,7 @@ public class InboxService extends AbstractScheduledService { * Open the remote inbox. * * @return Opened inbox folder + * @throws Exception e */ private Folder openInbox() throws Exception { Properties properties = new Properties(); @@ -167,7 +168,7 @@ public class InboxService extends AbstractScheduledService { * Import an email. * * @param message Message - * @throws Exception + * @throws Exception e */ private void importMessage(Message message) throws Exception { // Parse the mail diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java index 430787ea..dd60e7c2 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/ThemeResource.java @@ -58,7 +58,7 @@ public class ThemeResource extends BaseResource { // Build the stylesheet StringBuilder sb = new StringBuilder(); sb.append(new Selector(".navbar") - .rule("background-color", themeConfig.getString("color", "#24292e"))); + .rule("background-color", themeConfig.getString("color", "#ffffff"))); sb.append(themeConfig.getString("css", "")); return Response.ok().entity(sb.toString()).build(); @@ -83,7 +83,7 @@ public class ThemeResource extends BaseResource { JsonObject themeConfig = getThemeConfig(); JsonObjectBuilder json = Json.createObjectBuilder(); json.add("name", themeConfig.getString("name", "Sismics Docs")); - json.add("color", themeConfig.getString("color", "#24292e")); + json.add("color", themeConfig.getString("color", "#ffffff")); json.add("css", themeConfig.getString("css", "")); return Response.ok().entity(json.build()).build(); } diff --git a/docs-web/src/main/resources/image/logo.png b/docs-web/src/main/resources/image/logo.png index 1bcc7321..ae3e9f12 100644 Binary files a/docs-web/src/main/resources/image/logo.png and b/docs-web/src/main/resources/image/logo.png differ diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 2c644506..f7095127 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -128,6 +128,15 @@ angular.module('docs', } } }) + .state('settings.inbox', { + url: '/inbox', + views: { + 'settings': { + templateUrl: 'partial/docs/settings.inbox.html', + controller: 'SettingsInbox' + } + } + }) .state('settings.user', { url: '/user', views: { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsInbox.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsInbox.js new file mode 100644 index 00000000..cc7a5ec2 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsInbox.js @@ -0,0 +1,85 @@ +'use strict'; + +/** + * Settings inbox page controller. + */ +angular.module('docs').controller('SettingsInbox', function($scope, $rootScope, Restangular) { + // Get the app configuration + Restangular.one('app').get().then(function (data) { + $rootScope.app = data; + $scope.general = { + default_language: data.default_language + } + }); + + // Enable/disable guest login + $scope.changeGuestLogin = function (enabled) { + Restangular.one('app').post('guest_login', { + enabled: enabled + }).then(function () { + $scope.app.guest_login = enabled; + }); + }; + + // Fetch the current theme configuration + Restangular.one('theme').get().then(function (data) { + $scope.theme = data; + $rootScope.appName = $scope.theme.name; + }); + + // Update the theme + $scope.update = function () { + $scope.theme.name = $scope.theme.name.length === 0 ? 'Sismics Docs' : $scope.theme.name; + Restangular.one('theme').post('', $scope.theme).then(function () { + var stylesheet = $('#theme-stylesheet')[0]; + stylesheet.href = stylesheet.href.replace(/\?.*|$/, '?' + new Date().getTime()); + $rootScope.appName = $scope.theme.name; + }); + }; + + // Send an image + $scope.sendingImage = false; + $scope.sendImage = function (type, image) { + // Build the payload + var formData = new FormData(); + formData.append('image', image); + + // Send the file + var done = function() { + $scope.$apply(function() { + $scope.sendingImage = false; + $scope[type] = null; + }); + }; + $scope.sendingImage = true; + $.ajax({ + type: 'PUT', + url: '../api/theme/image/' + type, + data: formData, + cache: false, + contentType: false, + processData: false, + success: function() { + done(); + }, + error: function() { + done(); + } + }); + }; + + // Load SMTP config + Restangular.one('app/config_smtp').get().then(function (data) { + $scope.smtp = data; + }); + + // Edit SMTP config + $scope.editSmtpConfig = function () { + Restangular.one('app').post('config_smtp', $scope.smtp); + }; + + // Edit general config + $scope.editGeneralConfig = function () { + Restangular.one('app').post('config', $scope.general); + }; +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index a8798e1d..77aff9d3 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -72,6 +72,7 @@ + @@ -98,7 +99,7 @@
-