-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked the examples app to be a better example of how other apps co…
…uld be formatted
- Loading branch information
Spencer Alger
committed
Feb 24, 2014
1 parent
b2b5db4
commit 193f4f9
Showing
21 changed files
with
6,283 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
.DS_Store | ||
node_modules | ||
src/kibana/styles/*.css | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
define(function (require) { | ||
|
||
require('css!./styles/main.css'); | ||
|
||
}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
define(function (require) { | ||
|
||
require('css!./styles/main.css'); | ||
|
||
}); |
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div ng-controller="examples"> | ||
<div ng-controller="examples" id="examples"> | ||
<ul class="nav nav-tabs"> | ||
<li ng-repeat="example in examples" ng-class="{ active: active === example }"> | ||
<a ng-click="makeActive(example)">{{example}}</a> | ||
</li> | ||
</ul> | ||
<div ng-include="activeUrl" onload="exampleLoaded()" ></div> | ||
<ng-include src="activeUrl" onload="exampleLoaded()" ></ng-include> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,135 +1,145 @@ | ||
define(function (require) { | ||
var angular = require('angular'); | ||
var kibana = require('kibana'); | ||
|
||
angular | ||
.module('kibana/controllers') | ||
.controller('examples', function ($scope, $location, courier) { | ||
$scope.examples = [ | ||
'config', | ||
'mapper', | ||
'courier' | ||
]; | ||
require('css!./styles/index.css'); | ||
|
||
$scope.makeActive = function (example) { | ||
$scope.active = example; | ||
$scope.activeUrl = 'kibana/apps/examples/partials/' + example + '.html'; | ||
}; | ||
var app = angular.module('app/examples', []); | ||
kibana.useModule(app); | ||
|
||
$scope.exampleLoaded = function () { | ||
if ($scope.active !== 'config') { | ||
courier.fetch(); | ||
} | ||
}; | ||
}); | ||
// main controller for the examples | ||
app.controller('examples', function ($scope, $location, courier) { | ||
$scope.examples = [ | ||
'config', | ||
'mapper', | ||
'courier' | ||
]; | ||
|
||
angular | ||
.module('kibana/directives') | ||
.directive('configTest', function () { | ||
return { | ||
restrict: 'E', | ||
template: 'My favorite number is {{favoriteNum}} <button ng-click="click()">New Favorite</button>', | ||
controller: function ($scope, config) { | ||
config.$bind($scope, 'favoriteNum', { | ||
default: 0 | ||
$scope.makeActive = function (example) { | ||
$scope.active = example; | ||
$scope.activeUrl = 'kibana/apps/examples/partials/' + example + '.html'; | ||
}; | ||
|
||
$scope.exampleLoaded = function () { | ||
if ($scope.active !== 'config') { | ||
courier.fetch(); | ||
} | ||
}; | ||
}); | ||
|
||
// verify that config can be used, that it is stored, and that changes to it can be seen across tabs | ||
app.directive('configExample', function () { | ||
return { | ||
restrict: 'E', | ||
template: 'My favorite number is {{favoriteNum}} <button ng-click="click()">New Favorite</button>', | ||
controller: function ($scope, config) { | ||
config.$bind($scope, 'favoriteNum', { | ||
default: 0 | ||
}); | ||
|
||
$scope.click = function () { | ||
$scope.favoriteNum++; | ||
}; | ||
} | ||
}; | ||
}); | ||
|
||
// verify that a search can be created and it will automatically fetch results | ||
app.directive('courierExample', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
type: '@' | ||
}, | ||
template: '<strong style="float:left">{{count}} : </strong><pre>{{json}}</pre>', | ||
controller: function ($scope, courier) { | ||
$scope.count = 0; | ||
var source = courier.rootSearchSource.extend() | ||
.type($scope.type) | ||
.source({ | ||
include: 'country' | ||
}) | ||
.$scope($scope) | ||
.on('results', function (resp) { | ||
$scope.count ++; | ||
$scope.json = JSON.stringify(resp.hits, null, ' '); | ||
}); | ||
} | ||
}; | ||
}); | ||
|
||
$scope.click = function () { | ||
$scope.favoriteNum++; | ||
}; | ||
} | ||
}; | ||
}) | ||
.directive('courierTest', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
type: '@' | ||
}, | ||
template: '<strong style="float:left">{{count}} : </strong><pre>{{json}}</pre>', | ||
controller: function ($scope, courier) { | ||
$scope.count = 0; | ||
var source = courier.rootSearchSource.extend() | ||
.type($scope.type) | ||
.source({ | ||
include: 'country' | ||
}) | ||
.$scope($scope) | ||
.on('results', function (resp) { | ||
$scope.count ++; | ||
$scope.json = JSON.stringify(resp.hits, null, ' '); | ||
}); | ||
} | ||
}; | ||
}) | ||
.directive('courierDocTest', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
id: '@', | ||
type: '@', | ||
index: '@' | ||
}, | ||
template: '<strong style="float:left">{{count}} : <button ng-click="click()">reindex</button> : </strong><pre>{{json}}</pre>', | ||
controller: function (courier, $scope) { | ||
$scope.count = 0; | ||
var currentSource; | ||
$scope.click = function () { | ||
if (currentSource) { | ||
source.doIndex(currentSource); | ||
} | ||
}; | ||
var source = courier.createSource('doc') | ||
.id($scope.id) | ||
.type($scope.type) | ||
.index($scope.index) | ||
.$scope($scope) | ||
.on('results', function (doc) { | ||
currentSource = doc._source; | ||
$scope.count ++; | ||
$scope.json = JSON.stringify(doc, null, ' '); | ||
}); | ||
} | ||
}; | ||
}) | ||
.directive('mappingTest', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
type: '@', | ||
fields: '@' | ||
}, | ||
template: 'Mappings:<br><div ng-repeat="(name,mapping) in mappedFields">{{name}} = {{mapping.type}}</div><hr>' + | ||
'<strong style="float:left">{{count}} : </strong><pre>{{json}}</pre>', | ||
controller: function ($rootScope, $scope, courier) { | ||
$scope.count = 0; | ||
$scope.mappedFields = {}; | ||
// verify that a doc can be fetched, and it will be updated across tabs | ||
app.directive('courierDocExample', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
id: '@', | ||
type: '@', | ||
index: '@' | ||
}, | ||
template: '<strong style="float:left">{{count}} : <button ng-click="click()">reindex</button> : </strong><pre>{{json}}</pre>', | ||
controller: function (courier, $scope) { | ||
$scope.count = 0; | ||
var currentSource; | ||
$scope.click = function () { | ||
if (currentSource) { | ||
source.doIndex(currentSource); | ||
} | ||
}; | ||
var source = courier.createSource('doc') | ||
.id($scope.id) | ||
.type($scope.type) | ||
.index($scope.index) | ||
.$scope($scope) | ||
.on('results', function (doc) { | ||
currentSource = doc._source; | ||
$scope.count ++; | ||
$scope.json = JSON.stringify(doc, null, ' '); | ||
}); | ||
} | ||
}; | ||
}); | ||
|
||
var source = courier.rootSearchSource.extend() | ||
.index('logstash-*') | ||
.type($scope.type) | ||
.source({ | ||
include: 'geo' | ||
}) | ||
.$scope($scope) | ||
.on('results', function (resp) { | ||
$scope.count ++; | ||
$scope.json = JSON.stringify(resp.hits, null, ' '); | ||
}); | ||
// fetch the mapping for an index pattern | ||
app.directive('mappingExample', function () { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
type: '@', | ||
fields: '@' | ||
}, | ||
template: 'Mappings:<br><div ng-repeat="(name,mapping) in mappedFields">{{name}} = {{mapping.type}}</div><hr>' + | ||
'<strong style="float:left">{{count}} : </strong><pre>{{json}}</pre>', | ||
controller: function ($rootScope, $scope, courier) { | ||
$scope.count = 0; | ||
$scope.mappedFields = {}; | ||
|
||
var fields = $scope.fields.split(','); | ||
var source = courier.rootSearchSource.extend() | ||
.index('logstash-*') | ||
.type($scope.type) | ||
.source({ | ||
include: 'geo' | ||
}) | ||
.$scope($scope) | ||
.on('results', function (resp) { | ||
$scope.count ++; | ||
$scope.json = JSON.stringify(resp.hits, null, ' '); | ||
}); | ||
|
||
fields.forEach(function (field) { | ||
courier._mapper.getFieldMapping(source, field, function (err, mapping) { | ||
$scope.$apply(function () { | ||
$scope.mappedFields[field] = mapping; | ||
}); | ||
var fields = $scope.fields.split(','); | ||
|
||
fields.forEach(function (field) { | ||
courier._mapper.getFieldMapping(source, field, function (err, mapping) { | ||
$scope.$apply(function () { | ||
$scope.mappedFields[field] = mapping; | ||
}); | ||
}); | ||
}); | ||
|
||
courier._mapper.getFields(source, function (err, response, status) { | ||
console.log(response); | ||
}); | ||
} | ||
}; | ||
}); | ||
courier._mapper.getFields(source, function (err, response, status) { | ||
console.log(response); | ||
}); | ||
} | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<config-test></config-test> | ||
<config-example></config-example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<courier-doc-test index="logstash-2014.02.11" type="apache" id="6434"></courier-doc-test> | ||
<courier-doc-test index="logstash-2014.02.11" type="apache" id="6434"></courier-doc-test> | ||
<courier-test type="apache" fields="extension,response,request"></courier-test> | ||
<courier-doc-example index="logstash-2014.02.11" type="apache" id="6434"></courier-doc-example> | ||
<courier-doc-example index="logstash-2014.02.11" type="apache" id="6434"></courier-doc-example> | ||
<courier-example type="apache" fields="extension,response,request"></courier-example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<mapping-test type="apache" fields="extension,response,request"></mapping-test> | ||
<mapping-example type="apache" fields="extension,response,request"></mapping-example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#examples ng-include { | ||
display: block; | ||
margin: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#examples ng-include { | ||
display: block; | ||
margin: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
define(function (require) { | ||
|
||
require('css!./styles/main.css'); | ||
|
||
}); |
Empty file.
Empty file.
Oops, something went wrong.