forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] ML on Kibana Management: Add ability to pass a group ID filter t…
…o job management page (elastic#74533) (elastic#74713) * handle group id in url for anomaly detection * filter analytics list by group id. * handle list of groupIds * ensure analytics can handle jobid in url. rename util function * add tests for getSelectedIdFromUrl and getGroupQueryText * keep groupIds as array of strings and jobId as single string * fix tests and update types # Conflicts: # x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js
- Loading branch information
1 parent
11cbc12
commit 1fcea3d
Showing
10 changed files
with
160 additions
and
54 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
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
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
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
47 changes: 47 additions & 0 deletions
47
x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.test.ts
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,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getGroupQueryText, getSelectedIdFromUrl } from './utils'; | ||
|
||
describe('ML - Jobs List utils', () => { | ||
const jobId = 'test_job_id_1'; | ||
const jobIdUrl = `http://localhost:5601/aql/app/ml#/jobs?mlManagement=(jobId:${jobId})`; | ||
const groupIdOne = 'test_group_id_1'; | ||
const groupIdTwo = 'test_group_id_2'; | ||
const groupIdsUrl = `http://localhost:5601/aql/app/ml#/jobs?mlManagement=(groupIds:!(${groupIdOne},${groupIdTwo}))`; | ||
const groupIdUrl = `http://localhost:5601/aql/app/ml#/jobs?mlManagement=(groupIds:!(${groupIdOne}))`; | ||
|
||
describe('getSelectedIdFromUrl', () => { | ||
it('should get selected job id from the url', () => { | ||
const actual = getSelectedIdFromUrl(jobIdUrl); | ||
expect(actual).toStrictEqual({ jobId }); | ||
}); | ||
|
||
it('should get selected group ids from the url', () => { | ||
const expected = { groupIds: [groupIdOne, groupIdTwo] }; | ||
const actual = getSelectedIdFromUrl(groupIdsUrl); | ||
expect(actual).toStrictEqual(expected); | ||
}); | ||
|
||
it('should get selected group id from the url', () => { | ||
const expected = { groupIds: [groupIdOne] }; | ||
const actual = getSelectedIdFromUrl(groupIdUrl); | ||
expect(actual).toStrictEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('getGroupQueryText', () => { | ||
it('should get query string for selected group ids', () => { | ||
const actual = getGroupQueryText([groupIdOne, groupIdTwo]); | ||
expect(actual).toBe(`groups:(${groupIdOne} or ${groupIdTwo})`); | ||
}); | ||
|
||
it('should get query string for selected group id', () => { | ||
const actual = getGroupQueryText([groupIdOne]); | ||
expect(actual).toBe(`groups:(${groupIdOne})`); | ||
}); | ||
}); | ||
}); |
20 changes: 0 additions & 20 deletions
20
x-pack/plugins/ml/public/application/util/get_job_id_url.ts
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/ml/public/application/util/get_selected_ids_url.ts
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,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import rison from 'rison-node'; | ||
import { getBasePath } from './dependency_cache'; | ||
|
||
export enum TAB_IDS { | ||
DATA_FRAME_ANALYTICS = 'data_frame_analytics', | ||
ANOMALY_DETECTION = 'jobs', | ||
} | ||
|
||
function getSelectedIdsUrl(tabId: TAB_IDS, settings: { [key: string]: string | string[] }): string { | ||
// Create url for filtering by job id or group ids for kibana management table | ||
const encoded = rison.encode(settings); | ||
const url = `?mlManagement=${encoded}`; | ||
const basePath = getBasePath(); | ||
|
||
return `${basePath.get()}/app/ml#/${tabId}${url}`; | ||
} | ||
|
||
// Create url for filtering by group ids for kibana management table | ||
export function getGroupIdsUrl(tabId: TAB_IDS, ids: string[]): string { | ||
const settings = { | ||
groupIds: ids, | ||
}; | ||
|
||
return getSelectedIdsUrl(tabId, settings); | ||
} | ||
|
||
// Create url for filtering by job id for kibana management table | ||
export function getJobIdUrl(tabId: TAB_IDS, id: string): string { | ||
const settings = { | ||
jobId: id, | ||
}; | ||
|
||
return getSelectedIdsUrl(tabId, settings); | ||
} |