Skip to content

Commit 4012137

Browse files
authored
Merge pull request #1054 from frknbasaran/server-1547
[server-1547] dbviewer links added.
2 parents 8ee40b6 + 2c6ec9c commit 4012137

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

frontend/express/public/javascripts/countly/countly.template.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,20 @@ var AppRouter = Backbone.Router.extend({
12371237
* {{> date-selector }}
12381238
*/
12391239
Handlebars.registerPartial("date-selector", $("#template-date-selector").html());
1240-
1240+
/**
1241+
* Get id value from ObjectID string
1242+
* @name getIdValue
1243+
* @memberof Handlebars
1244+
* @example
1245+
* <span>{{#clearObjectId value}}{{/clearObjectId}}</span>
1246+
*/
1247+
Handlebars.registerHelper('clearObjectId', function(string) {
1248+
var id = string;
1249+
if (id.substr(0, 3) === "Obj") {
1250+
id = id.split("(")[1].split(")")[0];
1251+
}
1252+
return id;
1253+
});
12411254
/**
12421255
* Display common date time selecting UI elements
12431256
* @name date-time-selector

plugins/dbviewer/frontend/public/javascripts/countly.views.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ window.DBViewerView = countlyView.extend({
409409
}
410410
data.collections.forEach(function(item) {
411411
var template = '<tr>' +
412-
'<th class="jh-key jh-object-key"><p><strong>_id: </strong>' + item._id + '<span class="dbviewer-view-link" class="jh-type-string"><a class="dbviewer-document-detail" data-db="' + self.db + '" data-id="' + item._id + '" data-collection="' + self.collection + '" href="javascript:void(0)">View</a></span></p></th>' +
412+
'<th class="jh-key jh-object-key"><p><strong>_id: </strong>' + item._id + '<span class="dbviewer-view-link" class="jh-type-string"><a class="dbviewer-document-detail" data-db="' + self.db + '" data-id="' + item._id + '" data-collection="' + self.collection + '" href="#/manage/db/' + self.db + '/' + self.collection + '/' + item._id + '">View</a></span></p></th>' +
413413
'</tr>' +
414414
'<tr>' +
415415
'<td class="jh-value jh-object-value">' + self.syntaxHighlight(JSON.stringify(item, undefined, 4)) + '</td>' +
@@ -455,7 +455,7 @@ window.DBViewerView = countlyView.extend({
455455
$('.dbviewer-collections').append('<div class="dbviewer-db-area-title">' + this.db + '</div>');
456456
$('.dbviewer-collections').append('<div class="dbviewer-collection-list">');
457457
for (var collection in dbs[currentDbIndex].collections) {
458-
$('.dbviewer-collection-list').append('<div class="dbviewer-collection-list-item"><a class="collection-list-item" data-db="' + this.db + '" data-collection="' + dbs[currentDbIndex].collections[collection] + '" href="javascript:void(0)">' + collection + '</a></div>');
458+
$('.dbviewer-collection-list').append('<div class="dbviewer-collection-list-item"><a class="collection-list-item" data-db="' + this.db + '" data-collection="' + dbs[currentDbIndex].collections[collection] + '" href="#/manage/db/' + this.db + '/' + dbs[currentDbIndex].collections[collection] + '">' + collection + '</a></div>');
459459
}
460460
$('.dbviewer-collections').append('</div>');
461461
$('.dbviewer-aggregate').hide();
@@ -564,6 +564,7 @@ window.DBViewerView = countlyView.extend({
564564
$('#aggregate-header').show();
565565
$('#dbviewer-header').hide();
566566
$('#generate_aggregate_report').text($.i18n.map["dbviewer.generate-aggregate-report"]);
567+
$('#back_to_dbviewer').attr('href', '#/manage/db/' + self.templateData.db + '/' + self.templateData.collection);
567568
$('#back_to_dbviewer').text($.i18n.map["dbviewer.back-to-dbviewer"]);
568569
$('#back_to_dbviewer').css('display', 'block');
569570
}
@@ -948,7 +949,7 @@ window.DBViewerView = countlyView.extend({
948949
}
949950
response.collections.forEach(function(item) {
950951
var template = '<tr>' +
951-
'<th class="jh-key jh-object-key"><p><strong>_id: </strong>' + item._id + '<span class="dbviewer-view-link" data-db="' + self.db + '" data-id="' + item._id + '" data-collection="' + self.collection + '" class="jh-type-string"><a href="javascript:void(0)">View</a></span></p></th>' +
952+
'<th class="jh-key jh-object-key"><p><strong>_id: </strong>' + item._id + '<span class="dbviewer-view-link" data-db="' + self.db + '" data-id="' + item._id + '" data-collection="' + self.collection + '" class="jh-type-string"><a href="#/manage/db/' + self.db + '/' + self.collection + '/' + item._id + '">View</a></span></p></th>' +
952953
'</tr>' +
953954
'<tr>' +
954955
'<td class="jh-value jh-object-value">' + self.syntaxHighlight(JSON.stringify(item, undefined, 4)) + '</td>' +

plugins/dbviewer/frontend/public/templates/dbviewer.html

+13-9
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h3 id="{{value.name}}-db-selector">{{value.name}}</h3>
4747
</div>
4848
<ul class="dbviewer-collection-list-{{value.name}}">
4949
{{#eachOfArray value.list}}
50-
<li data-db="{{../value.name}}" data-collection="{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}" class="collection-list-item searchable"><a class="dbviewer-link-in-collection-list" href='javascript:void(0)'>{{value}}</a></li>
50+
<li data-db="{{../value.name}}" data-collection="{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}" class="collection-list-item searchable"><a class="dbviewer-link-in-collection-list" href="#/manage/db/{{../value.name}}/{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}">{{value}}</a></li>
5151
{{/eachOfArray}}
5252
</ul>
5353
</div>
@@ -56,17 +56,21 @@ <h3 id="{{value.name}}-db-selector">{{value.name}}</h3>
5656
</div>
5757
<div class="right-side">
5858
<!-- Collection Back Button -->
59-
<a class="dbviewer-go-back" href="javascript:void(0)"><div class="icon-button light dbviewer-back-button"><i class="fa fa-chevron-left"></i> <span>{{back}}</span></div></a>
60-
<a class="dbviewer-aggregate" href="javascript:void(0)"><div class="icon-button light dbviewer-aggregate-button"><i class="fa fa-bar-chart"></i> <span data-localize="dbviewer.aggregate"></span></div></a>
59+
{{#if document}}
60+
<a class="dbviewer-go-back" href="#/manage/db/{{db}}/{{collection}}"><div class="icon-button light dbviewer-back-button"><i class="fa fa-chevron-left"></i> <span>{{back}}</span></div></a>
61+
{{else}}
62+
<a class="dbviewer-go-back" href="#/manage/db"><div class="icon-button light dbviewer-back-button"><i class="fa fa-chevron-left"></i> <span>{{back}}</span></div></a>
63+
{{/if}}
64+
<a class="dbviewer-aggregate" href="#/manage/db/aggregate/{{db}}/{{collection}}"><div class="icon-button light dbviewer-aggregate-button"><i class="fa fa-bar-chart"></i> <span data-localize="dbviewer.aggregate"></span></div></a>
6165
<div class="dbviewer-gray-area dbviewer-area-pos">
6266
<div class="dbviewer-header-of-query-wrapper">
6367
<div class="dbviewer-gray dbviewer-left-side-1">
6468
<a id="dbviewer-go-back" href='javascript:void()'>/</a>
6569
{{#if db}}
6670
{{#if collection}}
67-
<a class="dbviewer-gray dbviewer-go-back" id="dbviewer-go-collectionlist" data-db="{{db}}" href='javascript:void(0)'><strong>{{db}}</strong></a>
71+
<a class="dbviewer-gray dbviewer-go-back" id="dbviewer-go-collectionlist" data-db="{{db}}" href='#/manage/db/{{db}}'><strong>{{db}}</strong></a>
6872
{{#if document}}
69-
<a class="dbviewer-gray" href='javascript:void(0)'>/ {{collection}}</a>
73+
<a class="dbviewer-gray" href='#/manage/db/{{db}}/{{collection}}'>/ {{collection}}</a>
7074
{{else}}
7175
/{{collection}}
7276
{{/if}}
@@ -169,7 +173,7 @@ <h3 id="{{value.name}}-db-selector">{{value.name}}</h3>
169173
<table class="jh-type-object jh-root" id="dbviewer-collections">
170174
{{#eachOfArray data.collections}}
171175
<tr>
172-
<th class="jh-key jh-object-key"><p><strong>_id:</strong> {{value._id}} <span class="dbviewer-view-link" class="jh-type-string"><a data-db="{{../db}}" data-collection="{{../collection}}" data-id="{{value._id}}" href='javascript:void(0)' class="dbviewer-document-detail">View</a></span></p></th>
176+
<th class="jh-key jh-object-key"><p><strong>_id:</strong> {{value._id}} <span class="dbviewer-view-link" class="jh-type-string"><a data-db="{{../db}}" data-collection="{{../collection}}" data-id="{{value._id}}" href="#/manage/db/{{../db}}/{{../collection}}/{{#clearObjectId value._id}}{{/clearObjectId}}" class="dbviewer-document-detail">View</a></span></p></th>
173177
</tr>
174178
<tr>
175179
<td class="jh-value jh-object-value">{{prettyJSON value}}</td>
@@ -220,20 +224,20 @@ <h3 id="{{value.name}}-db-selector">{{value.name}}</h3>
220224
<div class="dbviewer-collection-list">
221225
{{#eachOfArray value.list}}
222226
<div class="dbviewer-collection-list-item">
223-
<a class="collection-list-item" data-db="{{../../../db}}" data-collection="{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}" href="javascript:void(0)">{{value}}</a>
227+
<a class="collection-list-item" data-db="{{../../../db}}" data-collection="{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}" href="#/manage/db/{{../../../db}}/{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}">{{value}}</a>
224228
</div>
225229
{{/eachOfArray}}
226230
</div>
227231
{{/ifCond}}
228232
{{/eachOfArray}}
229233
{{else}}
230234
{{#eachOfArray dbs}}
231-
<a href="javascript:void(0)">
235+
<a href="#/manage/db/{{value.name}}">
232236
<div class="dbviewer-db-square db-detail" id="{{value.name}}-box" data-db="{{value.name}}">
233237
<img class="dbviewer-box-svg" src="./dbviewer/images/dbviewer/{{value.name}}.svg">
234238
<h3 class="dbviewer-db-title" data-localize="dbviewer.{{value.name}}-database"></h3>
235239
<p class="dbviewer-db-description" data-localize="dbviewer.{{value.name}}-database-description"></p>
236-
</div>
240+
</div>
237241
</a>
238242
{{/eachOfArray}}
239243
{{/if}}

0 commit comments

Comments
 (0)