#179: default language (ui)

This commit is contained in:
Benjamin Gamard 2018-02-25 16:55:45 +01:00
parent 9a9e86829e
commit f379b4e5ab
7 changed files with 62 additions and 32 deletions

View File

@ -3,6 +3,7 @@ package com.sismics.docs.rest.resource;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.sismics.docs.core.constant.AclType; import com.sismics.docs.core.constant.AclType;
import com.sismics.docs.core.constant.ConfigType;
import com.sismics.docs.core.constant.Constants; import com.sismics.docs.core.constant.Constants;
import com.sismics.docs.core.constant.PermType; import com.sismics.docs.core.constant.PermType;
import com.sismics.docs.core.dao.jpa.*; import com.sismics.docs.core.dao.jpa.*;
@ -16,6 +17,7 @@ import com.sismics.docs.core.event.FileDeletedAsyncEvent;
import com.sismics.docs.core.model.jpa.Document; import com.sismics.docs.core.model.jpa.Document;
import com.sismics.docs.core.model.jpa.File; import com.sismics.docs.core.model.jpa.File;
import com.sismics.docs.core.model.jpa.User; import com.sismics.docs.core.model.jpa.User;
import com.sismics.docs.core.util.ConfigUtil;
import com.sismics.docs.core.util.DocumentUtil; import com.sismics.docs.core.util.DocumentUtil;
import com.sismics.docs.core.util.FileUtil; import com.sismics.docs.core.util.FileUtil;
import com.sismics.docs.core.util.PdfUtil; import com.sismics.docs.core.util.PdfUtil;
@ -831,7 +833,7 @@ public class DocumentResource extends BaseResource {
document.setSubject(StringUtils.abbreviate(mailContent.getSubject(), 500)); document.setSubject(StringUtils.abbreviate(mailContent.getSubject(), 500));
document.setFormat("EML"); document.setFormat("EML");
document.setSource("Email"); document.setSource("Email");
document.setLanguage("eng"); document.setLanguage(ConfigUtil.getConfigStringValue(ConfigType.DEFAULT_LANGUAGE));
if (mailContent.getDate() == null) { if (mailContent.getDate() == null) {
document.setCreateDate(new Date()); document.setCreateDate(new Date());
} else { } else {

View File

@ -6,7 +6,7 @@
angular.module('docs').controller('Footer', function($scope, $rootScope, Restangular, $translate, timeAgoSettings, tmhDynamicLocale, $locale) { angular.module('docs').controller('Footer', function($scope, $rootScope, Restangular, $translate, timeAgoSettings, tmhDynamicLocale, $locale) {
// Load app data // Load app data
Restangular.one('app').get().then(function(data) { Restangular.one('app').get().then(function(data) {
$scope.app = data; $rootScope.app = data;
}); });
// Save the current language to local storage // Save the current language to local storage

View File

@ -8,7 +8,7 @@ angular.module('docs').controller('Login', function(Restangular, $scope, $rootSc
// Get the app configuration // Get the app configuration
Restangular.one('app').get().then(function(data) { Restangular.one('app').get().then(function(data) {
$scope.app = data; $rootScope.app = data;
}); });
// Login as guest // Login as guest

View File

@ -51,17 +51,15 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $
* Reset the form to add a new document. * Reset the form to add a new document.
*/ */
$scope.resetForm = function() { $scope.resetForm = function() {
var languages = { var language = 'eng';
en: 'eng', if ($rootScope.app && $rootScope.app.default_language) {
fr: 'fra', language = $rootScope.app.default_language;
zh_CN: 'chi_sim' }
};
var language = languages[$translate.use()];
$scope.document = { $scope.document = {
tags: [], tags: [],
relations: [], relations: [],
language: language ? language : 'eng' language: language
}; };
$scope.newFiles = []; $scope.newFiles = [];

View File

@ -6,7 +6,10 @@
angular.module('docs').controller('SettingsConfig', function($scope, $rootScope, Restangular) { angular.module('docs').controller('SettingsConfig', function($scope, $rootScope, Restangular) {
// Get the app configuration // Get the app configuration
Restangular.one('app').get().then(function (data) { Restangular.one('app').get().then(function (data) {
$scope.app = data; $rootScope.app = data;
$scope.general = {
default_language: data.default_language
}
}); });
// Enable/disable guest login // Enable/disable guest login
@ -74,4 +77,9 @@ angular.module('docs').controller('SettingsConfig', function($scope, $rootScope,
$scope.editSmtpConfig = function () { $scope.editSmtpConfig = function () {
Restangular.one('app').post('config_smtp', $scope.smtp); Restangular.one('app').post('config_smtp', $scope.smtp);
}; };
// Edit general config
$scope.editGeneralConfig = function () {
Restangular.one('app').post('config', $scope.general);
};
}); });

View File

@ -247,7 +247,7 @@
"menu_configuration": "Configuration", "menu_configuration": "Configuration",
"menu_server_logs": "Server logs", "menu_server_logs": "Server logs",
"user": { "user": {
"title": "Users <small>management</small>", "title": "Users management",
"add_user": "Add a user", "add_user": "Add a user",
"username": "Username", "username": "Username",
"create_date": "Create date", "create_date": "Create date",
@ -257,8 +257,8 @@
"delete_user_message": "Do you really want to delete this user? All associated documents, files and tags will be deleted", "delete_user_message": "Do you really want to delete this user? All associated documents, files and tags will be deleted",
"edit_user_failed_title": "User already exists", "edit_user_failed_title": "User already exists",
"edit_user_failed_message": "This username is already taken by another user", "edit_user_failed_message": "This username is already taken by another user",
"edit_user_title": "<small>Edit</small> \"{{ username }}\"", "edit_user_title": "Edit \"{{ username }}\"",
"add_user_title": "<small>Add a</small> user", "add_user_title": "Add a user",
"username": "Username", "username": "Username",
"email": "E-mail", "email": "E-mail",
"groups": "Groups", "groups": "Groups",
@ -273,15 +273,15 @@
} }
}, },
"workflow": { "workflow": {
"title": "Workflow <small>configuration</small>", "title": "Workflow configuration",
"add_workflow": "Add a workflow", "add_workflow": "Add a workflow",
"name": "Name", "name": "Name",
"create_date": "Create date", "create_date": "Create date",
"edit": { "edit": {
"delete_workflow_title": "Delete workflow", "delete_workflow_title": "Delete workflow",
"delete_workflow_message": "Do you really want to delete this workflow? Currently running workflows will not be deleted", "delete_workflow_message": "Do you really want to delete this workflow? Currently running workflows will not be deleted",
"edit_workflow_title": "<small>Edit</small> \"{{ name }}\"", "edit_workflow_title": "Edit \"{{ name }}\"",
"add_workflow_title": "<small>Add a</small> workflow", "add_workflow_title": "Add a workflow",
"name": "Name", "name": "Name",
"name_placeholder": "Step name or description", "name_placeholder": "Step name or description",
"drag_help": "Drag and drop to rorder the step", "drag_help": "Drag and drop to rorder the step",
@ -296,7 +296,7 @@
"security": { "security": {
"enable_totp": "Enable two-factor authentication", "enable_totp": "Enable two-factor authentication",
"enable_totp_message": "Make sure you have a TOTP-compatible application on your phone ready to add a new account", "enable_totp_message": "Make sure you have a TOTP-compatible application on your phone ready to add a new account",
"title": "Two-factor <small>authentication</small>", "title": "Two-factor authentication",
"message_1": "Two-factor authentication allows you to add a layer of security on your <strong>{{ appName }}</strong> account.<br/>Before activating this feature, make sure you have a TOTP-compatible app on your phone:", "message_1": "Two-factor authentication allows you to add a layer of security on your <strong>{{ appName }}</strong> account.<br/>Before activating this feature, make sure you have a TOTP-compatible app on your phone:",
"message_google_authenticator": "For Android, iOS, and Blackberry: <a href=\"https://support.google.com/accounts/answer/1066447\" target=\"_blank\">Google Authenticator</a>", "message_google_authenticator": "For Android, iOS, and Blackberry: <a href=\"https://support.google.com/accounts/answer/1066447\" target=\"_blank\">Google Authenticator</a>",
"message_duo_mobile": "For Android and iOS: <a href=\"https://guide.duo.com/third-party-accounts\" target=\"_blank\">Duo Mobile</a>", "message_duo_mobile": "For Android and iOS: <a href=\"https://guide.duo.com/third-party-accounts\" target=\"_blank\">Duo Mobile</a>",
@ -313,7 +313,7 @@
} }
}, },
"group": { "group": {
"title": "Groups <small>management</small>", "title": "Groups management",
"add_group": "Add a group", "add_group": "Add a group",
"name": "Name", "name": "Name",
"edit": { "edit": {
@ -321,8 +321,8 @@
"delete_group_message": "Do you really want to delete this group?", "delete_group_message": "Do you really want to delete this group?",
"edit_group_failed_title": "Group already exists", "edit_group_failed_title": "Group already exists",
"edit_group_failed_message": "This group name is already taken by another group", "edit_group_failed_message": "This group name is already taken by another group",
"edit_group_title": "Edit <small>\"{{ name }}\"</small>", "edit_group_title": "Edit \"{{ name }}\"",
"add_group_title": "<small>Add a</small> group", "add_group_title": "Add a group",
"name": "Name", "name": "Name",
"parent_group": "Parent group", "parent_group": "Parent group",
"search_group": "Search a group", "search_group": "Search a group",
@ -332,17 +332,19 @@
} }
}, },
"account": { "account": {
"title": "User <small>account</small>", "title": "User account",
"password": "Password", "password": "Password",
"password_confirm": "Password (confirm)", "password_confirm": "Password (confirm)",
"updated": "Account successfully updated" "updated": "Account successfully updated"
}, },
"config": { "config": {
"title_guest_access": "Guest <small>access</small>", "title_guest_access": "Guest access",
"message_guest_access": "Guest access is a mode where anyone can access {{ appName }} without password.<br/>Like a normal user, the guest user can only access its documents and those accessible through permissions.<br/>", "message_guest_access": "Guest access is a mode where anyone can access {{ appName }} without password.<br/>Like a normal user, the guest user can only access its documents and those accessible through permissions.<br/>",
"enable_guest_access": "Enable guest access", "enable_guest_access": "Enable guest access",
"disable_guest_access": "Disable guest access", "disable_guest_access": "Disable guest access",
"title_theme": "Theme <small>customization</small>", "title_theme": "Theme customization",
"title_general": "General configuration",
"default_language": "Default language for new documents",
"application_name": "Application name", "application_name": "Application name",
"main_color": "Main color", "main_color": "Main color",
"custom_css": "Custom CSS", "custom_css": "Custom CSS",
@ -350,7 +352,7 @@
"logo": "Logo (squared size)", "logo": "Logo (squared size)",
"background_image": "Background image", "background_image": "Background image",
"uploading_image": "Uploading the image...", "uploading_image": "Uploading the image...",
"title_smtp": "Email <small>configuration</small>", "title_smtp": "Email configuration",
"smtp_hostname": "SMTP hostname", "smtp_hostname": "SMTP hostname",
"smtp_port": "SMTP port", "smtp_port": "SMTP port",
"smtp_from": "Sender e-mail", "smtp_from": "Sender e-mail",
@ -359,13 +361,13 @@
"smtp_updated": "SMTP configuration updated successfully" "smtp_updated": "SMTP configuration updated successfully"
}, },
"log": { "log": {
"title": "Server <small>logs</small>", "title": "Server logs",
"date": "Date", "date": "Date",
"tag": "Tag", "tag": "Tag",
"message": "Message" "message": "Message"
}, },
"session": { "session": {
"title": "Opened <small>sessions</small>", "title": "Opened sessions",
"created_date": "Created date", "created_date": "Created date",
"last_connection_date": "Last connection date", "last_connection_date": "Last connection date",
"user_agent": "From", "user_agent": "From",
@ -375,7 +377,7 @@
"clear": "Clear all other sessions" "clear": "Clear all other sessions"
}, },
"vocabulary": { "vocabulary": {
"title": "Vocabulary <small>entries</small>", "title": "Vocabulary entries",
"choose_vocabulary": "Choose a vocabulary to edit", "choose_vocabulary": "Choose a vocabulary to edit",
"type": "Type", "type": "Type",
"coverage": "Coverage", "coverage": "Coverage",

View File

@ -1,9 +1,9 @@
<h1> <h2>
<span translate="settings.config.title_guest_access"></span> <span translate="settings.config.title_guest_access"></span>
<span class="label" ng-class="{ 'label-success': app.guest_login, 'label-danger': !app.guest_login }"> <span class="label" ng-class="{ 'label-success': app.guest_login, 'label-danger': !app.guest_login }">
{{ app.guest_login ? 'enabled' : 'disabled' | translate }} {{ app.guest_login ? 'enabled' : 'disabled' | translate }}
</span> </span>
</h1> </h2>
<p translate="settings.config.message_guest_access" translate-values="{ appName: appName }"> <p translate="settings.config.message_guest_access" translate-values="{ appName: appName }">
</p> </p>
<div ng-if="app"> <div ng-if="app">
@ -11,7 +11,27 @@
<button ng-if="app.guest_login" class="btn btn-danger" ng-click="changeGuestLogin(false)">{{ 'settings.config.disable_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> </div>
<h1 translate="settings.config.title_theme"></h1> <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> <form class="form-horizontal" name="editColorForm" novalidate>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label" for="inputName">{{ 'settings.config.application_name' | translate }}</label> <label class="col-sm-2 control-label" for="inputName">{{ 'settings.config.application_name' | translate }}</label>
@ -75,7 +95,7 @@
</div> </div>
</form> </form>
<h1 translate="settings.config.title_smtp"></h1> <h2 translate="settings.config.title_smtp"></h2>
<form class="form-horizontal" name="smtpForm" novalidate> <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 }"> <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> <label class="col-sm-2 control-label" for="smtpHostname">{{ 'settings.config.smtp_hostname' | translate }}</label>