Skip to content

Commit

Permalink
Merge pull request #6953 from RocketChat/improvements/rc-instances-info
Browse files Browse the repository at this point in the history
[NEW] Show info about multiple instances at admin page
  • Loading branch information
rodrigok authored May 11, 2017
2 parents f8c8633 + c816950 commit f582014
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
"BotHelpers_userFields": "User Fields",
"BotHelpers_userFields_Description": "CSV of user fields that can be accessed by bots helper methods.",
"Branch": "Branch",
"Broadcast_Connected_Instances": "Broadcast Connected Instances",
"Bugsnag_api_key": "Bugsnag API Key",
"busy": "busy",
"Busy": "Busy",
Expand Down Expand Up @@ -362,6 +363,7 @@
"CROWD_Reject_Unauthorized": "Reject Unauthorized",
"CRM_Integration": "CRM Integration",
"Current_Chats": "Current Chats",
"Current_Status": "Current Status",
"Custom": "Custom",
"Custom_Emoji": "Custom Emoji",
"Custom_Emoji_Add": "Add New Emoji",
Expand Down Expand Up @@ -706,6 +708,7 @@
"Install_FxOs_follow_instructions": "Please confirm the app installation on your device (press \"Install\" when prompted).",
"Installation": "Installation",
"Installed_at": "Installed at",
"Instance_Record": "Instance Record",
"Instructions_to_your_visitor_fill_the_form_to_send_a_message": "Instructions to your visitor fill the form to send a message",
"Impersonate_user": "Impersonate User",
"Impersonate_user_description": "When enabled, integration posts as the user that triggered integration",
Expand Down Expand Up @@ -1256,6 +1259,7 @@
"Reset_password": "Reset password",
"Restart": "Restart",
"Restart_the_server": "Restart the server",
"Retry_Count": "Retry Count",
"Role": "Role",
"Role_Editing": "Role Editing",
"Role_removed": "Role removed",
Expand Down Expand Up @@ -1560,6 +1564,7 @@
"Unread_Rooms": "Unread Rooms",
"Unread_Rooms_Mode": "Unread Rooms Mode",
"Unstar_Message": "Remove Star",
"Updated_at": "Updated at",
"Upload_file_description": "File description",
"Upload_file_name": "File name",
"Upload_file_question": "Upload file?",
Expand Down Expand Up @@ -1719,4 +1724,4 @@
"your_message_optional": "your message (optional)",
"Your_password_is_wrong": "Your password is wrong!",
"Your_push_was_sent_to_s_devices": "Your push was sent to %s devices"
}
}
11 changes: 10 additions & 1 deletion packages/rocketchat-ui-admin/client/adminInfo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Template.adminInfo.helpers
return Template.instance().ready.get()
statistics: ->
return Template.instance().statistics.get()
instances: ->
return Template.instance().instances.get()
inGB: (size) ->
if size > 1073741824
return _.numberFormat(size / 1024 / 1024 / 1024, 2) + ' GB'
Expand Down Expand Up @@ -52,13 +54,20 @@ Template.adminInfo.onRendered ->
Template.adminInfo.onCreated ->
instance = @
@statistics = new ReactiveVar {}
@instances = new ReactiveVar []
@ready = new ReactiveVar false

if RocketChat.authz.hasAllPermission('view-statistics')
Meteor.call 'getStatistics', (error, statistics) ->
instance.ready.set true
if error
handleError(error)
else
instance.statistics.set statistics

Meteor.call 'instances/get', (error, instances) ->
instance.ready.set true
if error
handleError(error)
else
instance.instances.set instances

44 changes: 44 additions & 0 deletions packages/rocketchat-ui-admin/client/adminInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,50 @@ <h3>{{_ "Usage"}}</h3>
</tr>
</table>

{{#if instances}}
<h3>{{_ "Broadcast_Connected_Instances"}}</h3>
{{#each instances}}
<table class="statistics-table secondary-background-color">
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Address"}}</th>
<td class="border-component-color">{{address}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Auth"}}</th>
<td class="border-component-color">{{broadcastAuth}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Current_Status"}} > {{_ "Connected"}}</th>
<td class="border-component-color">{{currentStatus.connected}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Current_Status"}} > {{_ "Retry_Count"}}</th>
<td class="border-component-color">{{currentStatus.retryCount}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Current_Status"}} > {{_ "Status"}}</th>
<td class="border-component-color">{{currentStatus.status}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Instance_Record"}} > {{_ "ID"}}</th>
<td class="border-component-color">{{instanceRecord._id}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Instance_Record"}} > {{_ "PID"}}</th>
<td class="border-component-color">{{instanceRecord.pid}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Instance_Record"}} > {{_ "Created_at"}}</th>
<td class="border-component-color">{{formatDate instanceRecord._createdAt}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Instance_Record"}} > {{_ "Updated_at"}}</th>
<td class="border-component-color">{{formatDate instanceRecord._updatedAt}}</td>
</tr>
</table>
{{/each}}
{{/if}}

<button type="button" class="button primary refresh">Refresh</button>
{{else}}
{{_ "Loading..."}}
Expand Down
15 changes: 15 additions & 0 deletions server/stream/streamBroadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,18 @@ function startStreamBroadcast() {
Meteor.startup(function() {
return startStreamBroadcast();
});

Meteor.methods({
'instances/get'() {
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'view-statistics')) {
throw new Meteor.Error('error-action-not-allowed', 'List instances is not allowed', {
method: 'instances/get'
});
}

return Object.keys(connections).map(address => {
const conn = connections[address];
return Object.assign({ address, currentStatus: conn._stream.currentStatus }, _.pick(conn, 'instanceRecord', 'broadcastAuth'));
});
}
});

0 comments on commit f582014

Please sign in to comment.