Skip to content
Snippets Groups Projects
Commit 3df722b7 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Add sections in settings and improve avatar settings

parent e79d1c78
No related branches found
No related tags found
No related merge requests found
...@@ -449,6 +449,7 @@ input:focus { ...@@ -449,6 +449,7 @@ input:focus {
textarea, textarea,
select, select,
input[type='text'], input[type='text'],
input[type='number'],
input[type='email'], input[type='email'],
input[type='password'] { input[type='password'] {
-webkit-appearance: none; -webkit-appearance: none;
...@@ -1898,6 +1899,14 @@ a.github-fork { ...@@ -1898,6 +1899,14 @@ a.github-fork {
} }
} }
.page-settings {
.rocket-form {
max-width: none;
width: 100%;
padding: 0;
}
}
.page-static { .page-static {
.content { .content {
> div { > div {
...@@ -1912,6 +1921,19 @@ a.github-fork { ...@@ -1912,6 +1921,19 @@ a.github-fork {
margin-bottom: 0; margin-bottom: 0;
} }
} }
.section {
h1 {
font-size: 20px;
margin-top: 40px;
padding: 0 0 0 10px;
font-weight: 500;
}
.section-content {
border: 1px solid #ddd;
padding: 20px;
border-radius: 5px;
}
}
h1, h1,
h2, h2,
h3, h3,
......
...@@ -5,10 +5,23 @@ Template.admin.helpers ...@@ -5,10 +5,23 @@ Template.admin.helpers
group = FlowRouter.getParam('group') group = FlowRouter.getParam('group')
group ?= Settings.findOne({ type: 'group' })?._id group ?= Settings.findOne({ type: 'group' })?._id
return Settings.findOne { _id: group, type: 'group' } return Settings.findOne { _id: group, type: 'group' }
settings: -> sections: ->
group = FlowRouter.getParam('group') group = FlowRouter.getParam('group')
group ?= Settings.findOne({ type: 'group' })?._id group ?= Settings.findOne({ type: 'group' })?._id
return Settings.find({ group: group }).fetch() settings = Settings.find({ group: group }, {sort: {section: 1}}).fetch()
sections = {}
for setting in settings
sections[setting.section or ''] ?= []
sections[setting.section or ''].push setting
sectionsArray = []
for key, value of sections
sectionsArray.push
section: key
settings: value
return sectionsArray
flexOpened: -> flexOpened: ->
return 'opened' if Session.equals('flexOpened', true) return 'opened' if Session.equals('flexOpened', true)
arrowPosition: -> arrowPosition: ->
......
<template name="admin"> <template name="admin">
<section class="page-container page-home page-static"> <section class="page-container page-home page-static page-settings">
<head class="fixed-title"> <head class="fixed-title">
{{> burger}} {{> burger}}
<h2> <h2>
...@@ -10,39 +10,61 @@ ...@@ -10,39 +10,61 @@
{{#unless isAdmin}} {{#unless isAdmin}}
<p>You are not authorized to view this page.</p> <p>You are not authorized to view this page.</p>
{{else}} {{else}}
<div class="info"> {{#with group}}
<h3>{{#with group}}{{description}}{{/with}}</h3> <div class="info">
</div> <h3>{{description}}</h3>
</div>
{{/with}}
<div class="rocket-form"> <div class="rocket-form">
<fieldset> <fieldset>
{{#each settings}} {{#each sections}}
{{#if $eq type 'string'}} <div class="section">
<div class="input-line double-col"> {{#if section}}
<label>{{label}}</label> <h1>{{section}}</h1>
<div> {{/if}}
{{#if multiline}} <div class="section-content">
<textarea name="{{_id}}" rows="4" style="height: auto">{{value}}</textarea> {{#each settings}}
{{else}} {{#if $eq type 'string'}}
<input type="text" name="{{_id}}" value="{{value}}" /> <div class="input-line double-col">
<label>{{label}}</label>
<div>
{{#if multiline}}
<textarea name="{{_id}}" rows="4" style="height: auto">{{value}}</textarea>
{{else}}
<input type="text" name="{{_id}}" value="{{value}}" />
{{/if}}
{{#if description}}
<small>{{description}}</small>
{{/if}}
</div>
</div>
{{/if}} {{/if}}
{{#if description}} {{#if $eq type 'int'}}
<small>{{description}}</small> <div class="input-line double-col">
<label>{{label}}</label>
<div>
<input type="number" name="{{_id}}" value="{{value}}" />
{{#if description}}
<small>{{description}}</small>
{{/if}}
</div>
</div>
{{/if}} {{/if}}
</div> {{#if $eq type 'boolean'}}
</div> <div class="input-line double-col">
{{/if}} <label>{{label}}</label>
{{#if $eq type 'boolean'}} <div>
<div class="input-line double-col"> <label><input type="radio" name="{{_id}}" value="1" checked="{{$eq value true}}" /> {{_ "True"}}</label>
<label>{{label}}</label> <label><input type="radio" name="{{_id}}" value="0" checked="{{$eq value false}}" /> {{_ "False"}}</label>
<div> </div>
<label><input type="radio" name="{{_id}}" value="1" checked="{{$eq value true}}" /> {{_ "True"}}</label> {{#if description}}
<label><input type="radio" name="{{_id}}" value="0" checked="{{$eq value false}}" /> {{_ "False"}}</label> <small>{{description}}</small>
</div> {{/if}}
{{#if description}} </div>
<small>{{description}}</small> {{/if}}
{{/if}} {{/each}}
</div> </div>
{{/if}} </div>
{{/each}} {{/each}}
</fieldset> </fieldset>
<div class="submit"> <div class="submit">
......
...@@ -21,6 +21,7 @@ RocketChat.settings.add = (_id, value, options = {}) -> ...@@ -21,6 +21,7 @@ RocketChat.settings.add = (_id, value, options = {}) ->
updateSettings.type = options.type if options.type updateSettings.type = options.type if options.type
updateSettings.multiline = options.multiline if options.multiline updateSettings.multiline = options.multiline if options.multiline
updateSettings.group = options.group if options.group updateSettings.group = options.group if options.group
updateSettings.section = options.section if options.section
updateSettings.public = options.public if options.public updateSettings.public = options.public if options.public
return Settings.upsert { _id: _id }, { $setOnInsert: { value: value }, $set: updateSettings } return Settings.upsert { _id: _id }, { $setOnInsert: { value: value }, $set: updateSettings }
......
Meteor.startup -> Meteor.startup ->
RocketChat.settings.addGroup 'Accounts' RocketChat.settings.addGroup 'Accounts'
RocketChat.settings.add 'Accounts_RegistrationRequired', true, { type: 'boolean', group: 'Accounts', public: true } RocketChat.settings.add 'Accounts_RegistrationRequired', true, { type: 'boolean', group: 'Accounts', public: true, section: 'Registration' }
RocketChat.settings.add 'Accounts_EmailVerification', false, { type: 'boolean', group: 'Accounts', public: true } RocketChat.settings.add 'Accounts_EmailVerification', false, { type: 'boolean', group: 'Accounts', public: true, section: 'Registration' }
RocketChat.settings.add 'Accounts_ManuallyApproveNewUsers', false, { type: 'boolean', group: 'Accounts', section: 'Registration' }
RocketChat.settings.add 'Accounts_Facebook', false, { type: 'boolean', group: 'Accounts' } RocketChat.settings.add 'Accounts_AvatarStoreType', 'GridFS', { type: 'string', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_Facebook_id', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_AvatarStorePath', '/var/www/rocket.chat/uploads/avatar/', { type: 'string', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_Facebook_secret', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_AvatarResize', false, { type: 'boolean', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_Google', false, { type: 'boolean', group: 'Accounts' } RocketChat.settings.add 'Accounts_AvatarSize', 200, { type: 'int', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_Google_id', '', { type: 'string', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Google_secret', '', { type: 'string', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Github', false, { type: 'boolean', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Github_id', '', { type: 'string', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Github_secret', '', { type: 'string', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Gitlab', false, { type: 'boolean', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Gitlab_id', '', { type: 'string', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Gitlab_secret', '', { type: 'string', group: 'Accounts' }
RocketChat.settings.add 'Accounts_Linkedin', false, { type: 'boolean', group: 'Accounts' } RocketChat.settings.add 'Accounts_Facebook', false, { type: 'boolean', group: 'Accounts', section: 'Facebook' }
RocketChat.settings.add 'Accounts_Linkedin_id', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_Facebook_id', '', { type: 'string', group: 'Accounts', section: 'Facebook' }
RocketChat.settings.add 'Accounts_Linkedin_secret', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_Facebook_secret', '', { type: 'string', group: 'Accounts', section: 'Facebook' }
RocketChat.settings.add 'Accounts_Meteor', false, { type: 'boolean', group: 'Accounts' } RocketChat.settings.add 'Accounts_Google', false, { type: 'boolean', group: 'Accounts', section: 'Google' }
RocketChat.settings.add 'Accounts_Meteor_id', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_Google_id', '', { type: 'string', group: 'Accounts', section: 'Google' }
RocketChat.settings.add 'Accounts_Meteor_secret', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_Google_secret', '', { type: 'string', group: 'Accounts', section: 'Google' }
RocketChat.settings.add 'Accounts_Twitter', false, { type: 'boolean', group: 'Accounts' } RocketChat.settings.add 'Accounts_Github', false, { type: 'boolean', group: 'Accounts', section: 'Github' }
RocketChat.settings.add 'Accounts_Twitter_id', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_Github_id', '', { type: 'string', group: 'Accounts', section: 'Github' }
RocketChat.settings.add 'Accounts_Twitter_secret', '', { type: 'string', group: 'Accounts' } RocketChat.settings.add 'Accounts_Github_secret', '', { type: 'string', group: 'Accounts', section: 'Github' }
RocketChat.settings.add 'Accounts_ManuallyApproveNewUsers', false, { type: 'boolean', group: 'Accounts' } RocketChat.settings.add 'Accounts_Gitlab', false, { type: 'boolean', group: 'Accounts', section: 'Gitlab' }
RocketChat.settings.add 'Accounts_Gitlab_id', '', { type: 'string', group: 'Accounts', section: 'Gitlab' }
RocketChat.settings.add 'Accounts_Gitlab_secret', '', { type: 'string', group: 'Accounts', section: 'Gitlab' }
RocketChat.settings.add 'Accounts_Linkedin', false, { type: 'boolean', group: 'Accounts', section: 'Linkedin' }
RocketChat.settings.add 'Accounts_Linkedin_id', '', { type: 'string', group: 'Accounts', section: 'Linkedin' }
RocketChat.settings.add 'Accounts_Linkedin_secret', '', { type: 'string', group: 'Accounts', section: 'Linkedin' }
RocketChat.settings.add 'Accounts_Meteor', false, { type: 'boolean', group: 'Accounts', section: 'Meteor' }
RocketChat.settings.add 'Accounts_Meteor_id', '', { type: 'string', group: 'Accounts', section: 'Meteor' }
RocketChat.settings.add 'Accounts_Meteor_secret', '', { type: 'string', group: 'Accounts', section: 'Meteor' }
RocketChat.settings.add 'Accounts_Twitter', false, { type: 'boolean', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.add 'Accounts_Twitter_id', '', { type: 'string', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.add 'Accounts_Twitter_secret', '', { type: 'string', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.addGroup 'General' RocketChat.settings.addGroup 'General'
RocketChat.settings.add 'Site_Name', 'Rocket.Chat', { type: 'string', group: 'General', public: true } RocketChat.settings.add 'Site_Name', 'Rocket.Chat', { type: 'string', group: 'General', public: true }
......
Meteor.startup -> Meteor.startup ->
storeType = 'GridFS' storeType = 'GridFS'
if RocketChat.settings.get 'avatarStore_type' if RocketChat.settings.get 'Accounts_AvatarStoreType'
storeType = RocketChat.settings.get 'avatarStore_type' storeType = RocketChat.settings.get 'Accounts_AvatarStoreType'
RocketChatStore = RocketChatFile[storeType] RocketChatStore = RocketChatFile[storeType]
...@@ -12,16 +12,16 @@ Meteor.startup -> ...@@ -12,16 +12,16 @@ Meteor.startup ->
console.log "Using #{storeType} for Avatar storage".green console.log "Using #{storeType} for Avatar storage".green
transformWrite = undefined transformWrite = undefined
if RocketChat.settings.get 'avatarStore_size_height' if RocketChat.settings.get('Accounts_AvatarResize') is true
height = RocketChat.settings.get 'avatarStore_size_height' height = RocketChat.settings.get 'Accounts_AvatarSize'
width = RocketChat.settings.get 'avatarStore_size_width' width = height
transformWrite = (file, readStream, writeStream) -> transformWrite = (file, readStream, writeStream) ->
RocketChatFile.gm(readStream, file.fileName).background('#ffffff').resize(width, height+'^>').gravity('Center').extent(width, height).stream('jpeg').pipe(writeStream) RocketChatFile.gm(readStream, file.fileName).background('#ffffff').resize(width, height+'^>').gravity('Center').extent(width, height).stream('jpeg').pipe(writeStream)
path = "~/uploads" path = "~/uploads"
if RocketChat.settings.get 'avatarStore_path' if RocketChat.settings.get('Accounts_AvatarStorePath')?.trim() isnt ''
path = RocketChat.settings.get 'avatarStore_path' path = RocketChat.settings.get 'Accounts_AvatarStorePath'
@RocketChatFileAvatarInstance = new RocketChatStore @RocketChatFileAvatarInstance = new RocketChatStore
name: 'avatars' name: 'avatars'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment