2024-01-23 14:16:10 +00:00
|
|
|
import { IDeviceUserResponse } from "interfaces/host";
|
2025-03-07 18:28:07 +00:00
|
|
|
import { IListOptions } from "interfaces/list_options";
|
2025-09-05 22:53:01 +00:00
|
|
|
import { IDeviceSoftware, ISetupSoftwareStatus } from "interfaces/software";
|
2025-02-21 11:52:41 +00:00
|
|
|
import { IHostCertificate } from "interfaces/certificates";
|
2022-03-21 13:38:59 +00:00
|
|
|
import sendRequest from "services";
|
2022-04-22 16:45:35 +00:00
|
|
|
import endpoints from "utilities/endpoints";
|
2025-09-05 22:31:03 +00:00
|
|
|
import {
|
|
|
|
|
buildQueryStringFromParams,
|
|
|
|
|
getPathWithQueryParams,
|
|
|
|
|
} from "utilities/url";
|
2025-02-21 11:52:41 +00:00
|
|
|
|
2025-07-21 18:13:46 +00:00
|
|
|
import { IMdmCommandResult } from "interfaces/mdm";
|
|
|
|
|
|
2025-09-05 22:53:01 +00:00
|
|
|
import { createMockSetupSoftwareStatusesResponse } from "__mocks__/deviceUserMock";
|
|
|
|
|
|
2024-05-17 17:30:55 +00:00
|
|
|
import { IHostSoftwareQueryParams } from "./hosts";
|
2022-03-21 13:38:59 +00:00
|
|
|
|
2025-04-04 14:46:22 +00:00
|
|
|
export type ILoadHostDetailsExtension = "macadmins";
|
2022-03-21 13:38:59 +00:00
|
|
|
|
2024-05-17 17:30:55 +00:00
|
|
|
export interface IDeviceSoftwareQueryKey extends IHostSoftwareQueryParams {
|
|
|
|
|
scope: "device_software";
|
|
|
|
|
id: string;
|
2024-06-12 13:38:57 +00:00
|
|
|
softwareUpdatedAt?: string;
|
2024-05-17 17:30:55 +00:00
|
|
|
}
|
2024-05-10 15:18:24 +00:00
|
|
|
|
2024-05-09 21:44:50 +00:00
|
|
|
export interface IGetDeviceSoftwareResponse {
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
software: IDeviceSoftware[];
|
2024-05-15 12:55:27 +00:00
|
|
|
count: number;
|
2024-05-09 21:44:50 +00:00
|
|
|
meta: {
|
|
|
|
|
has_next_results: boolean;
|
|
|
|
|
has_previous_results: boolean;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-24 15:43:16 +00:00
|
|
|
interface IGetDeviceDetailsRequest {
|
|
|
|
|
token: string;
|
|
|
|
|
exclude_software?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-21 11:52:41 +00:00
|
|
|
export interface IGetDeviceCertificatesResponse {
|
|
|
|
|
certificates: IHostCertificate[];
|
|
|
|
|
meta: {
|
|
|
|
|
has_next_results: boolean;
|
|
|
|
|
has_previous_results: boolean;
|
|
|
|
|
};
|
2025-09-17 11:05:32 +00:00
|
|
|
count: number;
|
2025-02-21 11:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-07 18:28:07 +00:00
|
|
|
export interface IGetDeviceCertsRequestParams extends IListOptions {
|
|
|
|
|
token: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-21 18:13:46 +00:00
|
|
|
export interface IGetVppInstallCommandResultsResponse {
|
|
|
|
|
results: IMdmCommandResult[];
|
|
|
|
|
}
|
2025-09-05 22:53:01 +00:00
|
|
|
export interface IGetSetupSoftwareStatusesResponse {
|
2025-09-15 22:26:23 +00:00
|
|
|
setup_experience_results: { software?: ISetupSoftwareStatus[] };
|
2025-09-05 22:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IGetSetupSoftwareStatusesParams {
|
|
|
|
|
token: string;
|
|
|
|
|
}
|
2025-07-21 18:13:46 +00:00
|
|
|
|
2022-03-21 13:38:59 +00:00
|
|
|
export default {
|
2024-06-24 15:43:16 +00:00
|
|
|
loadHostDetails: ({
|
|
|
|
|
token,
|
|
|
|
|
exclude_software,
|
|
|
|
|
}: IGetDeviceDetailsRequest): Promise<IDeviceUserResponse> => {
|
2022-03-21 13:38:59 +00:00
|
|
|
const { DEVICE_USER_DETAILS } = endpoints;
|
2024-06-24 15:43:16 +00:00
|
|
|
let path = `${DEVICE_USER_DETAILS}/${token}`;
|
|
|
|
|
if (exclude_software) {
|
|
|
|
|
path += "?exclude_software=true";
|
|
|
|
|
}
|
2022-03-21 13:38:59 +00:00
|
|
|
return sendRequest("GET", path);
|
|
|
|
|
},
|
|
|
|
|
loadHostDetailsExtension: (
|
|
|
|
|
deviceAuthToken: string,
|
|
|
|
|
extension: ILoadHostDetailsExtension
|
|
|
|
|
) => {
|
|
|
|
|
const { DEVICE_USER_DETAILS } = endpoints;
|
|
|
|
|
const path = `${DEVICE_USER_DETAILS}/${deviceAuthToken}/${extension}`;
|
|
|
|
|
|
|
|
|
|
return sendRequest("GET", path);
|
|
|
|
|
},
|
|
|
|
|
refetch: (deviceAuthToken: string) => {
|
|
|
|
|
const { DEVICE_USER_DETAILS } = endpoints;
|
|
|
|
|
const path = `${DEVICE_USER_DETAILS}/${deviceAuthToken}/refetch`;
|
|
|
|
|
|
|
|
|
|
return sendRequest("POST", path);
|
|
|
|
|
},
|
2024-05-09 21:44:50 +00:00
|
|
|
|
|
|
|
|
getDeviceSoftware: (
|
2024-05-17 17:30:55 +00:00
|
|
|
params: IDeviceSoftwareQueryKey
|
2024-05-09 21:44:50 +00:00
|
|
|
): Promise<IGetDeviceSoftwareResponse> => {
|
|
|
|
|
const { DEVICE_SOFTWARE } = endpoints;
|
2024-05-17 17:30:55 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
const { id, scope, ...rest } = params;
|
2025-09-05 22:31:03 +00:00
|
|
|
|
|
|
|
|
const path = getPathWithQueryParams(DEVICE_SOFTWARE(id), rest);
|
|
|
|
|
return sendRequest("GET", path);
|
2024-05-09 21:44:50 +00:00
|
|
|
},
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
|
2025-09-05 22:31:03 +00:00
|
|
|
// getSoftwareIcon doesn't need its own service function because the logic is encapsulated in
|
|
|
|
|
// softwareAPI.getSoftwareIconFromApiUrl in /entities/software.ts
|
|
|
|
|
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
installSelfServiceSoftware: (
|
|
|
|
|
deviceToken: string,
|
|
|
|
|
softwareTitleId: number
|
|
|
|
|
) => {
|
|
|
|
|
const { DEVICE_SOFTWARE_INSTALL } = endpoints;
|
|
|
|
|
const path = DEVICE_SOFTWARE_INSTALL(deviceToken, softwareTitleId);
|
|
|
|
|
|
|
|
|
|
return sendRequest("POST", path);
|
|
|
|
|
},
|
2025-05-14 15:42:37 +00:00
|
|
|
|
|
|
|
|
uninstallSelfServiceSoftware: (
|
|
|
|
|
deviceToken: string,
|
|
|
|
|
softwareTitleId: number
|
|
|
|
|
) => {
|
|
|
|
|
const { DEVICE_SOFTWARE_UNINSTALL } = endpoints;
|
|
|
|
|
return sendRequest(
|
|
|
|
|
"POST",
|
|
|
|
|
DEVICE_SOFTWARE_UNINSTALL(deviceToken, softwareTitleId)
|
|
|
|
|
);
|
|
|
|
|
},
|
2025-02-21 11:52:41 +00:00
|
|
|
|
2025-04-30 14:02:09 +00:00
|
|
|
/** Gets more info on FMA/custom package install for device user */
|
|
|
|
|
getSoftwareInstallResult: (deviceToken: string, uuid: string) => {
|
|
|
|
|
const { DEVICE_SOFTWARE_INSTALL_RESULTS } = endpoints;
|
|
|
|
|
const path = DEVICE_SOFTWARE_INSTALL_RESULTS(deviceToken, uuid);
|
|
|
|
|
|
|
|
|
|
return sendRequest("GET", path);
|
|
|
|
|
},
|
|
|
|
|
|
2025-06-06 19:40:52 +00:00
|
|
|
/** Gets more info on FMA/custom package uninstall for device user */
|
|
|
|
|
getSoftwareUninstallResult: (
|
|
|
|
|
deviceToken: string,
|
|
|
|
|
scriptExecutionId: string
|
|
|
|
|
) => {
|
|
|
|
|
const { DEVICE_SOFTWARE_UNINSTALL_RESULTS } = endpoints;
|
|
|
|
|
const path = DEVICE_SOFTWARE_UNINSTALL_RESULTS(
|
|
|
|
|
deviceToken,
|
|
|
|
|
scriptExecutionId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return sendRequest("GET", path);
|
|
|
|
|
},
|
|
|
|
|
|
2025-04-30 14:02:09 +00:00
|
|
|
/** Gets more info on VPP install for device user */
|
2025-07-21 18:13:46 +00:00
|
|
|
getVppCommandResult: (
|
|
|
|
|
deviceToken: string,
|
|
|
|
|
uuid: string
|
|
|
|
|
): Promise<IGetVppInstallCommandResultsResponse> => {
|
2025-04-30 14:02:09 +00:00
|
|
|
const { DEVICE_VPP_COMMAND_RESULTS } = endpoints;
|
|
|
|
|
const path = DEVICE_VPP_COMMAND_RESULTS(deviceToken, uuid);
|
|
|
|
|
|
|
|
|
|
return sendRequest("GET", path);
|
|
|
|
|
},
|
|
|
|
|
|
2025-03-07 18:28:07 +00:00
|
|
|
getDeviceCertificates: ({
|
|
|
|
|
token,
|
|
|
|
|
page,
|
|
|
|
|
per_page,
|
|
|
|
|
order_key,
|
|
|
|
|
order_direction,
|
|
|
|
|
}: IGetDeviceCertsRequestParams): Promise<IGetDeviceCertificatesResponse> => {
|
2025-02-21 11:52:41 +00:00
|
|
|
const { DEVICE_CERTIFICATES } = endpoints;
|
2025-03-07 18:28:07 +00:00
|
|
|
const path = `${DEVICE_CERTIFICATES(token)}?${buildQueryStringFromParams({
|
2025-02-26 15:32:53 +00:00
|
|
|
page,
|
2025-03-07 18:28:07 +00:00
|
|
|
per_page,
|
|
|
|
|
order_key,
|
|
|
|
|
order_direction,
|
2025-02-26 15:32:53 +00:00
|
|
|
})}`;
|
2025-02-21 11:52:41 +00:00
|
|
|
|
2025-02-26 15:32:53 +00:00
|
|
|
return sendRequest("GET", path);
|
2025-02-21 11:52:41 +00:00
|
|
|
},
|
2025-09-05 22:53:01 +00:00
|
|
|
|
|
|
|
|
getSetupSoftwareStatuses: ({
|
|
|
|
|
token,
|
|
|
|
|
}: IGetSetupSoftwareStatusesParams): Promise<IGetSetupSoftwareStatusesResponse> => {
|
|
|
|
|
const { DEVICE_SETUP_SOFTWARE_STATUSES } = endpoints;
|
|
|
|
|
const path = DEVICE_SETUP_SOFTWARE_STATUSES(token);
|
|
|
|
|
return sendRequest("POST", path);
|
|
|
|
|
},
|
2022-03-21 13:38:59 +00:00
|
|
|
};
|