Skip to content

Commit

Permalink
changes made for handling existing index pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandey, Kamlesh committed Jul 24, 2018
1 parent 6f47e51 commit 3af7dd8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ before_deploy:
- mkdir kibana
- cp -R patternizer kibana/
- rm -rf patternizer/node_modules
- zip -r patternizer-6.3.2.zip kibana
- zip -r patternizer-6.2.4.zip kibana
- rm -rf kibana
deploy:
provider: releases
api_key:
secure: DXak8lWw4iM5nagqzjMob3UunO4lQJJI+DuRFM8wY9MgrAcRBp5I7kO9qW9LjzYiIRuT8hJIXHu5jeL2zICf4Gvjp6qYGB7hlEfjl3bp9AicqjoNWfxS+/6HS2PnoZJFSU29btKYdM3wG8k3wrSoE5PyeFa6w1CS9jVSVjzCPmwUcaj5p3N0+OyfDJqY0WwpCQuDMV7rxG594aF+7DCaCOkOf8wQLSnX7uH3PHxL0beO2tJt7kYXg/Hq3P2QUERuP73etKbIFq3Oje7/uIXg5TNk3CdQAUo/J5PVFUnhq6isRnuTohpvz2jOBz4aL1HKVl8io/GUVrAW7w6GnuC8t+ku86RwXvtFC4FJFV/OLfXk9H0b88oDTAELap7pNkdaPqib0+kPBUycjH0xvEmhUC61ydhCHJxyXCz6HmS6XpHpr+3ukeFm1ZRDc53KRCKieYLfFYkOUCeWPs2wu5yCYyxbmx9f2b+I9AnCYnm4hJYKg8oWGrUQP2r7rEMDUNoCYj1H1R2tZzc15EKyG9nGO4Ep0geVkYVupsh9PyYTEHiKeHq/AiD4fpKYYLbj48tCUwf2pQ7EmNzuNzkxnGEq4UJSuaqXBf4UAH+pic8eD+Y555Ylcpb2KB/DXA4MJLeu7SLjRmP6fUTliS2W4NLWSW8/Hs8idBQLEb0nNC0Om70=
file: patternizer-6.3.2.zip
file: patternizer-6.2.4.zip
on:
repo: Nordstrom/patternizer
tags: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "This plugin allow you to create index pattern if it does not exist",
"main": "index.js",
"kibana": {
"version": "6.3.2"
"version": "6.2.4"
},
"repository": {
"type": "git",
Expand Down
21 changes: 18 additions & 3 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,33 @@ uiModules
var baseurl = $location.$$absUrl.split('/app')[0]
$scope.target = ($location.search()).target;
var request = {'timeFieldName': '@timestamp', 'title': $scope.target};
var patternId = ""
$http.post('../api/getIndexDocumentCount', request).then((response) => {
if(typeof $scope.target === 'undefined') {
$scope.welcomemessage = 'Welcome to Patternizer'
$scope.link = 'click here to create a new index pattern'
} else{
if(response.data.count > 0){
$http.post('../api/getIndexPattern', request).then((response, error) => {
$scope.found = response.data.found;
$scope.count = response.data.hits.total;
$scope.found = $scope.count > 0 ? true : false;
$scope.indextarget = 'Index pattern ' + $scope.target
$scope.link = 'click here'
if($scope.found){
window.location.href=baseurl + "/goto/shorturl" + $scope.target
if($scope.count > 0){
patternId = response.data.hits.hits[0]._id
alert(patternId)
$http.post('../api/getShortUrl', request).then((response) => {
$scope.urlfound = response.data.found;
if($scope.urlfound){
window.location.href=baseurl + "/goto/shorturl" + $scope.target
}
if(typeof $scope.urlfound === 'undefined'){
var createUrlReq = {'timeFieldName': '@timestamp', 'title': patternId.substring(14)}
$http.post('../api/createShortUrl', createUrlReq).then((response) => {
window.location.href=baseurl + "/goto/shorturl" + $scope.target
});
}
});
}else{
$scope.message = 'does not exist'
$scope.createmessage = 'to create one'
Expand Down
7 changes: 2 additions & 5 deletions server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export default function (server) {
let request = {
index: '.kibana',
type: 'doc',
id: 'index-pattern:' + req.payload.title
body:JSON.parse('{"query": {"bool": {"must": [{"match_phrase": {"index-pattern.title": {"query": "'+req.payload.title+'"}}}]}},"_source": ""}')
};
callWithRequest(req,'get', request).then(function (response) {
callWithRequest(req,'search', request).then(function (response) {
reply(response);
},
function (error) {
Expand Down Expand Up @@ -83,8 +83,6 @@ export default function (server) {
id: 'url:shorturl' + req.payload.title
};
callWithRequest(req,'get', request).then(function (response) {
console.log(response)
console.log(response.found)
reply(response);
},
function (error) {
Expand All @@ -104,7 +102,6 @@ export default function (server) {
id: '_count'
};
callWithRequest(req,'get', request).then(function (response) {
console.log(response)
reply(response);
},
function (error) {
Expand Down

0 comments on commit 3af7dd8

Please sign in to comment.