-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5366 from RocketChat/subscription-audio-notification
Subscription audio notification
- Loading branch information
Showing
57 changed files
with
1,290 additions
and
74 deletions.
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
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 RocketChatTabBar */ | ||
Template.adminSounds.helpers({ | ||
isReady() { | ||
if (Template.instance().ready != null) { | ||
return Template.instance().ready.get(); | ||
} | ||
return undefined; | ||
}, | ||
customsounds() { | ||
return Template.instance().customsounds(); | ||
}, | ||
isLoading() { | ||
if (Template.instance().ready != null) { | ||
if (!Template.instance().ready.get()) { | ||
return 'btn-loading'; | ||
} | ||
} | ||
}, | ||
hasMore() { | ||
if (Template.instance().limit != null) { | ||
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 = (instance.limit != null) ? instance.limit.get() : 0; | ||
const subscription = instance.subscribe('customSounds', '', limit); | ||
instance.ready.set(subscription.ready()); | ||
}); | ||
|
||
this.customsounds = function() { | ||
const filter = (instance.filter != null) ? _.trim(instance.filter.get()) : ''; | ||
|
||
let query = {}; | ||
|
||
if (filter) { | ||
const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); | ||
query = { name: filterReg }; | ||
} | ||
|
||
const limit = (instance.limit != null) ? 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) { | ||
//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.