#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.Strings;
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.PermType;
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.File;
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.FileUtil;
import com.sismics.docs.core.util.PdfUtil;
@ -831,7 +833,7 @@ public class DocumentResource extends BaseResource {
document.setSubject(StringUtils.abbreviate(mailContent.getSubject(), 500));
document.setFormat("EML");
document.setSource("Email");
document.setLanguage("eng");
document.setLanguage(ConfigUtil.getConfigStringValue(ConfigType.DEFAULT_LANGUAGE));
if (mailContent.getDate() == null) {
document.setCreateDate(new Date());
} else {

View File

@ -6,7 +6,7 @@
angular.module('docs').controller('Footer', function($scope, $rootScope, Restangular, $translate, timeAgoSettings, tmhDynamicLocale, $locale) {
// Load app data
Restangular.one('app').get().then(function(data) {
$scope.app = data;
$rootScope.app = data;
});
// 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
Restangular.one('app').get().then(function(data) {
$scope.app = data;
$rootScope.app = data;
});
// 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.
*/
$scope.resetForm = function() {
var languages = {
en: 'eng',
fr: 'fra',
zh_CN: 'chi_sim'
};
var language = languages[$translate.use()];
var language = 'eng';
if ($rootScope.app && $rootScope.app.default_language) {
language = $rootScope.app.default_language;
}
$scope.document = {
tags: [],
relations: [],
language: language ? language : 'eng'
language: language
};
$scope.newFiles = [];

View File

@ -6,7 +6,10 @@
angular.module('docs').controller('SettingsConfig', function($scope, $rootScope, Restangular) {
// Get the app configuration
Restangular.one('app').get().then(function (data) {
$scope.app = data;
$rootScope.app = data;
$scope.general = {
default_language: data.default_language
}
});
// Enable/disable guest login
@ -74,4 +77,9 @@ angular.module('docs').controller('SettingsConfig', function($scope, $rootScope,
$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

@ -247,7 +247,7 @@
"menu_configuration": "Configuration",
"menu_server_logs": "Server logs",
"user": {
"title": "Users <small>management</small>",
"title": "Users management",
"add_user": "Add a user",
"username": "Username",
"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",
"edit_user_failed_title": "User already exists",
"edit_user_failed_message": "This username is already taken by another user",
"edit_user_title": "<small>Edit</small> \"{{ username }}\"",
"add_user_title": "<small>Add a</small> user",
"edit_user_title": "Edit \"{{ username }}\"",
"add_user_title": "Add a user",
"username": "Username",
"email": "E-mail",
"groups": "Groups",
@ -273,15 +273,15 @@
}
},
"workflow": {
"title": "Workflow <small>configuration</small>",
"title": "Workflow configuration",
"add_workflow": "Add a workflow",
"name": "Name",
"create_date": "Create date",
"edit": {
"delete_workflow_title": "Delete workflow",
"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 }}\"",
"add_workflow_title": "<small>Add a</small> workflow",
"edit_workflow_title": "Edit \"{{ name }}\"",
"add_workflow_title": "Add a workflow",
"name": "Name",
"name_placeholder": "Step name or description",
"drag_help": "Drag and drop to rorder the step",
@ -296,7 +296,7 @@
"security": {
"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",
"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_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>",
@ -313,7 +313,7 @@
}
},
"group": {
"title": "Groups <small>management</small>",
"title": "Groups management",
"add_group": "Add a group",
"name": "Name",
"edit": {
@ -321,8 +321,8 @@
"delete_group_message": "Do you really want to delete this group?",
"edit_group_failed_title": "Group already exists",
"edit_group_failed_message": "This group name is already taken by another group",
"edit_group_title": "Edit <small>\"{{ name }}\"</small>",
"add_group_title": "<small>Add a</small> group",
"edit_group_title": "Edit \"{{ name }}\"",
"add_group_title": "Add a group",
"name": "Name",
"parent_group": "Parent group",
"search_group": "Search a group",
@ -332,17 +332,19 @@
}
},
"account": {
"title": "User <small>account</small>",
"title": "User account",
"password": "Password",
"password_confirm": "Password (confirm)",
"updated": "Account successfully updated"
},
"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/>",
"enable_guest_access": "Enable 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",
"main_color": "Main color",
"custom_css": "Custom CSS",
@ -350,7 +352,7 @@
"logo": "Logo (squared size)",
"background_image": "Background image",
"uploading_image": "Uploading the image...",
"title_smtp": "Email <small>configuration</small>",
"title_smtp": "Email configuration",
"smtp_hostname": "SMTP hostname",
"smtp_port": "SMTP port",
"smtp_from": "Sender e-mail",
@ -359,13 +361,13 @@
"smtp_updated": "SMTP configuration updated successfully"
},
"log": {
"title": "Server <small>logs</small>",
"title": "Server logs",
"date": "Date",
"tag": "Tag",
"message": "Message"
},
"session": {
"title": "Opened <small>sessions</small>",
"title": "Opened sessions",
"created_date": "Created date",
"last_connection_date": "Last connection date",
"user_agent": "From",
@ -375,7 +377,7 @@
"clear": "Clear all other sessions"
},
"vocabulary": {
"title": "Vocabulary <small>entries</small>",
"title": "Vocabulary entries",
"choose_vocabulary": "Choose a vocabulary to edit",
"type": "Type",
"coverage": "Coverage",

View File

@ -1,9 +1,9 @@
<h1>
<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>
</h1>
</h2>
<p translate="settings.config.message_guest_access" translate-values="{ appName: appName }">
</p>
<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>
</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>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputName">{{ 'settings.config.application_name' | translate }}</label>
@ -75,7 +95,7 @@
</div>
</form>
<h1 translate="settings.config.title_smtp"></h1>
<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>