Skip to content

Commit 110dd43

Browse files
add initial statistics ui
Change-Id: If8ab7eecf4dfcea3ded78b226b168ee4356cae44 Reviewed-on: http://review.couchbase.org/70461 Reviewed-by: Pavel Blagodov <[email protected]> Tested-by: Pavel Blagodov <[email protected]>
1 parent 16dfbdf commit 110dd43

39 files changed

+34649
-1158
lines changed

priv/public/ui/app/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
angular.element($window).on("storage", function (storage) {
2727
if (storage.key === "mnLogIn") {
28-
$state.go("app.admin.overview");
28+
$state.go("app.admin.overview.statistics");
2929
}
3030
});
3131

priv/public/ui/app/app_config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
.module('app')
66
.config(appConfig);
77

8+
//https://github.com/angular-ui/ui-select/issues/1560
9+
angular.module('ui.select').run(function($animate) {
10+
var origEnabled = $animate.enabled
11+
$animate.enabled = function (elem) {
12+
if (arguments.length !== 1) {
13+
return origEnabled.apply($animate, arguments);
14+
} else if (origEnabled(elem)) {
15+
return (/enable-ng-animation/).test(elem.classNames);
16+
}
17+
return false
18+
}
19+
});
20+
821
function appConfig($httpProvider, $stateProvider, $urlRouterProvider, $uibModalProvider, $transitionsProvider, $uibTooltipProvider, $animateProvider, $qProvider, $sceDelegateProvider) {
922
$httpProvider.defaults.headers.common['invalid-auth-response'] = 'on';
1023
$httpProvider.defaults.headers.common['Cache-Control'] = 'no-cache';
@@ -40,7 +53,7 @@
4053
$urlRouterProvider.otherwise(function ($injector, $location) {
4154
$injector.get("mnPools").get().then(function (pools) {
4255
if (pools.isInitialized) {
43-
return $injector.get("$state").go("app.admin.overview");
56+
return $injector.get("$state").go("app.admin.overview.statistics");
4457
}
4558
});
4659
return true;

priv/public/ui/app/components/mn_filters.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,14 @@
594594
function mnFormatServices() {
595595
return function (service) {
596596
switch (service) {
597-
case 'kv': return 'Data';
598-
case 'n1ql': return 'Query';
599-
case 'index': return 'Index';
600-
case 'fts': return 'Search';
601-
case 'eventing': return 'Eventing';
602-
case 'cbas': return 'Analytics';
597+
case 'kv': return 'Data';
598+
case 'query':
599+
case 'n1ql': return 'Query';
600+
case 'index': return 'Index';
601+
case 'fts': return 'Search';
602+
case 'eventing': return 'Eventing';
603+
case 'cbas': return 'Analytics';
604+
default: return service;
603605
}
604606
}
605607
}

priv/public/ui/app/components/mn_poll.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,28 @@
3434
}
3535
}
3636

37-
function mnPollerFactory($q, $timeout, mnTasksDetails, mnPromiseHelper) {
37+
function mnPollerFactory($q, $timeout, mnTasksDetails, mnPromiseHelper, $window) {
3838

3939
function Poller(scope, request) {
4040
this.deferred = $q.defer();
4141
this.request = request;
4242
this.scope = scope;
43+
var self = this;
44+
45+
scope.$on('$destroy', function () {
46+
$window.removeEventListener('visibilitychange', onVisibilitychange);
47+
self.onDestroy();
48+
});
49+
50+
function onVisibilitychange() {
51+
if (document.hidden) {
52+
self.stop();
53+
} else {
54+
self.reload();
55+
}
56+
}
4357

44-
scope.$on('$destroy', this.stop.bind(this));
58+
$window.addEventListener('visibilitychange', onVisibilitychange);
4559

4660
this.latestResult = undefined;
4761
this.stopTimestamp = undefined;
@@ -60,9 +74,14 @@
6074
Poller.prototype.showSpinner = showSpinner;
6175
Poller.prototype.reload = reload;
6276
Poller.prototype.reloadOnScopeEvent = reloadOnScopeEvent;
77+
Poller.prototype.onDestroy = onDestroy;
6378

6479
return Poller;
6580

81+
function onDestroy() {
82+
this.stop();
83+
}
84+
6685
function isStopped(startTimestamp) {
6786
return !(angular.isUndefined(this.stopTimestamp) || startTimestamp >= this.stopTimestamp);
6887
}
@@ -112,6 +131,11 @@
112131
return query;
113132
}
114133
function cycle() {
134+
if (this.isLaunched) {
135+
return this;
136+
}
137+
138+
this.isLaunched = true;
115139
this.doCycle();
116140
return this;
117141
}
@@ -140,6 +164,7 @@
140164
}
141165
function stop() {
142166
var self = this;
167+
self.isLaunched = false;
143168
self.stopTimestamp = new Date();
144169
$timeout.cancel(self.timeout);
145170
}

priv/public/ui/app/css/cbui-components.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,3 +2292,11 @@ nav.nav-sidebar-hidden {
22922292
content: '\007C';
22932293
color: #d1d1d1;
22942294
}
2295+
2296+
.pipe:nth-child(2):before {
2297+
content: none !important;
2298+
}
2299+
2300+
.nvd3.nv-scatter.nv-single-point .nv-groups .nv-group .nv-point:not(.hover) {
2301+
fill-opacity: .0 !important;
2302+
stroke-opa

priv/public/ui/app/mn_admin/mn_admin.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@
9797
</div>
9898

9999
<header>
100-
<a ui-sref="app.admin.overview" class="logobug-wrapper">
100+
<a ui-sref="app.admin.overview.statistics" class="logobug-wrapper">
101101
<img src="../cb_logo_bug_white_2.svg" width="48" height="48" alt="Couchbase Server" class="logobug" title="Couchbase Server {{::adminCtl.implementationVersion | mnPrettyVersion}}">
102102
</a>
103103
<h1>
104-
<a ui-sref="app.admin.overview" class="resp-txt-xsml ellipsis">
104+
<a ui-sref="app.admin.overview.statistics" class="resp-txt-xsml ellipsis">
105105
{{adminCtl.tabName}} <!-- the cluster name -->
106106
</a>
107107
<span class="resp-hide-xsml" ng-show="adminCtl.tabName">
@@ -143,7 +143,7 @@ <h1>
143143

144144
<a
145145
mn-tab="overview"
146-
ui-sref="app.admin.overview"
146+
ui-sref="app.admin.overview.statistics"
147147
ui-sref-active="currentnav">
148148
Dashboard
149149
</a>

priv/public/ui/app/mn_admin/mn_admin_config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'mnPromiseHelper',
1010
'mnBuckets',
1111
'mnAnalytics',
12+
'mnStatisticsNew',
1213
'mnLogs',
1314
'mnOverview',
1415
'mnIndexes',
@@ -81,6 +82,7 @@
8182
})
8283
.state('app.admin.overview', {
8384
url: '/overview',
85+
abstract: true,
8486
views: {
8587
8688
controller: 'mnOverviewController as overviewCtl',
@@ -202,6 +204,34 @@
202204
.state('app.admin.logs.collectInfo.form', {
203205
url: '/form',
204206
templateUrl: 'app/mn_admin/mn_logs/collect_info/mn_logs_collect_info_form.html'
207+
})
208+
.state('app.admin.overview.statistics', {
209+
url: '/stats?zoom&scenario&scenarioBucket',
210+
controller: 'mnStatisticsNewController as statisticsNewCtl',
211+
templateUrl: 'app/mn_admin/mn_statistics/mn_statistics.html',
212+
redirectTo: function (trans, permissions) {
213+
var mnPermissionsService = trans.injector().get("mnPermissions");
214+
var params = _.clone(trans.params(), true);
215+
return mnPermissionsService.check().then(function (permissions) {
216+
var statsRead = permissions.bucketNames['.stats!read']
217+
if (!params.scenarioBucket && statsRead && statsRead[0]) {
218+
params.scenarioBucket = statsRead[0];
219+
return {state: "app.admin.overview.statistics", params: params};
220+
}
221+
});
222+
},
223+
params: {
224+
scenarioBucket: {
225+
value: null
226+
},
227+
scenario: {
228+
value: null,
229+
dynamic: true
230+
},
231+
zoom: {
232+
value: null
233+
}
234+
}
205235
});
206236

207237
addAnalyticsStates("app.admin.servers.list");

priv/public/ui/app/mn_admin/mn_admin_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
var etagPoller = new mnEtagPoller($scope, function (previous) {
8888
return mnPoolDefault.get({
8989
etag: previous ? previous.etag : "",
90-
waitChange: $state.current.name === "app.admin.overview" ? 3000 : 10000
90+
waitChange: $state.current.name === "app.admin.overview.statistics" ? 3000 : 10000
9191
}, {group: "global"});
9292
}).subscribe(function (resp, previous) {
9393
if (!_.isEqual(resp, previous)) {

priv/public/ui/app/mn_admin/mn_analytics/mn_analytics_service.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
queries.push(isSpecificStat ? $q.when({
7676
data: resp.data.directory.value,
7777
origTitle: resp.data.directory.origTitle
78-
}) : getStatsDirectory(resp.data.directory.url));
79-
78+
}) : getStatsDirectory("/pools/default/buckets//" + params.$stateParams.bucket + "/statsDirectory"));
8079
return $q.all(queries).then(function (data) {
8180
return prepareAnaliticsState(data, params);
8281
});
@@ -114,7 +113,14 @@
114113
function getStatsDirectory(url) {
115114
return $http({
116115
url: url,
117-
method: 'GET'
116+
method: 'GET',
117+
params: {
118+
adde: '"all"',
119+
adda: '"all"',
120+
addi: '"all"',
121+
addf: '"all"',
122+
addq: "1"
123+
}
118124
});
119125
}
120126
function prepareAnaliticsState(data, params) {

priv/public/ui/app/mn_admin/mn_overview/mn_overview.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ <h3>{{overviewCtl.nodes.all.down.length || '0'}}</h3>
139139
</div>
140140
</div>
141141

142+
<div ui-view=""></div>
143+
142144
<div class="content-box-dashboard max-width-12 margin-top-2 resp-wrap-med resp-med">
143145
<div
144146
class="column width-6">

0 commit comments

Comments
 (0)