Change admin statistics for admin info.

pull/2081/head
Marcelo Schmidt 9 years ago
parent 6f27eb10ff
commit 3eb4ed97de
  1. 8
      client/routes/adminRouter.coffee
  2. 36
      i18n/en.i18n.json
  3. 4
      packages/rocketchat-lib/server/startup/settings.coffee
  4. 1
      packages/rocketchat-mailer/i18n/en.i18n.json
  5. 8
      packages/rocketchat-statistics/server/methods/getStatistics.coffee
  6. 5
      packages/rocketchat-statistics/server/models/Statistics.coffee
  7. 7
      packages/rocketchat-theme/assets/stylesheets/base.less
  8. 2
      packages/rocketchat-ui-admin/admin/admin.html
  9. 9
      packages/rocketchat-ui-admin/admin/adminFlex.html
  10. 32
      packages/rocketchat-ui-admin/admin/adminInfo.coffee
  11. 158
      packages/rocketchat-ui-admin/admin/adminInfo.html
  12. 2
      packages/rocketchat-ui-admin/admin/rooms/adminRoomInfo.html
  13. 2
      packages/rocketchat-ui-admin/admin/rooms/adminRooms.html
  14. 2
      packages/rocketchat-ui-admin/admin/users/adminUserChannels.html
  15. 2
      packages/rocketchat-ui-admin/admin/users/adminUserEdit.html
  16. 2
      packages/rocketchat-ui-admin/admin/users/adminUsers.html
  17. 4
      packages/rocketchat-ui-admin/package.js
  18. 1
      packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee

@ -16,11 +16,11 @@ FlowRouter.route '/admin/rooms',
RocketChat.TabBar.showGroup 'adminrooms'
BlazeLayout.render 'main', {center: 'adminRooms'}
FlowRouter.route '/admin/statistics',
name: 'admin-statistics'
FlowRouter.route '/admin/info',
name: 'admin-info'
action: ->
RocketChat.TabBar.showGroup 'adminstatistics'
BlazeLayout.render 'main', {center: 'adminStatistics'}
RocketChat.TabBar.showGroup 'adminInfo'
BlazeLayout.render 'main', {center: 'adminInfo'}
FlowRouter.route '/admin/:group?',
name: 'admin'

