Skip to content

Commit

Permalink
cleanup and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Jun 26, 2018
1 parent 5fe4bfd commit c6e8925
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
55 changes: 26 additions & 29 deletions src/core_plugins/kibana/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ export function getUiSettingDefaults() {
'buildNum': {
readonly: true
},
'version': {
readonly: true
},
'query:queryString:options': {
name: 'Query string options',
value: '{ "analyze_wildcard": true }',
Expand Down Expand Up @@ -78,7 +75,7 @@ export function getUiSettingDefaults() {
name: 'Scaled date format',
type: 'json',
value:
`[
`[
["", "HH:mm:ss.SSS"],
["PT1S", "HH:mm:ss"],
["PT1M", "HH:mm"],
Expand Down Expand Up @@ -307,7 +304,7 @@ export function getUiSettingDefaults() {
'format:defaultTypeMap': {
name: 'Field type format name',
value:
`{
`{
"ip": { "id": "ip", "params": {} },
"date": { "id": "date", "params": {} },
"number": { "id": "number", "params": {} },
Expand Down Expand Up @@ -365,7 +362,7 @@ export function getUiSettingDefaults() {
'timepicker:timeDefaults': {
name: 'Time picker defaults',
value:
`{
`{
"from": "now-15m",
"to": "now",
"mode": "quick"
Expand All @@ -376,7 +373,7 @@ export function getUiSettingDefaults() {
'timepicker:refreshIntervalDefaults': {
name: 'Time picker refresh interval',
value:
`{
`{
"display": "Off",
"pause": false,
"value": 0
Expand All @@ -387,30 +384,30 @@ export function getUiSettingDefaults() {
'timepicker:quickRanges': {
name: 'Time picker quick ranges',
value: JSON.stringify([
{ from: 'now/d', to: 'now/d', display: 'Today', section: 0 },
{ from: 'now/w', to: 'now/w', display: 'This week', section: 0 },
{ from: 'now/M', to: 'now/M', display: 'This month', section: 0 },
{ from: 'now/y', to: 'now/y', display: 'This year', section: 0 },
{ from: 'now/d', to: 'now', display: 'Today so far', section: 0 },
{ from: 'now/w', to: 'now', display: 'Week to date', section: 0 },
{ from: 'now/M', to: 'now', display: 'Month to date', section: 0 },
{ from: 'now/y', to: 'now', display: 'Year to date', section: 0 },
{ from: 'now/d', to: 'now/d', display: 'Today', section: 0 },
{ from: 'now/w', to: 'now/w', display: 'This week', section: 0 },
{ from: 'now/M', to: 'now/M', display: 'This month', section: 0 },
{ from: 'now/y', to: 'now/y', display: 'This year', section: 0 },
{ from: 'now/d', to: 'now', display: 'Today so far', section: 0 },
{ from: 'now/w', to: 'now', display: 'Week to date', section: 0 },
{ from: 'now/M', to: 'now', display: 'Month to date', section: 0 },
{ from: 'now/y', to: 'now', display: 'Year to date', section: 0 },

{ from: 'now-15m', to: 'now', display: 'Last 15 minutes', section: 1 },
{ from: 'now-30m', to: 'now', display: 'Last 30 minutes', section: 1 },
{ from: 'now-1h', to: 'now', display: 'Last 1 hour', section: 1 },
{ from: 'now-4h', to: 'now', display: 'Last 4 hours', section: 1 },
{ from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 1 },
{ from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 1 },
{ from: 'now-7d', to: 'now', display: 'Last 7 days', section: 1 },
{ from: 'now-15m', to: 'now', display: 'Last 15 minutes', section: 1 },
{ from: 'now-30m', to: 'now', display: 'Last 30 minutes', section: 1 },
{ from: 'now-1h', to: 'now', display: 'Last 1 hour', section: 1 },
{ from: 'now-4h', to: 'now', display: 'Last 4 hours', section: 1 },
{ from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 1 },
{ from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 1 },
{ from: 'now-7d', to: 'now', display: 'Last 7 days', section: 1 },

{ from: 'now-30d', to: 'now', display: 'Last 30 days', section: 2 },
{ from: 'now-60d', to: 'now', display: 'Last 60 days', section: 2 },
{ from: 'now-90d', to: 'now', display: 'Last 90 days', section: 2 },
{ from: 'now-6M', to: 'now', display: 'Last 6 months', section: 2 },
{ from: 'now-1y', to: 'now', display: 'Last 1 year', section: 2 },
{ from: 'now-2y', to: 'now', display: 'Last 2 years', section: 2 },
{ from: 'now-5y', to: 'now', display: 'Last 5 years', section: 2 },
{ from: 'now-30d', to: 'now', display: 'Last 30 days', section: 2 },
{ from: 'now-60d', to: 'now', display: 'Last 60 days', section: 2 },
{ from: 'now-90d', to: 'now', display: 'Last 90 days', section: 2 },
{ from: 'now-6M', to: 'now', display: 'Last 6 months', section: 2 },
{ from: 'now-1y', to: 'now', display: 'Last 1 year', section: 2 },
{ from: 'now-2y', to: 'now', display: 'Last 2 years', section: 2 },
{ from: 'now-5y', to: 'now', display: 'Last 5 years', section: 2 },

], null, 2),
type: 'json',
Expand Down
8 changes: 7 additions & 1 deletion src/server/saved_objects/service/lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class SavedObjectsRepository {
* @param {object} [options={}]
* @property {string} [options.id] - force id on creation, not recommended
* @property {boolean} [options.overwrite=false]
* @property {object} [options.extraBodyProperties={}] - extra properties to append to the document body, outside of the object's type property
* @returns {promise} - { id, type, version, attributes }
*/
async create(type, attributes = {}, options = {}) {
Expand Down Expand Up @@ -210,6 +211,7 @@ export class SavedObjectsRepository {
* @property {string} [options.search]
* @property {Array<string>} [options.searchFields] - see Elasticsearch Simple Query String
* Query field argument for more information
* @property {object} [options.extraQueryParams] - ES Query parameters to merge/append into the generated query
* @property {integer} [options.page=1]
* @property {integer} [options.perPage=20]
* @property {string} [options.sortField]
Expand Down Expand Up @@ -295,7 +297,8 @@ export class SavedObjectsRepository {
* Returns an array of objects by id
*
* @param {array} objects - an array ids, or an array of objects containing id and optionally type
* @param {object} options
* @param {object} [options = {}]
* @param {array} [options.extraSourceProperties = []] - an array of extra properties to return from the underlying document
* @returns {promise} - { saved_objects: [{ id, type, version, attributes }] }
* @example
*
Expand Down Expand Up @@ -359,6 +362,8 @@ export class SavedObjectsRepository {
*
* @param {string} type
* @param {string} id
* @param {object} [options = {}]
* @param {array} [options.extraSourceProperties = []] - an array of extra properties to return from the underlying document
* @returns {promise} - { id, type, version, attributes }
*/
async get(type, id, options = {}) {
Expand Down Expand Up @@ -401,6 +406,7 @@ export class SavedObjectsRepository {
* @param {string} id
* @param {object} [options={}]
* @property {integer} options.version - ensures version matches that of persisted object
* @param {array} [options.extraBodyProperties = []] - an array of extra properties to write into the underlying document
* @returns {promise}
*/
async update(type, id, attributes, options = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function getFieldsForTypes(searchFields, types) {
* @param {(string|Array<string>)} type
* @param {String} search
* @param {Array<string>} searchFields
* @param {Object} extraQueryParams query parameters to merge into the result
* @return {Object}
*/
export function getQueryParams(mappings, type, search, searchFields, extraQueryParams = {}) {
Expand Down Expand Up @@ -94,12 +95,14 @@ export function getQueryParams(mappings, type, search, searchFields, extraQueryP
];
}

// a list of fields to manually merge together
const fieldsToMerge = ['filter', 'must'];

const extraParams = {
...extraQueryParams.bool
};

// Remove the manual merge fields from the collection of properties we will automatically combine.
fieldsToMerge.forEach(field => delete extraParams[field]);

let query = {
Expand Down

0 comments on commit c6e8925

Please sign in to comment.