mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
5cc6e5e445
## Addresses #11825 - [x] Add ChromeOS to Dashboard page: <img width="1365" alt="Screenshot 2023-06-02 at 4 01 12 AM" src="https://github.com/fleetdm/fleet/assets/61553566/e846c4b6-5fcb-4847-af05-67b2237ada39"> - [x] Add to platforms dropdown, confirm order of platform options, add route - [x] Hosts summary card - [x] Add responsiveness for <980px <img width="952" alt="Screenshot 2023-06-02 at 4 02 44 AM" src="https://github.com/fleetdm/fleet/assets/61553566/93662957-c590-40e0-876d-6ce4adabad2b"> - [x] TODO: Confirm label number of chrome hosts label - ask Juan on [this issue](https://github.com/fleetdm/fleet/issues/11829) - needed to call an API to get this id - [x] Missing hosts card (didn’t need any changes) - [x] Low disk space hosts card (Not supported) - [x] Operating systems card **Note for reviewers:** There is an API call happening from the HostsSummary component to get the id for the ChromeOS label needed for the URL to the filtered manage hosts page. This feature working properly depends on the response from that endpoint, which is WIP. UPDATE 6/5 - the endpoint is now working and being called correctly, though the id being returned is WIP (backend). No need to replace anything to test. ## Checklist for submitter - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
86 lines
2.1 KiB
TypeScript
86 lines
2.1 KiB
TypeScript
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
import sendRequest from "services";
|
|
import endpoints from "utilities/endpoints";
|
|
import helpers from "utilities/helpers";
|
|
import { ILabel, ILabelFormData, ILabelSummary } from "interfaces/label";
|
|
|
|
export interface ILabelsResponse {
|
|
labels: ILabel[];
|
|
}
|
|
|
|
export interface ILabelsSummaryResponse {
|
|
labels: ILabelSummary[];
|
|
}
|
|
|
|
export default {
|
|
create: async (formData: ILabelFormData) => {
|
|
const { LABELS } = endpoints;
|
|
|
|
try {
|
|
const { label: createdLabel } = await sendRequest(
|
|
"POST",
|
|
LABELS,
|
|
formData
|
|
);
|
|
|
|
return {
|
|
...createdLabel,
|
|
slug: helpers.labelSlug(createdLabel),
|
|
type: "custom",
|
|
};
|
|
} catch (error) {
|
|
console.error(error);
|
|
throw error;
|
|
}
|
|
},
|
|
destroy: (label: ILabel) => {
|
|
const { LABELS } = endpoints;
|
|
const path = `${LABELS}/id/${label.id}`;
|
|
|
|
return sendRequest("DELETE", path);
|
|
},
|
|
// TODO: confirm this still works
|
|
loadAll: async (): Promise<ILabelsResponse> => {
|
|
const { LABELS } = endpoints;
|
|
|
|
try {
|
|
const response = await sendRequest("GET", LABELS);
|
|
return Promise.resolve({ labels: helpers.formatLabelResponse(response) });
|
|
} catch (error) {
|
|
console.error(error);
|
|
return Promise.reject(error);
|
|
}
|
|
},
|
|
summary: (): Promise<ILabelsSummaryResponse> => {
|
|
const { LABELS } = endpoints;
|
|
const path = `${LABELS}/summary`;
|
|
|
|
return sendRequest("GET", path);
|
|
},
|
|
update: async (label: ILabel, updatedAttrs: ILabel) => {
|
|
const { LABELS } = endpoints;
|
|
const path = `${LABELS}/${label.id}`;
|
|
|
|
try {
|
|
const { label: updatedLabel } = await sendRequest(
|
|
"PATCH",
|
|
path,
|
|
updatedAttrs
|
|
);
|
|
return {
|
|
...updatedLabel,
|
|
slug: helpers.labelSlug(updatedLabel),
|
|
type: "custom",
|
|
};
|
|
} catch (error) {
|
|
console.error(error);
|
|
throw error;
|
|
}
|
|
},
|
|
specByName: (labelName: string) => {
|
|
const { LABEL_SPEC_BY_NAME } = endpoints;
|
|
const path = LABEL_SPEC_BY_NAME(labelName);
|
|
return sendRequest("GET", path);
|
|
},
|
|
};
|