mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
2adf3ce477
## Addresses #13470 - [x] Save query - [x] Add checkbox - [x] default unchecked - [x] If global setting is disabled (that is, "Disable query reports" is _enabled_) - [x] this box is disabled - [x] copy below is changed - [x] If enabled locally but globally disabled, box is checked and disabled - [x] If user clicks "Edit anyway", the normal checkbox state is restored, allowing them to edit it anyway., e.g. to prepare for enabling globally before doing so - [x] banner under [certain conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A9996&mode=design&t=XDBlQetD7kqdEdh9-1) - [x] 2 x update help text - [x] Edit query - [x] checkbox - [x] back button - [x] 2 x help text updates - [x] save changes modals when [conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A8745&mode=design&t=XDBlQetD7kqdEdh9-1) are met: - [x] changed SQL - [x] other - [x] Mange queries - update[ tooltip](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A10035&mode=design&t=ACwsj3wVdqzCXulq-1) - [x] Significant cleanup and improvement of styles and structure around the Edit Queries page <img width="854" alt="Screenshot 2023-10-05 at 3 44 05 PM" src="https://github.com/fleetdm/fleet/assets/61553566/9831570f-3c83-4e59-b040-649d52faa257"> <img width="854" alt="Screenshot 2023-10-05 at 3 44 15 PM" src="https://github.com/fleetdm/fleet/assets/61553566/dec76eba-46d1-4e43-87e9-e7fc44e84691"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 09 PM" src="https://github.com/fleetdm/fleet/assets/61553566/a7879b21-49b0-476a-81ab-6b465967510f"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 29 PM" src="https://github.com/fleetdm/fleet/assets/61553566/14a90d0a-2a52-4e59-8ee8-fb76fce55417"> <img width="1105" alt="Screenshot 2023-10-05 at 3 46 58 PM" src="https://github.com/fleetdm/fleet/assets/61553566/6c488fbe-4e5a-442b-8b62-2ddd15bda1fe"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 10 PM" src="https://github.com/fleetdm/fleet/assets/61553566/649534c5-d859-41f9-8c8a-6882b1dc2219"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 24 PM" src="https://github.com/fleetdm/fleet/assets/61553566/eaa0469c-a57a-474d-87bc-21cf2133dd3c"> ## Checklist for submitter - [x] Added/updated tests - [ ] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
130 lines
3.7 KiB
TypeScript
130 lines
3.7 KiB
TypeScript
import { IFormField } from "./form_field";
|
||
import { IPack } from "./pack";
|
||
import { SelectedPlatformString, SupportedPlatform } from "./platform";
|
||
|
||
// Query itself
|
||
export interface ISchedulableQuery {
|
||
created_at: string;
|
||
updated_at: string;
|
||
id: number;
|
||
name: string;
|
||
description: string;
|
||
query: string;
|
||
team_id: number | null;
|
||
interval: number;
|
||
platform: SelectedPlatformString; // Might more accurately be called `platforms_to_query` – comma-sepparated string of platforms to query, default all platforms if ommitted
|
||
min_osquery_version: string;
|
||
automations_enabled: boolean;
|
||
logging: QueryLoggingOption;
|
||
saved: boolean;
|
||
author_id: number;
|
||
author_name: string;
|
||
author_email: string;
|
||
observer_can_run: boolean;
|
||
discard_data: boolean;
|
||
packs: IPack[];
|
||
stats: ISchedulableQueryStats;
|
||
}
|
||
|
||
export interface IEnhancedQuery extends ISchedulableQuery {
|
||
performance: string;
|
||
platforms: SupportedPlatform[];
|
||
}
|
||
export interface ISchedulableQueryStats {
|
||
user_time_p50?: number;
|
||
user_time_p95?: number;
|
||
system_time_p50?: number;
|
||
system_time_p95?: number;
|
||
total_executions?: number;
|
||
}
|
||
|
||
// API shapes
|
||
|
||
// Get a query by id
|
||
/** GET /api/v1/fleet/queries/{id}` */
|
||
export interface IGetQueryResponse {
|
||
query: ISchedulableQuery;
|
||
}
|
||
|
||
// List global or team queries
|
||
/** GET /api/v1/fleet/queries?order_key={column_from_queries_table}&order_direction={asc|desc}&team_id={team_id} */
|
||
export interface IListQueriesResponse {
|
||
queries: ISchedulableQuery[];
|
||
}
|
||
|
||
export interface IQueryKeyQueriesLoadAll {
|
||
scope: "queries";
|
||
teamId: number | undefined;
|
||
}
|
||
// Create a new query
|
||
/** POST /api/v1/fleet/queries */
|
||
export interface ICreateQueryRequestBody {
|
||
name: string;
|
||
query: string;
|
||
description?: string;
|
||
observer_can_run?: boolean;
|
||
discard_data?: boolean;
|
||
team_id?: number; // global query if ommitted
|
||
interval?: number; // default 0 means never run
|
||
platform?: SelectedPlatformString; // Might more accurately be called `platforms_to_query` – comma-sepparated string of platforms to query, default all platforms if ommitted
|
||
min_osquery_version?: string; // default all versions if ommitted
|
||
automations_enabled?: boolean; // whether to send data to the configured log destination according to the query's `interval`. Default false if ommitted.
|
||
logging?: QueryLoggingOption;
|
||
}
|
||
|
||
// response is ISchedulableQuery
|
||
|
||
// Modify a query by id
|
||
/** PATCH /api/v1/fleet/queries/{id} */
|
||
export interface IModifyQueryRequestBody
|
||
extends Omit<ICreateQueryRequestBody, "name" | "query"> {
|
||
id?: number;
|
||
name?: string;
|
||
query?: string;
|
||
description?: string;
|
||
observer_can_run?: boolean;
|
||
discard_data?: boolean;
|
||
frequency?: number;
|
||
platform?: SelectedPlatformString;
|
||
min_osquery_version?: string;
|
||
}
|
||
|
||
// response is ISchedulableQuery // better way to indicate this?
|
||
|
||
// Delete a query by name
|
||
/** DELETE /api/v1/fleet/queries/{name} */
|
||
export interface IDeleteQueryRequestBody {
|
||
team_id?: number; // searches for a global query if omitted
|
||
}
|
||
|
||
// Delete a query by id
|
||
// DELETE /api/v1/fleet/queries/id/{id}
|
||
// (no body)
|
||
|
||
// Delete queries by id
|
||
/** POST /api/v1/fleet/queries/delete */
|
||
export interface IDeleteQueriesRequestBody {
|
||
ids: number[];
|
||
}
|
||
|
||
export interface IDeleteQueriesResponse {
|
||
deleted: number; // number of queries deleted
|
||
}
|
||
|
||
export interface IEditQueryFormFields {
|
||
name: IFormField<string>;
|
||
description: IFormField<string>;
|
||
query: IFormField<string>;
|
||
observer_can_run: IFormField<boolean>;
|
||
discard_data: IFormField<boolean>;
|
||
frequency: IFormField<number>;
|
||
platforms: IFormField<SelectedPlatformString>;
|
||
min_osquery_version: IFormField<string>;
|
||
logging: IFormField<QueryLoggingOption>;
|
||
}
|
||
|
||
export type QueryLoggingOption =
|
||
| "snapshot"
|
||
| "differential"
|
||
| "differential_ignore_removals";
|