@ -89,6 +89,7 @@
"are_also_typing" : "are also typing",
"are_typing" : "are typing",
"Are_you_sure" : "Are you sure?",
"Author" : "Author",
"Authorization_URL" : "Authorization URL",
"Authorize" : "Authorize",
"Auto_Load_Images" : "Auto Load Images",
@ -105,6 +106,8 @@
"Back_to_integrations" : "Back to integrations",
"Back_to_login" : "Back to login",
"bold" : "bold",
"Branch" : "Branch",
"Build_Environment" : "Build Environment",
"busy" : "busy",
"Busy" : "Busy",
"busy_female" : "busy",
@ -126,6 +129,7 @@
"close" : "close",
"coming_soon" : "coming soon",
"Commands" : "Commands",
"Commit" : "Commit",
"Compact_View" : "Compact View",
"Confirm_password" : "Confirm your password",
"Contact" : "Contact",
@ -140,7 +144,9 @@
"Created_at_s_by_s" : "Created at <strong>%s</strong> by <strong>%s</strong>",
"Custom_oauth_helper" : "When setting up your OAuth Provider, you'll have to inform a Callback URL. Use <pre>%s</pre> .",
"Custom_oauth_unique_name" : "Custom oauth unique name",
"Date" : "Date",
"days" : "days",
"DB_Schema_Version" : "DB Schema Version",
"Deactivate" : "Deactivate",
"Delete_Room_Warning" : "Deleting a room will delete all messages posted within the room. This cannot be undone.",
"Delete_User_Warning" : "Deleting a user will delete all messages from that user as well. This cannot be undone.",
@ -194,12 +200,14 @@
"github_no_public_email" : "You don't have any email as public email in your GitHub account",
"Give_a_unique_name_for_the_custom_oauth" : "Give a unique name for the custom oauth",
"Give_the_application_a_name_This_will_be_seen_by_your_users" : "Give the application a name. This will be seen by your users.",
"Hash" : "Hash",
"Has_more" : "Has more",
"Have_your_own_chat" : "Have your own web chat. Developed with Meteor.com, the Rocket.Chat is a great solution for developers looking forward to build and evolve their own chat platform.",
"Hide_room" : "Hide room",
"History" : "History",
"hours" : "hours",
"Incorrect_Password" : "Incorrect Password",
"Info" : "Info",
"inline_code" : "inline_code",
"Install_Extension" : "Install Extension",
"Install_FxOs" : "Install Rocket.Chat on your Firefox",
@ -349,6 +357,7 @@
"No_results_found" : "No results found",
"no_tokens_for_this_user" : "There are no tokens for this user",
"No_user_with_username_%s_was_found" : "No user with username <strong>\"%s\"</strong> was found!",
"Node_version" : "Node version",
"Not_allowed" : "Not allowed",
"Not_authorized" : "Not authorized",
"Not_found_or_not_allowed" : "Not Found or Not Allowed",
@ -424,6 +433,7 @@
"Reset_password" : "Reset password",
"Restart" : "Restart",
"Restart_the_server" : "Restart the server",
"Rocket.Chat" : "Rocket.Chat",
"Room" : "Room",
"Room_archived" : "Room archived",
"Room_has_been_deleted" : "Room has been deleted",
@ -435,6 +445,7 @@
"Room_uploaded_file_list_empty" : "No files available.",
"room_user_count" : "%s users",
"Rooms" : "Rooms",
"Runtime_Environment" : "Runtime Environment",
"S_new_messages_since_s" : "%s new messages since %s",
"SAML" : "SAML",
"SAML_Custom_Cert" : "Custom Certificate",
@ -501,15 +512,15 @@
"Stats_Non_Active_Users" : "Inactive Users",
"Stats_Offline_Users" : "Offline Users",
"Stats_Online_Users" : "Online Users",
"Stats_OS_Arch" : "OS Arch",
"Stats_OS_Cpus" : "OS CPU Count",
"Stats_OS_Freemem" : "OS Free Memory",
"Stats_OS_Loadavg" : "OS Load Average",
"Stats_OS_Platform" : "OS Platform",
"Stats_OS_Release" : "OS Release",
"Stats_OS_Totalmem" : "OS Total Memory",
"Stats_OS_Type" : "OS Type",
"Stats_OS_Uptime" : "OS Uptime",
"Arch" : "Arch",
"Cpus" : "CPU Count",
"Freemem" : "Free Memory",
"Loadavg" : "Load Average",
"Platform" : "Platform",
"Release" : "Release",
"Totalmem" : "Total Memory",
"Type" : "Type",
"Uptime" : "Uptime",
"Stats_Total_Channels" : "Total Channels",
"Stats_Total_Direct_Messages" : "Total Direct Message Rooms",
"Stats_Total_Messages" : "Total Messages",
@ -518,9 +529,11 @@
"Stats_Total_Users" : "Total Users",
"Stop_Recording" : "Stop Recording",
"strike" : "strike",
"Subject" : "Subject",
"Submit" : "Submit",
"Success" : "Success",
"The_application_name_is_required" : "Th _application name is required",
"Tag" : "Tag",
"The_application_name_is_required" : "The _application name is required",
"The_channel_name_is_required" : "The channel name is required",
"The_field_is_required" : "The field %s is required.",
"The_image_resize_will_not_work_because_we_can_not_detect_ImageMagick_or_GraphicsMagick_installed_in_your_server" : "The image resize will not work because we can not detect ImageMagick or GraphicsMagick installed on your server.",
@ -540,6 +553,7 @@
"Unread_Rooms_Mode" : "Unread Rooms Mode",
"Upload_file_question" : "Upload file?",
"Uploading_file" : "Uploading file...",
"Usage" : "Usage",
"Use_Emojis" : "Use Emojis",
"Use_initials_avatar" : "Use your username initials",
"use_menu" : "Use the side menu to access your rooms and chats",
@ -595,6 +609,7 @@
"UTF8_Names_Slugify" : "UTF8 Names Slugify",
"UTF8_Names_Validation" : "UTF8 Names Validation",
"UTF8_Names_Validation_Description" : "Do not allow special characters and spaces. You can use - _ and . but not at the end of the name",
"Version" : "Version",
"View_All" : "View All",
"Wait_activation_warning" : "Before you can login, your account must be manually activated by an administrator.",
"We_have_sent_password_email" : "We have sent you an e-mail with password reset instructions. If you do not receive an e-mail shortly, please come back and try again.",
@ -610,6 +625,7 @@
"Yes_remove_user" : "Yes, remove user!",
"you_are_in_preview_mode_of" : "You are in preview mode of channel #<strong>__room_name__</strong>",
"You_are_logged_in_as" : "You are logged in as",
"You_are_not_authorized_to_view_this_page" : "You are not authorized to view this page.",
"You_can_change_a_different_avatar_too" : "You can override the avatar used to post from this integration.",
"You_can_use_an_emoji_as_avatar" : "You can also use an emoji as an avatar.",
"You_have_been_muted" : "You have been muted and cannot speak in this room",

