Skip to content

Commit 722d9b3

Browse files
committed
[server-1547] dbviewer links added.
- create clearObjectId helper for handlerbars. - added dynamic hrefs to related places.
1 parent 2b01069 commit 722d9b3

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
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

+3-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();
@@ -948,7 +948,7 @@ window.DBViewerView = countlyView.extend({
948948
}
949949
response.collections.forEach(function(item) {
950950
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>' +
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="#/manage/db/' + self.db + '/' + self.collection + '/' + item._id + '">View</a></span></p></th>' +
952952
'</tr>' +
953953
'<tr>' +
954954
'<td class="jh-value jh-object-value">' + self.syntaxHighlight(JSON.stringify(item, undefined, 4)) + '</td>' +

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

+4-4
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=href="#/manage/db/{{../value.name}}/{{#withItem ../value.collections key=value}}{{this}}{{/withItem}}">{{value}}</a></li>
5151
{{/eachOfArray}}
5252
</ul>
5353
</div>
@@ -169,7 +169,7 @@ <h3 id="{{value.name}}-db-selector">{{value.name}}</h3>
169169
<table class="jh-type-object jh-root" id="dbviewer-collections">
170170
{{#eachOfArray data.collections}}
171171
<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>
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="#/manage/db/{{../db}}/{{../collection}}/{{#clearObjectId value._id}}{{/clearObjectId}}" class="dbviewer-document-detail">View</a></span></p></th>
173173
</tr>
174174
<tr>
175175
<td class="jh-value jh-object-value">{{prettyJSON value}}</td>
@@ -220,15 +220,15 @@ <h3 id="{{value.name}}-db-selector">{{value.name}}</h3>
220220
<div class="dbviewer-collection-list">
221221
{{#eachOfArray value.list}}
222222
<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>
223+
<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>
224224
</div>
225225
{{/eachOfArray}}
226226
</div>
227227
{{/ifCond}}
228228
{{/eachOfArray}}
229229
{{else}}
230230
{{#eachOfArray dbs}}
231-
<a href="javascript:void(0)">
231+
<a href="#/manage/db/{{value.name}}">
232232
<div class="dbviewer-db-square db-detail" id="{{value.name}}-box" data-db="{{value.name}}">
233233
<img class="dbviewer-box-svg" src="./dbviewer/images/dbviewer/{{value.name}}.svg">
234234
<h3 class="dbviewer-db-title" data-localize="dbviewer.{{value.name}}-database"></h3>

0 commit comments

Comments
 (0)