refresh ui css + init inbox scanning settings

This commit is contained in:
Benjamin Gamard 2018-02-27 19:02:23 +01:00
parent 062dee987f
commit 797a987e2b
15 changed files with 416 additions and 86 deletions

View File

@ -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

View File

@ -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();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -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: {

View File

@ -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);
};
});

View File

@ -72,6 +72,7 @@
<script src="app/docs/controller/settings/SettingsDefault.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/SettingsAccount.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/SettingsConfig.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/SettingsInbox.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/SettingsSecurity.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/SettingsSecurityModalDisableTotp.js" type="text/javascript"></script>
<script src="app/docs/controller/settings/SettingsSession.js" type="text/javascript"></script>
@ -98,7 +99,7 @@
<!-- endref -->
</head>
<body translate-cloak ng-cloak>
<nav class="navbar navbar-inverse" role="navigation" ng-controller="Navigation">
<nav class="navbar navbar-default" role="navigation" ng-controller="Navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
ng-init="isCollapsed = true"
@ -113,7 +114,12 @@
<img src="../api/theme/image/logo" />
</div>
<a class="navbar-brand" href="#"> {{ appName }}</a>
<a class="navbar-brand" href="#">
<span ng-if="appName == 'Sismics Docs'">
<span style="color: #e43935;">Sismics</span> <span style="color: #2aabd2;">Docs</span>
</span>
<span ng-if="appName != 'Sismics Docs'">{{ appName }}</span>
</a>
</div>
<div class="collapse navbar-collapse" uib-collapse="isCollapsed">

View File

@ -13,7 +13,7 @@ angular.module('ngProgress.provider', ['ngProgress.directive'])
this.count = 0;
this.height = '2px';
this.$scope = $rootScope.$new();
this.color = 'white';
this.color = '#bbb';
this.parent = $document.find('body')[0];
this.count = 0;

View File

