1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-21 21:33:18 +01:00

feat: adds labels to fuzzy search dialog (#2649)

This commit is contained in:
Amir Raminfar
2024-01-04 07:47:51 -08:00
committed by GitHub
parent ee4f94ce2e
commit a4026e16e8
7 changed files with 22 additions and 15 deletions

View File

@@ -58,22 +58,24 @@ const store = useContainerStore();
const { containers } = storeToRefs(store);
const list = computed(() => {
return containers.value.map(({ id, created, name, state, hostLabel: host }) => {
return containers.value.map(({ id, created, name, state, labels, hostLabel: host }) => {
return {
id,
created,
name,
state,
host,
labels: Object.entries(labels).map(([_, value]) => value),
};
});
});
const { results } = useFuse(query, list, {
fuseOptions: {
keys: ["name", "host"],
keys: ["name", "host", "labels"],
includeScore: true,
useExtendedSearch: true,
threshold: 0.3,
},
resultLimit,
matchAllWhenSearchEmpty: true,

View File

@@ -18,7 +18,7 @@ describe("Container", () => {
];
test.each(names)("name %s should be %s and %s", (name, expectedName, expectedSwarmId) => {
const c = new Container("id", new Date(), "image", name!, "command", "host", "status", "created");
const c = new Container("id", new Date(), "image", name!, "command", "host", {}, "status", "created");
expect(c.name).toBe(expectedName);
expect(c.swarmId).toBe(expectedSwarmId);
});

View File

@@ -31,6 +31,7 @@ export class Container {
public readonly name: string,
public readonly command: string,
public readonly host: string,
public readonly labels = {} as Record<string, string>,
public status: string,
public state: ContainerState,
public health?: ContainerHealth,

View File

@@ -124,6 +124,7 @@ export const useContainerStore = defineStore("container", () => {
c.name,
c.command,
c.host,
c.labels,
c.status,
c.state,
c.health,

View File

@@ -14,6 +14,7 @@ export type ContainerJson = {
readonly status: string;
readonly state: ContainerState;
readonly host: string;
readonly labels: Record<string, string>;
readonly health?: ContainerHealth;
};

View File

@@ -190,6 +190,7 @@ func (d *Client) ListContainers() ([]Container, error) {
Status: c.Status,
Host: d.host.ID,
Health: findBetweenParentheses(c.Status),
Labels: c.Labels,
}
containers = append(containers, container)
}

View File

@@ -6,18 +6,19 @@ import (
// Container represents an internal representation of docker containers
type Container struct {
ID string `json:"id"`
Names []string `json:"names"`
Name string `json:"name"`
Image string `json:"image"`
ImageID string `json:"imageId"`
Command string `json:"command"`
Created int64 `json:"created"`
State string `json:"state"`
Status string `json:"status"`
Health string `json:"health,omitempty"`
Host string `json:"host,omitempty"`
Tty bool `json:"-"`
ID string `json:"id"`
Names []string `json:"names"`
Name string `json:"name"`
Image string `json:"image"`
ImageID string `json:"imageId"`
Command string `json:"command"`
Created int64 `json:"created"`
State string `json:"state"`
Status string `json:"status"`
Health string `json:"health,omitempty"`
Host string `json:"host,omitempty"`
Tty bool `json:"-"`
Labels map[string]string `json:"labels,omitempty"`
}
// ContainerStat represent stats instant for a container