Skip to content

Commit efa6210

Browse files
BigFungerJim Unger
authored andcommitted
modified to use hash
Fixes #5497
1 parent 4831453 commit efa6210

12 files changed

Lines changed: 72 additions & 161 deletions

File tree

src/plugins/kibana/public/dashboard/index.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ define(function (require) {
2626
'kibana/courier',
2727
'kibana/config',
2828
'kibana/notify',
29-
'kibana/typeahead',
30-
'kibana/share'
29+
'kibana/typeahead'
3130
]);
3231

3332
require('ui/routes')
@@ -92,7 +91,6 @@ define(function (require) {
9291
var $uiState = $scope.uiState = $state.makeStateful('uiState');
9392

9493
$scope.$watchCollection('state.options', function (newVal, oldVal) {
95-
//console.log('watch state.options');
9694
if (!angular.equals(newVal, oldVal)) $state.save();
9795
});
9896
$scope.$watch('state.options.darkTheme', setDarkTheme);
@@ -157,15 +155,13 @@ define(function (require) {
157155
}
158156

159157
function setDarkTheme(enabled) {
160-
//console.log('setDarkTheme');
161158
var theme = Boolean(enabled) ? 'theme-dark' : 'theme-light';
162159
chrome.removeApplicationClass(['theme-dark', 'theme-light']);
163160
chrome.addApplicationClass(theme);
164161
}
165162

166163
// update root source when filters update
167164
$scope.$listen(queryFilter, 'update', function () {
168-
//console.log('queryFilter update');
169165
updateQueryOnRootSource();
170166
$state.save();
171167
});
@@ -239,16 +235,6 @@ define(function (require) {
239235
save: $scope.save,
240236
addVis: $scope.addVis,
241237
addSearch: $scope.addSearch
242-
// ,
243-
// shareData: function () {
244-
// //console.log('this is being called.');
245-
// return {
246-
// link: $location.absUrl(),
247-
// // This sucks, but seems like the cleanest way. Uhg.
248-
// embed: '<iframe src="' + $location.absUrl().replace('?', '?embed&') +
249-
// '" height="600" width="800"></iframe>'
250-
// };
251-
// }
252238
};
253239

254240
init();
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
11
<share object-type="dashboard"></share>
2-
<!-- <form role="form" class="vis-share">
3-
4-
<p>
5-
<div class="input-group">
6-
<label>
7-
Embed this dashboard
8-
<small>Add to your html source. Note all clients must still be able to access kibana</small>
9-
</label>
10-
<div class="form-control" disabled>{{opts.shareData().embed}}</div>
11-
</div>
12-
</p>
13-
14-
<p>
15-
<div class="input-group">
16-
<label>
17-
Share a link
18-
</label>
19-
<div class="form-control" disabled>{{opts.shareData().link}}</div>
20-
</div>
21-
</p>
22-
</form> -->

src/plugins/kibana/public/discover/controllers/discover.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ define(function (require) {
2020
require('ui/state_management/app_state');
2121
require('ui/timefilter');
2222
require('ui/highlight/highlight_tags');
23+
require('ui/share');
2324

2425
var app = require('ui/modules').get('apps/discover', [
2526
'kibana/notify',
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
11
<share object-type="search"></share>
2-
<!-- <form role="form" class="vis-share">
3-
4-
<p>
5-
<div class="input-group">
6-
<label>
7-
Embed this dashboard
8-
<small>Add to your html source. Note all clients must still be able to access kibana</small>
9-
</label>
10-
<div class="form-control" disabled>{{opts.shareData().embed}}</div>
11-
</div>
12-
</p>
13-
14-
<p>
15-
<div class="input-group">
16-
<label>
17-
Share a link
18-
</label>
19-
<div class="form-control" disabled>{{opts.shareData().link}}</div>
20-
</div>
21-
</p>
22-
</form> -->

src/plugins/kibana/public/goto/index.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/plugins/kibana/public/visualize/editor/editor.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ define(function (require) {
66

77
require('ui/visualize');
88
require('ui/collapsible_sidebar');
9+
require('ui/share');
910

1011
require('ui/routes')
1112
.when('/visualize/create', {
@@ -234,15 +235,6 @@ define(function (require) {
234235
}, notify.fatal);
235236
};
236237

237-
// $scope.shareData = function () {
238-
// return {
239-
// link: $location.absUrl(),
240-
// // This sucks, but seems like the cleanest way. Uhg.
241-
// embed: '<iframe src="' + $location.absUrl().replace('?', '?embed&') +
242-
// '" height="600" width="800"></iframe>'
243-
// };
244-
// };
245-
246238
$scope.unlink = function () {
247239
if (!$state.linked) return;
248240

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1 @@
11
<share object-type="visualization"></share>
2-
<!-- <form role="form" class="vis-share">
3-
4-
<p>
5-
<div class="form-group">
6-
<label>
7-
Embed this visualization.
8-
<small>Add to your html source. Note all clients must still be able to access kibana</small>
9-
</label>
10-
<div class="form-control" disabled>{{conf.shareData().embed}}</div>
11-
</div>
12-
</p>
13-
14-
<p>
15-
<div class="form-group">
16-
<label>
17-
Share a link
18-
</label>
19-
<div class="form-control" disabled>{{conf.shareData().link}}</div>
20-
</div>
21-
</p>
22-
23-
</form> -->

src/server/http/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ module.exports = function (kbnServer, server, config) {
6363

6464
server.connection(connectionOptions);
6565

66-
6766
// provide a simple way to expose static directories
6867
server.decorate('server', 'exposeStaticDir', function (routePath, dirPath) {
6968
this.route({

src/server/http/urlLookup.js

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,83 @@ export default function (server) {
1717
}
1818
});
1919
} catch (err) {
20-
console.log(err);
21-
//swallow errors. We don't care if there is no update.
20+
console.log('Error updating url metadata', err);
21+
//swallow errors. It isn't critical if there is no update.
2222
}
2323
}
2424

25-
return {
26-
async generateUrlId(url) {
27-
const urlId = await new Promise((resolve, reject) => {
28-
const client = server.plugins.elasticsearch.client;
25+
async function getUrlDoc(urlId) {
26+
const urlDoc = await new Promise((resolve, reject) => {
27+
const client = server.plugins.elasticsearch.client;
2928

30-
// const urlId = crypto.createHash('md5')
31-
// .update(url)
32-
// .digest('hex');
29+
client.get({
30+
index: '.kibana',
31+
type: 'url',
32+
id: urlId
33+
})
34+
.then(response => {
35+
resolve(response);
36+
})
37+
.catch(err => {
38+
resolve();
39+
});
40+
});
3341

34-
client.index({
35-
index: '.kibana',
36-
type: 'url',
37-
body: {
38-
url,
39-
'access-count': 0,
40-
'create-date': new Date(),
41-
'access-date': new Date()
42-
}
43-
})
44-
.then(response => {
45-
const urlId = response._id;
46-
resolve(urlId);
47-
})
48-
.catch(err => {
49-
reject(err);
50-
});
42+
return urlDoc;
43+
}
44+
45+
async function createUrlDoc(url, urlId) {
46+
const newUrlId = await new Promise((resolve, reject) => {
47+
const client = server.plugins.elasticsearch.client;
48+
49+
client.index({
50+
index: '.kibana',
51+
type: 'url',
52+
id: urlId,
53+
body: {
54+
url,
55+
'access-count': 0,
56+
'create-date': new Date(),
57+
'access-date': new Date()
58+
}
59+
})
60+
.then(response => {
61+
resolve(response._id);
62+
})
63+
.catch(err => {
64+
reject(err);
5165
});
66+
});
67+
68+
return newUrlId;
69+
}
70+
71+
function createUrlId(url) {
72+
const urlId = crypto.createHash('md5')
73+
.update(url)
74+
.digest('hex');
75+
76+
return urlId;
77+
}
5278

53-
return urlId;
79+
return {
80+
async generateUrlId(url) {
81+
const urlId = createUrlId(url);
82+
83+
const urlDoc = await getUrlDoc(urlId);
84+
if (urlDoc) return urlId;
85+
86+
return createUrlDoc(url, urlId);
5487
},
5588
async getUrl(urlId) {
56-
const url = await new Promise((resolve, reject) => {
57-
const client = server.plugins.elasticsearch.client;
58-
59-
client.get({
60-
index: '.kibana',
61-
type: 'url',
62-
id: urlId
63-
})
64-
.then(response => {
65-
const url = response._source.url;
66-
updateMetadata(urlId, response);
67-
resolve(url);
68-
})
69-
.catch(err => {
70-
resolve('/');
71-
});
72-
});
89+
try {
90+
const urlDoc = await getUrlDoc(urlId);
91+
updateMetadata(urlId, urlDoc);
7392

74-
return url;
93+
return urlDoc._source.url;
94+
} catch (err) {
95+
return '/';
96+
}
7597
}
7698
};
7799
};

src/ui/public/directives/config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ define(function (require) {
2929
var tmpScope = $scope.$new();
3030

3131
$scope.$watch('configObject', function (newVal) {
32-
console.log('config watch');
3332
$scope[attr.configObject] = $scope.configObject;
3433
});
3534

@@ -45,7 +44,6 @@ define(function (require) {
4544
'configSubmit',
4645
'configTemplate.current || configTemplate'
4746
], function () {
48-
console.log('config watchMulti');
4947
var tmpl = $scope.configTemplate;
5048
if (tmpl instanceof ConfigTemplate) {
5149
tmpl = tmpl.toString();

0 commit comments

Comments
 (0)