-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription audio notification #5366
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
63a1901
Add audio notification choices to subscriptions
marceloschmidt 6def9c7
Add user preferences for default new message sound;
marceloschmidt 6eae556
Subscription preference first, then user preferences, then default
marceloschmidt 736e520
Custom Sounds admin sections
marceloschmidt 8219f13
Admin section for managing sounds
marceloschmidt 06fa160
Add default sounds
marceloschmidt b3094dc
Remove chime as it is default everytime
marceloschmidt a58f364
Use audio#id to play audios.
marceloschmidt 4eec964
New room sound preferences
marceloschmidt 28a96ab
Change name of settings; add migration
marceloschmidt 8c04163
Merge branch 'develop' into subscription-audio-notification
marceloschmidt 19d2461
Revert migration 77
marceloschmidt fb3ff0d
Remove unused variable
marceloschmidt 838b364
Fix less eslint
marceloschmidt 155861b
Fix sound notification playing current opened room sound
marceloschmidt 5320944
Merge branch 'develop'
marceloschmidt aba3043
Corrected migration number
marceloschmidt bb7d360
Merge branch 'develop' into subscription-audio-notification
marceloschmidt 8249b96
Merge branch 'develop' into subscription-audio-notification
marceloschmidt 2adfbf2
Fix codacy issues
marceloschmidt 880292d
Merge branch 'develop' into subscription-audio-notification
marceloschmidt 03ad5bc
Merge branch 'develop' into subscription-audio-notification
marceloschmidt dae3d5c
Fix tabbar of admin sounds
rodrigok 4d6850c
Filter admin sound input to audio/mp3 only
rodrigok 120d47e
Remove uncessary brackets
rodrigok e1c4214
Remove all uncessary `isSetNotNull`
rodrigok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,7 @@ rocketchat:[email protected] | |
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
rocketchat:[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template name="adminSoundEdit"> | ||
<div class="content"> | ||
<div class="sound-view"> | ||
{{> soundEdit .}} | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template name="adminSoundInfo"> | ||
<div class="content"> | ||
<div class="sound-view"> | ||
{{> soundInfo .}} | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template name="adminSounds"> | ||
<div class="main-content-flex"> | ||
<section class="page-container page-list flex-tab-main-content"> | ||
<header class="fixed-title"> | ||
{{> burger}} | ||
<h2> | ||
<span class="room-title">{{_ "Custom_Sounds"}}</span> | ||
</h2> | ||
</header> | ||
<div class="content"> | ||
{{#requiresPermission 'manage-sounds'}} | ||
<form class="search-form" role="form"> | ||
<div class="input-line search"> | ||
<input type="text" id="sound-filter" placeholder="{{_ "Search"}}" dir="auto"> | ||
<i class="icon-search"></i> | ||
{{#unless isReady}}<i class="icon-spin"></i>{{/unless}} | ||
</div> | ||
</form> | ||
<div class="results"> | ||
{{{_ "Showing_results" customsounds.length}}} | ||
</div> | ||
<div class="list"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th width="100%">{{_ "Name"}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each customsounds}} | ||
<tr class="sound-info row-link"> | ||
<td>{{name}} <i class="icon-play-circled"></i></td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
{{#if hasMore}} | ||
<button class="button secondary load-more {{isLoading}}">{{_ "Load_more"}}</button> | ||
{{/if}} | ||
</div> | ||
{{/requiresPermission}} | ||
</div> | ||
</section> | ||
{{#with flexData}} | ||
{{> flexTabBar}} | ||
{{/with}} | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* globals isSetNotNull, RocketChatTabBar */ | ||
Template.adminSounds.helpers({ | ||
isReady() { | ||
if (isSetNotNull(() => Template.instance().ready)) { | ||
return Template.instance().ready.get(); | ||
} | ||
return undefined; | ||
}, | ||
customsounds() { | ||
return Template.instance().customsounds(); | ||
}, | ||
isLoading() { | ||
if (isSetNotNull(() => Template.instance().ready)) { | ||
if (!Template.instance().ready.get()) { | ||
return 'btn-loading'; | ||
} | ||
} | ||
}, | ||
hasMore() { | ||
if (isSetNotNull(() => Template.instance().limit)) { | ||
if (typeof Template.instance().customsounds === 'function') { | ||
return Template.instance().limit.get() === Template.instance().customsounds().length; | ||
} | ||
} | ||
return false; | ||
}, | ||
flexData() { | ||
return { | ||
tabBar: Template.instance().tabBar, | ||
data: Template.instance().tabBarData.get() | ||
}; | ||
} | ||
}); | ||
|
||
Template.adminSounds.onCreated(function() { | ||
const instance = this; | ||
this.limit = new ReactiveVar(50); | ||
this.filter = new ReactiveVar(''); | ||
this.ready = new ReactiveVar(false); | ||
|
||
this.tabBar = new RocketChatTabBar(); | ||
this.tabBar.showGroup(FlowRouter.current().route.name); | ||
this.tabBarData = new ReactiveVar(); | ||
|
||
RocketChat.TabBar.addButton({ | ||
groups: ['custom-sounds', 'custom-sounds-selected'], | ||
id: 'add-sound', | ||
i18nTitle: 'Custom_Sound_Add', | ||
icon: 'icon-plus', | ||
template: 'adminSoundEdit', | ||
openClick(/*e, t*/) { | ||
instance.tabBarData.set(); | ||
return true; | ||
}, | ||
order: 1 | ||
}); | ||
|
||
RocketChat.TabBar.addButton({ | ||
groups: ['custom-sounds-selected'], | ||
id: 'admin-sound-info', | ||
i18nTitle: 'Custom_Sound_Info', | ||
icon: 'icon-cog', | ||
template: 'adminSoundInfo', | ||
order: 2 | ||
}); | ||
|
||
this.autorun(function() { | ||
const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0; | ||
const subscription = instance.subscribe('customSounds', '', limit); | ||
instance.ready.set(subscription.ready()); | ||
}); | ||
|
||
this.customsounds = function() { | ||
const filter = (isSetNotNull(() => instance.filter))? _.trim(instance.filter.get()) : ''; | ||
|
||
let query = {}; | ||
|
||
if (filter) { | ||
const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); | ||
query = { name: filterReg }; | ||
} | ||
|
||
const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0; | ||
|
||
return RocketChat.models.CustomSounds.find(query, { limit: limit, sort: { name: 1 }}).fetch(); | ||
}; | ||
}); | ||
|
||
Template.adminSounds.onRendered(() => | ||
Tracker.afterFlush(function() { | ||
SideNav.setFlex('adminFlex'); | ||
SideNav.openFlex(); | ||
}) | ||
); | ||
|
||
Template.adminSounds.events({ | ||
['keydown #sound-filter'](e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the selector is between brackets? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise above |
||
//stop enter key | ||
if (e.which === 13) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
} | ||
}, | ||
|
||
['keyup #sound-filter'](e, t) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
t.filter.set(e.currentTarget.value); | ||
}, | ||
|
||
['click .sound-info'](e, instance) { | ||
e.preventDefault(); | ||
instance.tabBarData.set(RocketChat.models.CustomSounds.findOne({_id: this._id})); | ||
instance.tabBar.showGroup('custom-sounds-selected'); | ||
instance.tabBar.open('admin-sound-info'); | ||
}, | ||
|
||
['click .load-more'](e, t) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
t.limit.set(t.limit.get() + 50); | ||
}, | ||
|
||
['click .icon-play-circled'](e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
const $audio = $('audio#' + this._id); | ||
if ($audio && $audio[0] && $audio[0].play) { | ||
$audio[0].play(); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FlowRouter.route('/admin/custom-sounds', { | ||
name: 'custom-sounds', | ||
subscriptions(/*params, queryParams*/) { | ||
this.register('customSounds', Meteor.subscribe('customSounds')); | ||
}, | ||
action(/*params*/) { | ||
BlazeLayout.render('main', {center: 'adminSounds'}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<template name="soundEdit"> | ||
{{#requiresPermission 'manage-sounds'}} | ||
<div class="about clearfix"> | ||
<form class="edit-form" autocomplete="off"> | ||
{{#if sound}} | ||
<h3>{{sound.name}}</h3> | ||
{{else}} | ||
<h3>{{_ "Custom_Sound_Add"}}</h3> | ||
{{/if}} | ||
<div class="input-line"> | ||
<label for="name">{{_ "Name"}}</label> | ||
<input type="text" id="name" autocomplete="off" value="{{sound.name}}"> | ||
</div> | ||
<div class="input-line"> | ||
<label for="image">{{_ "Sound_File_mp3"}}</label> | ||
<input id="image" type="file" accept="audio/mp3"/> | ||
</div> | ||
<nav> | ||
<button class='button button-block cancel' type="button"><span>{{_ "Cancel"}}</span></button> | ||
<button class='button button-block primary save'><span>{{_ "Save"}}</span></button> | ||
</nav> | ||
</form> | ||
</div> | ||
{{/requiresPermission}} | ||
</template> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for use this
isSetNotNull
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CTRL+C, CTRL+V from adminEmoji :( should I remove it?