@ -86,6 +86,8 @@ RocketChat.settings.addGroup 'General', ->
@add 'UTF8_Names_Validation', '[0-9a-zA-Z-_.]+', { type: 'string', public: true, i18nDescription: 'UTF8_Names_Validation_Description'}
@add 'UTF8_Names_Slugify', true, { type: 'boolean', public: true }
@section 'Reporting', ->
@add 'Statistics_opt_out', false, { type: 'boolean', i18nLabel: "Opt_out_statistics" }
RocketChat.settings.addGroup 'API', ->
@add 'API_Analytics', '', { type: 'string', public: true }
@ -162,8 +164,6 @@ RocketChat.settings.addGroup 'Layout', ->
@add 'Layout_Login_Terms', 'By proceeding to create your account and use Rocket.Chat, you are agreeing to our <a href="/terms-of-service">Terms of Service</a> and <a href="/privacy-policy">Privacy Policy</a>. If you do not agree, you cannot use Rocket.Chat.', { type: 'string', multiline: true, public: true }
RocketChat.settings.add 'Statistics_opt_out', false, { type: 'boolean', group: false }
RocketChat.settings.init()
# Remove runtime settings (non-persistent)

@ -12,7 +12,6 @@
"Query_description" : "Additional conditions for determining which users to send the e-mail to. Unsubscribed users are automatically removed from the query. It must be a valid JSON. Example: \"{\"createdAt\":{\"$gt\":{\"$date\": \"2015-01-01T00:00:00.000Z\"}}}\"",
"Send_email" : "Send E-mail",
"The_emails_are_being_sent" : "The e-mails are being sent.",
"You_are_not_authorized_to_view_this_page" : "You are not authorized to view this page.",
"You_have_successfully_unsubscribed" : "You have successfully unsubscribed from our Mailling List.",
"You_informed_an_invalid_FROM_address" : "You informed an invalid FROM address.",
"You_must_provide_the_unsubscribe_link" : "You must provide the [unsubscribe] link."

@ -1,9 +1,13 @@
Meteor.methods
getStatistics: ->
getStatistics: (refresh) ->
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] getStatistics -> Invalid user")
unless RocketChat.authz.hasPermission(Meteor.userId(), 'view-statistics') is true
throw new Meteor.Error 'not-authorized', '[methods] getStatistics -> Not authorized'
return RocketChat.statistics.get()
if refresh
return RocketChat.statistics.save()
else
return RocketChat.models.Statistics.findLast()