@ -245,6 +245,7 @@
"menu_groups": "Groups",
"menu_vocabularies": "Vocabularies",
"menu_configuration": "Configuration",
"menu_inbox": "Inbox scanning",
"menu_server_logs": "Server logs",
"user": {
"title": "Users management",

View File

@ -1,7 +1,17 @@
<div class="row row-full">
<script type="text/ng-template" id="tag-tree-item">
<span class="btn" ng-style="{ 'background-color': tag.color }"></span>
<span class="btn btn-link" ng-click="setSearch('tag:' + tag.name)">
{{ tag.name }}
</span>
<ul class="list-unstyled">
<li ng-repeat="tag in getChildrenTags(tag.id)" ng-include="'tag-tree-item'"></li>
</ul>
</script>
<div class="row">
<div class="col-md-4">
<div class="well well-full">
<div class="text-center mb-10">
<div class="well well-3d">
<div class="text-center mb-19">
<div class="btn-group" uib-dropdown>
<a href="#/document/add" class="btn btn-primary">
<span class="glyphicon glyphicon-plus"></span> {{ 'document.add_document' | translate }}
@ -126,8 +136,8 @@
<table class="row table table-hover table-documents">
<thead>
<tr>
<th class="col-xs-6" ng-click="sortDocuments(1)"><span class="glyphicon glyphicon-chevron-{{ sortColumn == 1 ? (asc ? 'down' : 'up') : '' }}"></span> {{ 'document.title' | translate }}</th>
<th class="col-xs-3" ng-click="sortDocuments(3)"><span class="glyphicon glyphicon-chevron-{{ sortColumn == 3 ? (asc ? 'down' : 'up') : '' }}"></span> {{ 'document.creation_date' | translate }}</th>
<th class="col-xs-6" ng-click="sortDocuments(1)">{{ 'document.title' | translate }} <span class="glyphicon glyphicon-chevron-{{ sortColumn == 1 ? (asc ? 'down' : 'up') : '' }}"></span></th>
<th class="col-xs-3" ng-click="sortDocuments(3)">{{ 'document.creation_date' | translate }} <span class="glyphicon glyphicon-chevron-{{ sortColumn == 3 ? (asc ? 'down' : 'up') : '' }}"></span></th>
</tr>
</thead>
<tbody>
@ -194,13 +204,3 @@
<div ui-view="document"></div>
</div>
</div>
<script type="text/ng-template" id="tag-tree-item">
<span class="btn" ng-style="{ 'background-color': tag.color }"></span>
<span class="btn btn-link" ng-click="setSearch('tag:' + tag.name)">
{{ tag.name }}
</span>
<ul class="list-unstyled">
<li ng-repeat="tag in getChildrenTags(tag.id)" ng-include="'tag-tree-item'"></li>
</ul>
</script>

View File

@ -1,5 +1,5 @@
<div class="row">
<div class="col-md-3">
<div class="col-md-3 settings-menu">
<div class="panel panel-default">
<div class="panel-heading"><strong>{{ 'settings.menu_personal_settings' | translate }}</strong></div>
<ul class="list-group">
@ -15,6 +15,7 @@
<a class="list-group-item" ui-sref-active="{ active: 'settings.workflow.**' }" href="#/settings/workflow">{{ 'settings.menu_workflow' | translate }}</a>
<a class="list-group-item" ui-sref-active="{ active: 'settings.user.**' }" href="#/settings/user">{{ 'settings.menu_users' | translate }}</a>
<a class="list-group-item" ui-sref-active="{ active: 'settings.group.**' }" href="#/settings/group">{{ 'settings.menu_groups' | translate }}</a>
<a class="list-group-item" ui-sref-active="{ active: 'settings.inbox.**' }" href="#/settings/inbox">{{ 'settings.menu_inbox' | translate }}</a>
<a class="list-group-item" ui-sref-active="{ active: 'settings.vocabulary.**' }" href="#/settings/vocabulary">{{ 'settings.menu_vocabularies' | translate }}</a>
<a class="list-group-item" ui-sref-active="{ active: 'settings.config.**' }" href="#/settings/config">{{ 'settings.menu_configuration' | translate }}</a>
<a class="list-group-item" ui-sref-active="{ active: 'settings.log.**' }" href="#/settings/log">{{ 'settings.menu_server_logs' | translate }}</a>
@ -22,7 +23,7 @@
</div>
</div>
<div class="col-md-9">
<div class="col-md-9 settings-content">
<div ui-view="settings"></div>
</div>
</div>

View File

@ -0,0 +1,145 @@
<h2>
<span translate="settings.config.title_guest_access"></span>
<span class="label" ng-class="{ 'label-success': app.guest_login, 'label-danger': !app.guest_login }">
{{ app.guest_login ? 'enabled' : 'disabled' | translate }}
</span>
</h2>
<p translate="settings.config.message_guest_access" translate-values="{ appName: appName }">
</p>
<div ng-if="app">
<button ng-if="!app.guest_login" class="btn btn-primary" ng-click="changeGuestLogin(true)">{{ 'settings.config.enable_guest_access' | translate }}</button>
<button ng-if="app.guest_login" class="btn btn-danger" ng-click="changeGuestLogin(false)">{{ 'settings.config.disable_guest_access' | translate }}</button>
</div>
<h2 translate="settings.config.title_general"></h2>
<form class="form-horizontal" name="generalForm" novalidate>
<div class="form-group" ng-class="{ 'has-error': !generalForm.defaultLanguage.$valid && generalForm.$dirty }">
<label class="col-sm-2 control-label" for="defaultLanguage">{{ 'settings.config.default_language' | translate }}</label>
<div class="col-sm-7">
<select name="defaultLanguage" class="form-control" id="defaultLanguage" ng-model="general.default_language">
<option ng-repeat="language in acceptedLanguages" value="{{ language.key }}">{{ language.label }}</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-click="editGeneralConfig()" ng-disabled="!generalForm.$valid">
<span class="glyphicon glyphicon-pencil"></span> {{ 'save' | translate }}
</button>
</div>
</div>
</form>
<h2 translate="settings.config.title_theme"></h2>
<form class="form-horizontal" name="editColorForm" novalidate>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputName">{{ 'settings.config.application_name' | translate }}</label>
<div class="col-sm-8">
<input type="text" class="form-control"
id="inputName" ng-model="theme.name" ng-blur="update()" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputColor">{{ 'settings.config.main_color' | translate }}</label>
<div class="col-sm-1">
<span colorpicker class="btn btn-default" id="inputColor" on-hide="update()"
data-color="" ng-model="theme.color" ng-style="{ 'background': theme.color }">&nbsp;&nbsp;&nbsp;</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputCss">{{ 'settings.config.custom_css' | translate }}</label>
<div class="col-sm-8">
<textarea class="form-control" rows="6" ng-attr-placeholder="{{ 'settings.config.custom_css_placeholder' | translate }}"
id="inputCss" ng-model="theme.css" ng-blur="update()"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputLogo">{{ 'settings.config.logo' | translate }}</label>
<div class="col-sm-2">
<input type="file" ngf-select ngf-accept="'image/gif,image/png,image/jpg,image/jpeg'"
class="form-control" id="inputLogo" ng-model="logo" ng-disabled="sendingImage" />
</div>
<div class="col-sm-2">
<button class="btn btn-default" ng-click="sendImage('logo', logo)" ng-disabled="sendingImage || !logo">
<span class="glyphicon glyphicon-save"></span>
{{ 'send' | translate }}
</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputBackground">{{ 'settings.config.background_image' | translate }}</label>
<div class="col-sm-2">
<input type="file" ngf-select ngf-accept="'image/gif,image/png,image/jpg,image/jpeg'"
class="form-control" id="inputBackground" ng-model="background" ng-disabled="sendingImage" />
</div>
<div class="col-sm-2">
<button class="btn btn-default" ng-click="sendImage('background', background)" ng-disabled="sendingImage || !background">
<span class="glyphicon glyphicon-save"></span>
{{ 'send' | translate }}
</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<p class="form-control-static text-info" ng-if="sendingImage">
{{ 'settings.config.uploading_image' | translate }}
</p>
</div>
</div>
</form>
<h2 translate="settings.config.title_smtp"></h2>
<form class="form-horizontal" name="smtpForm" novalidate>
<div class="form-group" ng-show="smtp.hasOwnProperty('hostname')" ng-class="{ 'has-error': !smtpForm.hostname.$valid && smtpForm.$dirty }">
<label class="col-sm-2 control-label" for="smtpHostname">{{ 'settings.config.smtp_hostname' | translate }}</label>
<div class="col-sm-7">
<input name="hostname" type="text" ng-disabled="!smtp.hasOwnProperty('hostname')" class="form-control" id="smtpHostname" ng-model="smtp.hostname" />
</div>
</div>
<div class="form-group" ng-show="smtp.hasOwnProperty('port')" ng-class="{ 'has-error': !smtpForm.port.$valid && smtpForm.$dirty }">
<label class="col-sm-2 control-label" for="smtpPort">{{ 'settings.config.smtp_port' | translate }}</label>
<div class="col-sm-7">
<input name="port" type="number" ng-disabled="!smtp.hasOwnProperty('port')" class="form-control" id="smtpPort" ng-model="smtp.port" />
</div>
</div>
<div class="form-group" ng-show="smtp.hasOwnProperty('username')">
<label class="col-sm-2 control-label" for="smtpUsername">{{ 'settings.config.smtp_username' | translate }}</label>
<div class="col-sm-7">
<input name="username" type="text" ng-disabled="!smtp.hasOwnProperty('username')" class="form-control" id="smtpUsername" ng-model="smtp.username" />
</div>
</div>
<div class="form-group" ng-show="smtp.hasOwnProperty('password')">
<label class="col-sm-2 control-label" for="smtpPassword">{{ 'settings.config.smtp_password' | translate }}</label>
<div class="col-sm-7">
<input name="password" type="password" ng-disabled="!smtp.hasOwnProperty('password')" class="form-control" id="smtpPassword" ng-model="smtp.password" />
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !smtpForm.from.$valid && smtpForm.$dirty }">
<label class="col-sm-2 control-label" for="smtpFrom">{{ 'settings.config.smtp_from' | translate }}</label>
<div class="col-sm-7">
<input name="from" type="email" class="form-control" id="smtpFrom" ng-model="smtp.from" />
</div>
<div class="col-sm-3">
<span class="help-block" ng-show="smtpForm.from.$error.email && smtpForm.$dirty">{{ 'validation.email' | translate }}</span>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-click="editSmtpConfig()" ng-disabled="!smtpForm.$valid">
<span class="glyphicon glyphicon-pencil"></span> {{ 'save' | translate }}
</button>
</div>
</div>
</form>

