From a144ffe59c11ffaab930d6be8d1361028c66d78d Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Thu, 10 Dec 2015 16:04:25 -0200 Subject: [PATCH] Allow avatar and alias customization --- i18n/en.i18n.json | 5 ++++ .../client/views/integrationsIncoming.coffee | 26 ++++++++++++++++--- .../client/views/integrationsIncoming.html | 17 +++++++++++- .../server/api/api.coffee | 2 ++ .../server/methods/updateIntegration.coffee | 2 ++ .../assets/stylesheets/base.less | 7 +++++ .../stylesheets/utils/_colors.import.less | 1 + .../message/message.html | 16 ++++++++++-- 8 files changed, 70 insertions(+), 6 deletions(-) diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 17e84777e6f..dff853cce2e 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -65,6 +65,7 @@ "Add_Members" : "Add Members", "Add_users" : "Add users", "Administration" : "Administration", + "Alias" : "Alias", "All_channels" : "All channels", "Allow_Invalid_SelfSigned_Certs" : "Allow Invalid Self-Signed Certs", "Allow_Invalid_SelfSigned_Certs_Description" : "Allow invalid and self-signed SSL certificate's for link validation and previews.", @@ -79,6 +80,7 @@ "Are_you_sure" : "Are you sure?", "Auto_Load_Images" : "Auto Load Images", "Avatar_changed_successfully" : "Avatar changed successfully", + "Avatar_URL" : "Avatar URL", "Avatar_url_invalid_or_error" : "The url provided is invalid or not accessible. Please try again, but with a different url.", "away" : "away", "Away" : "Away", @@ -102,6 +104,7 @@ "Channels" : "Channels", "Channels_list" : "List of public channels", "Chat_Rooms" : "Chat Rooms", + "Choose_the_alias_that_will_appear_before_the_username_in_messages" : "Choose the alias that will appear before the username in messages.", "Choose_the_username_that_this_integration_will_post_as" : "Choose the username that this integration will post as.", "Clear_all_unreads_question" : "Clear all unreads?", "close" : "close", @@ -402,6 +405,7 @@ "Send_your_JSON_payloads_to_this_URL" : "Send your JSON payloads to this URL.", "Settings" : "Settings", "Settings_updated" : "Settings updated", + "Should_be_a_URL_of_an_image" : "Should be a URL of an image.", "Should_exists_a_user_with_this_username" : "Should exists a user with this username.", "Showing_online_users" : "Showing __total_online__ of __total__ users", "Showing_results" : "

Showing %s results