@ -9,3 +9,8 @@ RocketChat.models.Statistics = new class extends RocketChat.models._Base
_id: _id
return @findOne query, options
findLast: ->
query = {}
options = sort: createdAt: -1
return @find(query, options).fetch()?[0]

@ -3918,6 +3918,7 @@ a.github-fork {
}
.statistics-table {
margin-bottom: 30px;
border: 1px solid;
width:100%;
tr {
@ -3931,6 +3932,12 @@ a.github-fork {
text-align: left;
padding: 3px 10px;
}
th {
width: 20%;
}
td {
width: 80%;
}
}
.rocket-team {

@ -9,7 +9,7 @@
<div class="content">
{{#unless hasPermission 'view-privileged-setting'}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
{{#with group}}
{{#if description}}

@ -7,12 +7,9 @@
<div class="content">
<div class="wrapper">
<ul>
{{#if hasPermission 'view-statistics'}}
<li>
<a href="{{pathFor 'admin-statistics'}}" class="admin-link">{{_ "Statistics"}}</a>
</li>
{{/if}}
<li>
<a href="{{pathFor 'admin-info'}}" class="admin-link">{{_ "Info"}}</a>
</li>
{{#if hasPermission 'view-room-administration'}}
<li>
<a href="{{pathFor 'admin-rooms'}}" class="admin-link">{{_ "Rooms"}}</a>

@ -1,4 +1,4 @@
Template.adminStatistics.helpers
Template.adminInfo.helpers
isReady: ->
return Template.instance().ready.get()
statistics: ->
@ -7,7 +7,7 @@ Template.adminStatistics.helpers
if size > 1073741824
return _.numberFormat(size / 1024 / 1024 / 1024, 2) + ' GB'
return _.numberFormat(size / 1024 / 1024, 2) + ' MB'
humanReadable: (time) ->
humanReadableTime: (time) ->
days = Math.floor time / 86400
hours = Math.floor (time % 86400) / 3600
minutes = Math.floor ((time % 86400) % 3600) / 60
@ -22,12 +22,23 @@ Template.adminStatistics.helpers
if seconds > 0
out += "#{seconds} #{TAPi18n.__ 'seconds'}"
return out
formatDate: (date) ->
if date
return moment(date).format("LLL")
numFormat: (number) ->
return _.numberFormat(number, 2)
optOut: ->
return RocketChat.settings.get 'Statistics_opt_out'
server: ->
return RocketChat.Info
commit: ->
return _.extend(RocketChat.Info?.commit, { tag: RocketChat.Info?.tag, branch: RocketChat.Info?.branch })
migration: ->
return Template.instance().migration.get()
build: ->
return RocketChat.Info?.compile || RocketChat.Info?.build
Template.adminStatistics.events
Template.adminInfo.events
'click input[name=opt-out-statistics]': (e) ->
if $(e.currentTarget).prop('checked')
$('#opt-out-warning').show()
@ -38,7 +49,16 @@ Template.adminStatistics.events
RocketChat.settings.set 'Statistics_opt_out', false, ->
toastr.success TAPi18n.__ 'Settings_updated'
Template.adminStatistics.onRendered ->
'click .refresh': (e, instance) ->
instance.ready.set false
Meteor.call 'getStatistics', true, (error, statistics) ->
instance.ready.set true
if error
toastr.error error.reason
else
instance.statistics.set statistics
Template.adminInfo.onRendered ->
Tracker.afterFlush ->
SideNav.setFlex "adminFlex"
SideNav.openFlex()
@ -48,9 +68,10 @@ Template.adminStatistics.onRendered ->
else
$('#opt-out-warning').hide()
Template.adminStatistics.onCreated ->
Template.adminInfo.onCreated ->
instance = @
@statistics = new ReactiveVar {}
@migration = new ReactiveVar {}
@ready = new ReactiveVar false
Meteor.call 'getStatistics', (error, statistics) ->
@ -59,3 +80,4 @@ Template.adminStatistics.onCreated ->
toastr.error error.reason
else
instance.statistics.set statistics

@ -1,16 +1,122 @@
<template name="adminStatistics">
<template name="adminInfo">
<section class="page-container page-list">
<head class="fixed-title">
{{> burger}}
<h2>
<span class="room-title">{{_ "Statistics"}}</span>
<span class="room-title">{{_ "Info"}}</span>
</h2>
</head>
<div class="content">
<h3>{{_ "Rocket.Chat"}}</h3>
<table class="statistics-table">
<tr>
<th>{{_ "Version"}}</th>
<td>{{server.version}}</td>
</tr>
<tr>
<th>{{_ "DB_Schema_Version"}}</th>
<td>{{migration.version}}</td>
</tr>
</table>
<h3>{{_ "Commit"}}</h3>
<table class="statistics-table">
<tr>
<th>{{_ "Hash"}}</th>
<td>{{commit.hash}}</td>
</tr>
<tr>
<th>{{_ "Date"}}</th>
<td>{{commit.date}}</td>
</tr>
<tr>
<th>{{_ "Branch"}}</th>
<td>{{commit.branch}}</td>
</tr>
<tr>
<th>{{_ "Tag"}}</th>
<td>{{commit.tag}}</td>
</tr>
<tr>
<th>{{_ "Author"}}</th>
<td>{{commit.author}}</td>
</tr>
<tr>
<th>{{_ "Subject"}}</th>
<td>{{commit.subject}}</td>
</tr>
</table>
{{#unless hasPermission 'view-statistics'}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
{{#if isReady}}
<h3>{{_ "Runtime_Environment"}}</h3>
<table class="statistics-table">
<tr>
<th>{{_ "Type"}}</th>
<td>{{statistics.os.type}}</td>
</tr>
<tr>
<th>{{_ "Platform"}}</th>
<td>{{statistics.os.platform}}</td>
</tr>
<tr>
<th>{{_ "Arch"}}</th>
<td>{{statistics.os.arch}}</td>
</tr>
<tr>
<th>{{_ "Release"}}</th>
<td>{{statistics.os.release}}</td>
</tr>
<tr>
<th>{{_ "Uptime"}}</th>
<td>{{humanReadableTime statistics.os.uptime}}</td>
</tr>
<tr>
<th>{{_ "Loadavg"}}</th>
<td>{{numFormat statistics.os.loadavg.[0]}}, {{numFormat statistics.os.loadavg.[1]}}, {{numFormat statistics.os.loadavg.[2]}}</td>
</tr>
<tr>
<th>{{_ "Totalmem"}}</th>
<td>{{inGB statistics.os.totalmem}}</td>
</tr>
<tr>
<th>{{_ "Freemem"}}</th>
<td>{{inGB statistics.os.freemem}}</td>
</tr>
<tr>
<th>{{_ "Cpus"}}</th>
<td>{{statistics.os.cpus.length}}</td>
</tr>
</table>
<h3>{{_ "Build_Environment"}}</h3>
<table class="statistics-table">
<tr>
<th>{{_ "Platform"}}</th>
<td>{{build.platform}}</td>
</tr>
<tr>
<th>{{_ "Arch"}}</th>
<td>{{build.arch}}</td>
</tr>
<tr>
<th>{{_ "Release"}}</th>
<td>{{build.osRelease}}</td>
</tr>
<tr>
<th>{{_ "Node_version"}}</th>
<td>{{build.nodeVersion}}</td>
</tr>
<tr>
<th>{{_ "Date"}}</th>
<td>{{formatDate build.date}}</td>
</tr>
</table>
<h3>{{_ "Usage"}}</h3>
<table class="statistics-table">
<tr>
<th>{{_ "Stats_Total_Users"}}</th>
@ -68,53 +174,13 @@
<th>{{_ "Stats_Avg_Private_Group_Users"}}</th>
<td>{{numFormat statistics.avgPrivateGroupUsers}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Type"}}</th>
<td>{{statistics.os.type}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Platform"}}</th>
<td>{{statistics.os.platform}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Arch"}}</th>
<td>{{statistics.os.arch}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Release"}}</th>
<td>{{statistics.os.release}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Uptime"}}</th>
<td>{{humanReadable statistics.os.uptime}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Loadavg"}}</th>
<td>{{numFormat statistics.os.loadavg.[0]}}, {{numFormat statistics.os.loadavg.[1]}}, {{numFormat statistics.os.loadavg.[2]}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Totalmem"}}</th>
<td>{{inGB statistics.os.totalmem}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Freemem"}}</th>
<td>{{inGB statistics.os.freemem}}</td>
</tr>
<tr>
<th>{{_ "Stats_OS_Cpus"}}</th>
<td>{{statistics.os.cpus.length}}</td>
</tr>
</table>
<button type="button" class="button refresh">Refresh</button>
{{else}}
{{_ "Please_wait_statistics"}}
{{_ "Loading..."}}
{{/if}}
{{/unless}}
<div style="margin: 30px 0">
<label for="opt-out-statistics"><input type="checkbox" value="1" name="opt-out-statistics" id="opt-out-statistics" checked="{{optOut}}"> {{_ "Opt_out_statistics"}}</label>
<div id="opt-out-warning" class="alert-warning" style="margin-top: 10px; padding: 10px;">
{{_ "Opt_out_statistics_warning"}}
</div>
</div>
</div>
</section>
</template>

@ -1,6 +1,6 @@
<template name="adminRoomInfo">
{{#unless hasPermission 'view-room-administration'}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
<div>
<h3><a href="{{route}}"><i class="icon-{{type}}"></i> {{name}}</a></h3>

@ -8,7 +8,7 @@
</head>
<div class="content">
{{#unless hasPermission 'view-room-administration'}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
<form class="search-form" role="form">
<div class="input-line search">

@ -1,6 +1,6 @@
<template name="adminUserChannels">
{{#unless hasPermission 'view-full-other-user-info'}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
<div class="user-info-channel">
<h3><a href="{{route}}"><i class="icon-{{type}}"></i> {{name}}</a></h3>

@ -1,6 +1,6 @@
<template name="adminUserEdit">
{{#unless canEditOrAdd}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
<div class="about clearfix">
<form class="edit-form">

@ -8,7 +8,7 @@
</head>
<div class="content">
{{#unless hasPermission 'view-user-administration'}}
<p>You are not authorized to view this page.</p>
<p>{{_ "You_are_not_authorized_to_view_this_page"}}</p>
{{else}}
<form class="search-form" role="form">
<div class="input-line search">

@ -24,7 +24,7 @@ Package.onUse(function(api) {
// template files
api.addFiles('admin/admin.html', 'client');
api.addFiles('admin/adminFlex.html', 'client');
api.addFiles('admin/adminStatistics.html', 'client');
api.addFiles('admin/adminInfo.html', 'client');
api.addFiles('admin/rooms/adminRoomInfo.html', 'client');
api.addFiles('admin/rooms/adminRooms.html', 'client');
@ -38,7 +38,7 @@ Package.onUse(function(api) {
// coffee files
api.addFiles('admin/admin.coffee', 'client');
api.addFiles('admin/adminFlex.coffee', 'client');
api.addFiles('admin/adminStatistics.coffee', 'client');
api.addFiles('admin/adminInfo.coffee', 'client');
api.addFiles('admin/rooms/adminRoomInfo.coffee', 'client');
api.addFiles('admin/rooms/adminRooms.coffee', 'client');

@ -49,6 +49,7 @@ Template.accountBox.events
'click #admin': ->
SideNav.setFlex "adminFlex"
SideNav.openFlex()
FlowRouter.go 'admin-info'
'click .account-link': ->
menu.close()

Loading…
Cancel
Save