From f6672605e82919798eb23ec45d8e663351af7d97 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 9 Jan 2017 09:26:07 -0500 Subject: Reorganize stats on system statistics page (#5007) --- webapp/components/analytics/system_analytics.jsx | 314 ++++++++++++++--------- 1 file changed, 189 insertions(+), 125 deletions(-) (limited to 'webapp/components') diff --git a/webapp/components/analytics/system_analytics.jsx b/webapp/components/analytics/system_analytics.jsx index 244e1ff07..dd7b90260 100644 --- a/webapp/components/analytics/system_analytics.jsx +++ b/webapp/components/analytics/system_analytics.jsx @@ -80,69 +80,141 @@ class SystemAnalytics extends React.Component { render() { const stats = this.state.stats; + const isLicensed = global.window.mm_license.IsLicensed === 'true'; + const skippedIntensiveQueries = stats[StatTypes.TOTAL_POSTS] === -1; + const postCountsDay = formatPostsPerDayData(stats[StatTypes.POST_PER_DAY]); + const userCountsWithPostsDay = formatUsersWithPostsPerDayData(stats[StatTypes.USERS_WITH_POSTS_PER_DAY]); let banner; - if (stats[StatTypes.TOTAL_POSTS] === -1) { + let postCount; + let postTotalGraph; + let activeUserGraph; + if (skippedIntensiveQueries) { banner = ( - +
+
+ + ); + } else { + postCount = ( + } + icon='fa-comment' + count={stats[StatTypes.TOTAL_POSTS]} /> ); - } - let advancedCounts; - let advancedStats; - let advancedGraphs; - if (global.window.mm_license.IsLicensed === 'true') { - advancedCounts = ( + postTotalGraph = (
- - } - icon='fa-signal' - count={stats[StatTypes.TOTAL_SESSIONS]} - /> - - } - icon='fa-terminal' - count={stats[StatTypes.TOTAL_COMMANDS]} - /> - } - icon='fa-arrow-down' - count={stats[StatTypes.TOTAL_IHOOKS]} + data={postCountsDay} + options={{ + legend: { + display: false + } + }} + width='740' + height='225' /> - + ); + + activeUserGraph = ( +
+ } - icon='fa-arrow-up' - count={stats[StatTypes.TOTAL_OHOOKS]} + data={userCountsWithPostsDay} + options={{ + legend: { + display: false + } + }} + width='740' + height='225' />
); + } + + let advancedStats; + let advancedGraphs; + let sessionCount; + let commandCount; + let incomingCount; + let outgoingCount; + if (global.window.mm_license.IsLicensed === 'true') { + sessionCount = ( + + } + icon='fa-signal' + count={stats[StatTypes.TOTAL_SESSIONS]} + /> + ); + + commandCount = ( + + } + icon='fa-terminal' + count={stats[StatTypes.TOTAL_COMMANDS]} + /> + ); + + incomingCount = ( + + } + icon='fa-arrow-down' + count={stats[StatTypes.TOTAL_IHOOKS]} + /> + ); + + outgoingCount = ( + + } + icon='fa-arrow-up' + count={stats[StatTypes.TOTAL_OHOOKS]} + /> + ); advancedStats = (
@@ -247,65 +319,89 @@ class SystemAnalytics extends React.Component { } } - const postCountsDay = formatPostsPerDayData(stats[StatTypes.POST_PER_DAY]); - const userCountsWithPostsDay = formatUsersWithPostsPerDayData(stats[StatTypes.USERS_WITH_POSTS_PER_DAY]); + const userCount = ( + + } + icon='fa-user' + count={stats[StatTypes.TOTAL_USERS]} + /> + ); - let totalPostsCount; - let postTotalGraph; - let activeUserGraph; - if (stats[StatTypes.TOTAL_POSTS] !== -1) { - totalPostsCount = ( - - } - icon='fa-comment' - count={stats[StatTypes.TOTAL_POSTS]} - /> + const teamCount = ( + + } + icon='fa-users' + count={stats[StatTypes.TOTAL_TEAMS]} + /> + ); + + const channelCount = ( + + } + icon='fa-globe' + count={stats[StatTypes.TOTAL_PUBLIC_CHANNELS] + stats[StatTypes.TOTAL_PRIVATE_GROUPS]} + /> + ); + + let firstRow; + let secondRow; + if (isLicensed && skippedIntensiveQueries) { + firstRow = ( +
+ {userCount} + {teamCount} + {channelCount} + {sessionCount} +
); - postTotalGraph = ( + secondRow = (
- - } - data={postCountsDay} - options={{ - legend: { - display: false - } - }} - width='740' - height='225' - /> + {commandCount} + {incomingCount} + {outgoingCount} +
+ ); + } else if (isLicensed && !skippedIntensiveQueries) { + firstRow = ( +
+ {userCount} + {teamCount} + {channelCount} + {postCount}
); - activeUserGraph = ( + secondRow = (
- - } - data={userCountsWithPostsDay} - options={{ - legend: { - display: false - } - }} - width='740' - height='225' - /> + {sessionCount} + {commandCount} + {incomingCount} + {outgoingCount} +
+ ); + } else if (!isLicensed) { + firstRow = ( +
+ {userCount} + {teamCount} + {channelCount} + {postCount}
); } @@ -319,40 +415,8 @@ class SystemAnalytics extends React.Component { /> {banner} -
- - } - icon='fa-user' - count={stats[StatTypes.TOTAL_USERS]} - /> - - } - icon='fa-users' - count={stats[StatTypes.TOTAL_TEAMS]} - /> - {totalPostsCount} - - } - icon='fa-globe' - count={stats[StatTypes.TOTAL_PUBLIC_CHANNELS] + stats[StatTypes.TOTAL_PRIVATE_GROUPS]} - /> -
- {advancedCounts} + {firstRow} + {secondRow} {advancedStats} {advancedGraphs} {postTotalGraph} -- cgit v1.2.3-1-g7c22