", @@ -506,6 +510,7 @@ "Yes_clear_all" : "Yes, clear all!", "Yes_delete_it" : "Yes, delete it!", "you_are_in_preview_mode_of" : "You are in preview mode of channel #__room_name__", + "You_can_change_a_different_avatar_too" : "You can change a different avatar too", "You_need_confirm_email" : "You need to confirm your email to login!", "You_should_name_it_to_easily_manage_your_integrations" : "You should name it to easily manage your integrations.", "You_will_not_be_able_to_recover" : "You will not be able to recover this message!", diff --git a/packages/rocketchat-integrations/client/views/integrationsIncoming.coffee b/packages/rocketchat-integrations/client/views/integrationsIncoming.coffee index 51be06db248..28f19b530c6 100644 --- a/packages/rocketchat-integrations/client/views/integrationsIncoming.coffee +++ b/packages/rocketchat-integrations/client/views/integrationsIncoming.coffee @@ -1,3 +1,8 @@ +Template.integrationsIncoming.onCreated -> + @record = new ReactiveVar + username: 'rocket.cat' + + Template.integrationsIncoming.helpers hasPermission: -> @@ -10,14 +15,17 @@ Template.integrationsIncoming.helpers data = ChatIntegrations.findOne({_id: params.id}) if data? data.url = Meteor.absoluteUrl("hooks/#{encodeURIComponent(data._id)}/#{encodeURIComponent(data.userId)}/#{encodeURIComponent(data.token)}") + Template.instance().record.set data return data - return {} = - username: 'rocket.cat' + return Template.instance().record.curValue example: -> + record = Template.instance().record.get() return {} = _id: Random.id() + alias: record.alias + avatar: record.avatar msg: 'Example message' bot: i: Random.id() @@ -31,10 +39,18 @@ Template.integrationsIncoming.helpers ts: new Date u: _id: Random.id() - username: "rocket.cat" + username: record.username Template.integrationsIncoming.events + "blur input": (e, t) -> + t.record.set + name: $('[name=name]').val().trim() + alias: $('[name=alias]').val().trim() + avatar: $('[name=avatar]').val().trim() + channel: $('[name=channel]').val().trim() + username: $('[name=username]').val().trim() + "click .submit > .delete": -> params = Template.instance().data.params() @@ -61,6 +77,8 @@ Template.integrationsIncoming.events "click .submit > .save": -> name = $('[name=name]').val().trim() + alias = $('[name=alias]').val().trim() + avatar = $('[name=avatar]').val().trim() channel = $('[name=channel]').val().trim() username = $('[name=username]').val().trim() @@ -72,6 +90,8 @@ Template.integrationsIncoming.events integration = channel: channel + alias: alias if alias isnt '' + avatar: avatar if avatar isnt '' name: name if name isnt '' params = Template.instance().data.params?() diff --git a/packages/rocketchat-integrations/client/views/integrationsIncoming.html b/packages/rocketchat-integrations/client/views/integrationsIncoming.html index c210dcf32b9..d17db30e5c5 100644 --- a/packages/rocketchat-integrations/client/views/integrationsIncoming.html +++ b/packages/rocketchat-integrations/client/views/integrationsIncoming.html @@ -32,6 +32,21 @@
{{_ "Should_exists_a_user_with_this_username"}}
+
+ +
+ +
{{_ "Choose_the_alias_that_will_appear_before_the_username_in_messages"}}
+
+
+
+ +
+ +
{{_ "You_can_change_a_different_avatar_too"}}
+
{{_ "Should_be_a_URL_of_an_image"}}
+
+
{{#if data.token}}
@@ -42,7 +57,7 @@
{{/if}} -
+
{{#nrr nrrargs 'message' example}}{{/nrr}}
diff --git a/packages/rocketchat-integrations/server/api/api.coffee b/packages/rocketchat-integrations/server/api/api.coffee index e9aed714393..4001e3c09a7 100644 --- a/packages/rocketchat-integrations/server/api/api.coffee +++ b/packages/rocketchat-integrations/server/api/api.coffee @@ -71,6 +71,8 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true, error: 'invalid-channel-type' message = + avatar: integration.avatar + alias: integration.alias msg: @bodyParams.text or '' attachments: @bodyParams.attachments parseUrls: false diff --git a/packages/rocketchat-integrations/server/methods/updateIntegration.coffee b/packages/rocketchat-integrations/server/methods/updateIntegration.coffee index 272348dcbe0..d41d0e3d145 100644 --- a/packages/rocketchat-integrations/server/methods/updateIntegration.coffee +++ b/packages/rocketchat-integrations/server/methods/updateIntegration.coffee @@ -39,6 +39,8 @@ Meteor.methods RocketChat.models.Integrations.update integrationId, $set: name: integration.name + avatar: integration.avatar + alias: integration.alias channel: integration.channel _updatedAt: new Date _updatedBy: RocketChat.models.Users.findOne @userId, {fields: {username: 1}} diff --git a/packages/rocketchat-theme/assets/stylesheets/base.less b/packages/rocketchat-theme/assets/stylesheets/base.less index 2208b33a840..2ba3fe0465b 100644 --- a/packages/rocketchat-theme/assets/stylesheets/base.less +++ b/packages/rocketchat-theme/assets/stylesheets/base.less @@ -427,6 +427,7 @@ select, input[type='text'], input[type='number'], input[type='email'], +input[type='url'], input[type='password'] { -webkit-appearance: none; height: 35px; @@ -466,6 +467,7 @@ form.inline { input[type='text'], input[type='number'], input[type='email'], + input[type='url'], input[type='password'] { width: auto; } @@ -2700,6 +2702,11 @@ a.github-fork { &.temp .body { opacity: .5; } + .message-alias { + color: #aaa; + font-weight: 400; + padding-left: 2px; + } } .compact { diff --git a/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less b/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less index e0cb54f452a..7bdb7b45f75 100644 --- a/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less +++ b/packages/rocketchat-theme/assets/stylesheets/utils/_colors.import.less @@ -136,6 +136,7 @@ select, input[type='text'], input[type='number'], input[type='email'], +input[type='url'], input[type='password'] { border-color: #E7E7E7; background-color: #fff; diff --git a/packages/rocketchat-ui-message/message/message.html b/packages/rocketchat-ui-message/message/message.html index 5a3ced89fa2..0ae084bfc99 100644 --- a/packages/rocketchat-ui-message/message/message.html +++ b/packages/rocketchat-ui-message/message/message.html @@ -1,7 +1,19 @@