Skip to content

Commit

Permalink
settings for livechat title and background color
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Sep 22, 2015
1 parent b3e12a3 commit 06328ec
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 6 deletions.
11 changes: 9 additions & 2 deletions packages/rocketchat-lib/settings/server/publication.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Meteor.publish 'settings', ->
Meteor.publish 'settings', (ids = []) ->
console.log '[publish] settings'.green
return Settings.find { public: true }, { fields: _id: 1, value: 1 }
filter =
public: true

if ids.length > 0
filter._id =
$in: ids

return Settings.find filter, { fields: _id: 1, value: 1 }

Meteor.publish 'admin-settings', ->
console.log '[publish] admin-settings'.green
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@ChatMessage = new Meteor.Collection null
@ChatRoom = new Meteor.Collection 'rocketchat_room'
@Settings = new Meteor.Collection 'rocketchat_settings'
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ input:focus {
top: 0;
bottom: 0;
.title {
background-color: #C1272D;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
color: #FFF;
Expand Down
10 changes: 10 additions & 0 deletions packages/rocketchat-livechat/app/client/views/room.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ Template.room.helpers
messages: ->
return ChatMessage.find { rid: visitor.getRoom(), t: { '$ne': 't' } }, { sort: { ts: 1 } }

title: ->
return '' unless Template.instance().subscriptionsReady()
return Settings.findOne('Livechat_title')?.value or 'Rocket.Chat'

color: ->
return 'transparent' unless Template.instance().subscriptionsReady()
return Settings.findOne('Livechat_title_color')?.value or '#C1272D'

Template.room.events
'keyup .input-message': (event) ->
Template.instance().chatMessages.keyup(visitor.getRoom(), event, Template.instance())
Expand All @@ -28,6 +36,8 @@ Template.room.onCreated ->
visitor.setRoom room._id
RoomHistoryManager.getMoreIfIsEmpty room._id

self.subscribe 'settings', ['Livechat_title', 'Livechat_title_color']

self.atBottom = true

Template.room.onRendered ->
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-livechat/app/client/views/room.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template name="room">
<div class="livechat-room">
<div class="title">
<h1>Rocket.Chat</h1>
<div class="title" style="background-color:{{color}}">
<h1>{{title}}</h1>
</div>
<div class="messages">
<div class="wrapper">
Expand Down
5 changes: 5 additions & 0 deletions packages/rocketchat-livechat/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Meteor.startup(function() {
RocketChat.settings.addGroup('Livechat');
RocketChat.settings.add('Livechat_title' , 'Rocket.Chat', { type: 'string', group: 'Livechat', i18nLabel: 'rocketchat-livechat:Livechat_title', public: true });
RocketChat.settings.add('Livechat_title_color' , '#C1272D', { type: 'string', group: 'Livechat', i18nLabel: 'rocketchat-livechat:Livechat_title_color', public: true });
});
4 changes: 4 additions & 0 deletions packages/rocketchat-livechat/i18n/en.i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Livechat_title": "Livechat title",
"Livechat_title_color": "Livechat title background color"
}
4 changes: 4 additions & 0 deletions packages/rocketchat-livechat/i18n/pt.i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Livechat_title": "Título Livechat",
"Livechat_title_color": "Cor de fundo do título do Livechat"
}
Empty file.
17 changes: 17 additions & 0 deletions packages/rocketchat-livechat/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,34 @@ Package.registerBuildPlugin({
}
});

// Loads all i18n.json files into tapi18nFiles
var _ = Npm.require('underscore');
var fs = Npm.require('fs');
tapi18nFiles = _.compact(_.map(fs.readdirSync('packages/rocketchat-livechat/i18n'), function(filename) {
if (fs.statSync('packages/rocketchat-livechat/i18n/' + filename).size > 16) {
return 'i18n/' + filename;
}
}));

Package.onUse(function(api) {
api.versionsFrom('1.0');

api.use(['coffeescript', 'webapp', 'autoupdate'], 'server');
api.use('templating', 'client');
api.use(["tap:[email protected]"], ["client", "server"]);
api.imply('tap:i18n');
api.addFiles("package-tap.i18n", ["client", "server"]);

api.addFiles('livechat.coffee', 'server');
api.addFiles('methods.coffee', 'server');
api.addFiles('publications.coffee', 'server');

api.addFiles('config.js', 'server');

api.addFiles('rocket-livechat.js', 'client', {isAsset: true});
api.addFiles('public/livechat.css', 'client', {isAsset: true});
api.addFiles('public/livechat.js', 'client', {isAsset: true});
api.addFiles('public/head.html', 'server', {isAsset: true});

api.addFiles(tapi18nFiles, ["client", "server"]);
});
1 change: 0 additions & 1 deletion packages/rocketchat-livechat/rocket-livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
chatWidget.style.position = 'fixed';
chatWidget.style.width = '300px';
chatWidget.style.height = '30px';
chatWidget.style.backgroundColor = '#C1272D';
chatWidget.style.borderTopLeftRadius = '5px';
chatWidget.style.borderTopRightRadius = '5px';
chatWidget.style.bottom = '0';
Expand Down

0 comments on commit 06328ec

Please sign in to comment.