View File

@ -1,6 +1,6 @@
<div class="row row-full">
<div class="row">
<div class="col-md-4">
<div class="well well-full">
<div class="well well-3d">
<form name="tagForm" novalidate>
<p class="input-group" ng-class="{ 'has-error': !tagForm.name.$valid && tagForm.$dirty }">
<span colorpicker class="input-group-addon btn btn-default" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }">&nbsp;</span>

View File

@ -1,6 +1,6 @@
<div class="row">
<div class="col-md-4">
<div class="well">
<div class="well well-3d">
<p class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
<input type="search" class="form-control" ng-attr-placeholder="{{ 'usergroup.search_groups' | translate }}" ng-model="searchGroup">
@ -18,7 +18,7 @@
</table>
</div>
<div class="well">
<div class="well well-3d">
<p class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
<input type="search" class="form-control" ng-attr-placeholder="{{ 'usergroup.search_users' | translate }}" ng-model="searchUser">

View File

@ -34,36 +34,28 @@
// Documents list
.table-documents {
thead th {
cursor: pointer;
white-space: nowrap;
}
tbody tr {
cursor: pointer;
margin-top: 18px !important;
td {
.label {
margin-left: 5px;
}
}
}
}
@media (min-width: 992px) {
.row-full {
overflow: hidden;
margin-top: -20px !important;
min-height: 80vh;
thead th {
cursor: pointer;
white-space: nowrap;
text-transform: uppercase;
font-weight: 500;
background-color: #f6f9fc;
border: none !important;
font-size: 90%;
}
tbody tr {
cursor: pointer;
.well-full {
margin-left: -15px;
padding-bottom: 1000px;
margin-bottom: -980px;
height: 100%;
background-color: #f5f5f5;
box-shadow: inset -2px 0 0 #e5e5e5;
td {
.label {
margin-left: 5px;
}
border: none;
}
}
}
@ -320,6 +312,55 @@ input[readonly].share-link {
}
}
// Settings
.settings-menu {
.panel-default {
border: 1px solid #eee;
box-shadow: 0 7px 14px 0 rgba(50,50,93,.1), 0 3px 6px 0 rgba(0,0,0,.07);
border-radius: 4px;
& > .panel-heading {
border-bottom: none;
background: #f9f9f9;
strong {
font-weight: 500;
}
}
.list-group-item {
border: none;
}
.list-group-item.active {
background: none;
color: #337ab7;
font-weight: 500;
}
}
}
.settings-content {
.well {
box-shadow: 0 7px 14px 0 rgba(50,50,93,.1), 0 3px 6px 0 rgba(0,0,0,.07);
background: none;
padding: 0;
border-radius: 4px;
.table {
margin-bottom: 0;
}
th {
text-transform: uppercase;
font-weight: 500;
background-color: #f6f9fc;
border-bottom: 1px solid #ddd;
font-size: 90%;
}
}
}
// Feedback
.feedback {
display: block;
@ -451,10 +492,51 @@ input[readonly].share-link {
margin-bottom: 10px;
}
// Buttons
.mb-19 {
margin-bottom: 19px;
}
// BS customizations
.btn {
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
font-weight: 400;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
font-weight: 500;
border-radius: 4px;
box-shadow: 0 0 0 1px rgba(50,50,93,.1), 0 2px 5px 0 rgba(50,50,93,.08), 0 1px 1.5px 0 rgba(0,0,0,.07), 0 1px 2px 0 rgba(0,0,0,.08), 0 0 0 0 transparent;
}
.form-control {
border-radius: 4px;
box-shadow: 0 0 0 1px rgba(49,49,93,.03), 0 2px 5px 0 rgba(49,49,93,.1), 0 1px 2px 0 rgba(0,0,0,.08);
}
.dropdown-menu {
border: none;
box-shadow: 0 0 0 1px rgba(136,152,170,.1), 0 15px 35px 0 rgba(49,49,93,.1), 0 5px 15px 0 rgba(0,0,0,.13);
}
.navbar-default {
border: none;
.navbar-brand {
color: white;
}
}
.nav > li {
font-weight: 500;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #2ab2dc;
background: none;
}
.well-3d {
border: 1px solid #eee;
box-shadow: 0 7px 14px 0 rgba(50,50,93,.1), 0 3px 6px 0 rgba(0,0,0,.07);
background: none;
border-radius: 4px;
}

View File

@ -32,13 +32,13 @@ public class TestThemeResource extends BaseJerseyTest {
// Get the stylesheet anonymously
String stylesheet = target().path("/theme/stylesheet").request()
.get(String.class);
Assert.assertTrue(stylesheet.contains("background-color: #24292e;"));
Assert.assertTrue(stylesheet.contains("background-color: #ffffff;"));
// Get the theme configuration anonymously
JsonObject json = target().path("/theme").request()
.get(JsonObject.class);
Assert.assertEquals("Sismics Docs", json.getString("name"));
Assert.assertEquals("#24292e", json.getString("color"));
Assert.assertEquals("#ffffff", json.getString("color"));
Assert.assertEquals("", json.getString("css"));
// Update the main color as admin