Skip to content
Snippets Groups Projects
Commit 0da099e9 authored by George Secrieru's avatar George Secrieru
Browse files

Added tabbar button for listing files uploaded to room.

parent c472555e
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,7 @@ openRoom = (type, name) ->
RocketChat.TabBar.addButton({ id: 'members-list', title: t('User_Info'), icon: 'icon-user', template: 'membersList', order: 2 })
else
RocketChat.TabBar.addButton({ id: 'members-list', title: t('Members_List'), icon: 'icon-users', template: 'membersList', order: 2 })
RocketChat.TabBar.addButton({ id: 'uploaded-files-list', title: t('Room_uploaded_file_list'), icon: 'icon-download', template: 'uploadedFilesList', order: 3 })
# update user's room subscription
if ChatSubscription.findOne({rid: room._id})?.open is false
......
Template.uploadedFilesList.helpers
files: ->
return fileCollection.find().fetch()
hasFiles: ->
return fileCollection.find().count() > 0
getFileIcon: (type) ->
if type.match(/^image\/.+$/)
return 'icon-picture'
return 'icon-docs'
Template.uploadedFilesList.onCreated ->
instance = this
this.autorun ->
instance.subscribe 'roomFiles', Session.get('openedRoom')
<template name="uploadedFilesList">
<div class="content">
<div class="list-view">
<div class="status">
<h2>{{_ "Room_uploaded_file_list"}}</h2>
</div>
{{#if hasFiles }}
<ul class='list clearfix lines'>
{{#each files}}
<li>
<i class="{{getFileIcon type}}"></i>
<a title="{{name}}" href="{{url}}" target="_blank">{{name}}</a>
</li>
{{/each}}
</ul>
{{else}}
<h2>{{_ "Room_uploaded_file_list_empty"}}</h2>
{{/if}}
</div>
</div>
</template>
\ No newline at end of file
......@@ -257,6 +257,8 @@
"Room_name_changed" : "Room name changed to: <em>__room_name__</em> by <em>__user_by__</em>",
"Room_name_changed_successfully" : "Room name changed successfully",
"Room_not_found" : "Room not found",
"Room_uploaded_file_list" : "Files list",
"Room_uploaded_file_list_empty" : "No files available.",
"room_user_count" : "%s users",
"Rooms" : "Rooms",
"Save" : "Save",
......
......@@ -251,6 +251,8 @@
"Room_name_changed" : "Nome da sala alterado para: <em>__room_name__</em> por <em>__user_by__</em>",
"Room_name_changed_successfully" : "Nome da sala alterado com sucesso",
"Room_not_found" : "Sala não encontrada",
"Room_uploaded_file_list" : "Lista de arquivos",
"Room_uploaded_file_list_empty" : "Nenhum arquivo disponível",
"room_user_count" : "%s usuários",
"Rooms" : "Salas",
"Save" : "Salvar",
......
Meteor.publish 'roomFiles', (rid) ->
unless this.userId
return this.ready()
console.log '[publish] roomFiles'.green, rid
# list of channel messages which were created after uploading a file
msgQuery =
rid: rid
'file._id': { $exists: true }
msgOptions =
fields:
_id: 1
'file._id': 1
cursorFileMessages = RocketChat.models.Messages.find(msgQuery, msgOptions);
uploadedFilesMessages = cursorFileMessages.fetch()
unless uploadedFilesMessages
return this.ready()
uploadIdList = _.map(uploadedFilesMessages, (doc) -> return doc?.file?._id)
unless uploadIdList
return this.ready()
fileQuery =
_id: { $in : uploadIdList }
complete: true
uploading: false
fileOptions =
fields:
_id: 1
name: 1
type: 1
url: 1
fileCollection.find(fileQuery, fileOptions)
this.ready()
# observe whether a new file was sent to the room and notifies subscribers
pub = this
cursorFileMessagesHandle = cursorFileMessages.observeChanges
added: (_id, record) ->
unless record?.file?._id
return pub.ready()
data = fileCollection.findOne({ _id: record.file._id }, fileOptions)
pub.added('rocketchat_uploads', record.file._id, data)
this.onStop ->
cursorFileMessagesHandle.stop()
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