Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 131 additions & 9 deletions ui/admin/src/api/client/api.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/admin/src/api/client/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ShellHub Enterprise OpenAPI
* > NOTICE: THE API IS NOT STABLE YET; ERROR AND INCONSISTENCIES MAY OCCUR. ShellHub Enterprise OpenAPI specification. It documents all routes provided by ShellHub Enterprise.
*
* The version of the OpenAPI document: 0.18.0
* The version of the OpenAPI document: 0.19.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/src/api/client/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ShellHub Enterprise OpenAPI
* > NOTICE: THE API IS NOT STABLE YET; ERROR AND INCONSISTENCIES MAY OCCUR. ShellHub Enterprise OpenAPI specification. It documents all routes provided by ShellHub Enterprise.
*
* The version of the OpenAPI document: 0.18.0
* The version of the OpenAPI document: 0.19.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/src/api/client/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ShellHub Enterprise OpenAPI
* > NOTICE: THE API IS NOT STABLE YET; ERROR AND INCONSISTENCIES MAY OCCUR. ShellHub Enterprise OpenAPI specification. It documents all routes provided by ShellHub Enterprise.
*
* The version of the OpenAPI document: 0.18.0
* The version of the OpenAPI document: 0.19.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/src/api/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ShellHub Enterprise OpenAPI
* > NOTICE: THE API IS NOT STABLE YET; ERROR AND INCONSISTENCIES MAY OCCUR. ShellHub Enterprise OpenAPI specification. It documents all routes provided by ShellHub Enterprise.
*
* The version of the OpenAPI document: 0.18.0
* The version of the OpenAPI document: 0.19.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
9 changes: 7 additions & 2 deletions ui/admin/src/components/Namespace/NamespaceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{ namespace.name }}
</td>
<td>
{{ namespace.devices_count || 0 }}
{{ sumDevicesCount(namespace) }}
</td>
<td>
{{ namespace.tenant_id }}
Expand Down Expand Up @@ -59,6 +59,7 @@
import { computed, onMounted, ref, watch } from "vue";
import { useRouter } from "vue-router";
import useNamespacesStore from "@admin/store/modules/namespaces";
import { INamespace } from "@admin/interfaces/INamespace";
import useSnackbar from "@/helpers/snackbar";
import DataTable from "../DataTable.vue";
import NamespaceEdit from "./NamespaceEdit.vue";
Expand Down Expand Up @@ -114,7 +115,6 @@ onMounted(async () => {
});

const namespaces = computed(() => namespacesStore.list);

const numberOfNamespaces = computed(() => namespacesStore.getnumberOfNamespaces);

const goToNamespace = (namespace: string) => {
Expand Down Expand Up @@ -153,4 +153,9 @@ const changeItemsPerPage = async (newItemsPerPage: number) => {
watch(itemsPerPage, async () => {
await getNamespaces(itemsPerPage.value, page.value);
});

const sumDevicesCount = (namespace: INamespace) => {
const { devices_accepted_count: acceptedCount, devices_pending_count: pendingCount, devices_rejected_count: rejectedCount } = namespace;
return (acceptedCount + pendingCount + rejectedCount) || 0;
};
</script>
15 changes: 12 additions & 3 deletions ui/admin/src/hooks/namespaceExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getFilter = (option: NamespaceFilterOptions, numberOfDevices: number): IFi
{
type: "property",
params: {
name: "devices",
name: "devices_accepted_count",
operator: "gt",
value: numberOfDevices,
},
Expand All @@ -15,13 +15,22 @@ const getFilter = (option: NamespaceFilterOptions, numberOfDevices: number): IFi
[NamespaceFilterOptions.NoDevices]: [
{
type: "property",
params: { name: "devices", operator: "eq", value: 0 },
params: { name: "devices_accepted_count", operator: "eq", value: 0 },
},
{
type: "property",
params: { name: "devices_pending_count", operator: "eq", value: 0 },
},
{
type: "property",
params: { name: "devices_rejected_count", operator: "eq", value: 0 },
},
{ type: "operator", params: { name: "and" } },
],
[NamespaceFilterOptions.NoSessions]: [
{
type: "property",
params: { name: "devices", operator: "gt", value: 0 },
params: { name: "devices_accepted_count", operator: "gt", value: 0 },
},
{
type: "property",
Expand Down
4 changes: 3 additions & 1 deletion ui/admin/src/interfaces/INamespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ type Billing = {
export interface INamespace {
billing?: Billing;
created_at: string;
devices_count: number;
devices_accepted_count: number;
devices_pending_count: number;
devices_rejected_count: number;
max_devices: number;
members: Array<Members>;
name: string;
Expand Down
9 changes: 7 additions & 2 deletions ui/admin/src/views/NamespaceDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<div class="text-overline mt-3">
<h3>Devices:</h3>
</div>
<div :data-test="namespace.devices_count">
<p>{{ namespace.devices_count || 0 }}</p>
<div data-test="namespace-devices-count">
<p>{{ sumDevicesCount(namespace) }}</p>
</div>
</div>

Expand Down Expand Up @@ -113,6 +113,11 @@ const goToUser = (userId: string) => {
router.push({ name: "userDetails", params: { id: userId } });
};

const sumDevicesCount = (namespace: INamespace) => {
const { devices_accepted_count: acceptedCount, devices_pending_count: pendingCount, devices_rejected_count: rejectedCount } = namespace;
return (acceptedCount + pendingCount + rejectedCount) || 0;
};

defineExpose({ namespace });
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const namespace = {
subscription_id: "",
},
created_at: "2022-04-13T11:42:49.578Z",
devices_count: 2,
devices_accepted_count: 1,
devices_pending_count: 1,
devices_rejected_count: 0,
max_devices: 10,
members: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const namespaces: INamespace[] = [
subscription_id: "",
},
created_at: "2022-04-13T11:42:49.578Z",
devices_count: 2,
devices_accepted_count: 1,
devices_pending_count: 0,
devices_rejected_count: 1,
max_devices: 10,
members: [
{
Expand Down Expand Up @@ -53,7 +55,9 @@ const namespaces: INamespace[] = [
subscription_id: "",
},
created_at: "2022-04-13T11:42:49.578Z",
devices_count: 12,
devices_accepted_count: 10,
devices_pending_count: 2,
devices_rejected_count: 0,
max_devices: 100,
members: [
{
Expand Down
20 changes: 15 additions & 5 deletions ui/admin/tests/unit/store/modules/namespaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe("Namespaces Pinia Store", () => {
],
tenant_id: "a736a52b-5777-4f92-b0b8-e359bf484713",
created_at: "2023-01-01T00:00:00.000Z",
devices_count: 0,
devices_accepted_count: 0,
devices_pending_count: 0,
devices_rejected_count: 0,
max_devices: 10,
settings: {},
billing: undefined,
Expand All @@ -30,7 +32,9 @@ describe("Namespaces Pinia Store", () => {
],
tenant_id: "a736a52b-5777-4f92-b0b8-e359bf484714",
created_at: "2023-01-01T00:00:00.000Z",
devices_count: 1,
devices_accepted_count: 1,
devices_pending_count: 0,
devices_rejected_count: 0,
max_devices: 10,
settings: {},
billing: undefined,
Expand All @@ -45,7 +49,9 @@ describe("Namespaces Pinia Store", () => {
],
tenant_id: "a736a52b-5777-4f92-b0b8-e359bf484715",
created_at: "2023-01-01T00:00:00.000Z",
devices_count: 2,
devices_accepted_count: 1,
devices_pending_count: 1,
devices_rejected_count: 0,
max_devices: 10,
settings: {},
billing: undefined,
Expand All @@ -59,7 +65,9 @@ describe("Namespaces Pinia Store", () => {
],
tenant_id: "a736a52b-5777-4f92-b0b8-e359bf484716",
created_at: "2023-01-01T00:00:00.000Z",
devices_count: 3,
devices_accepted_count: 1,
devices_pending_count: 1,
devices_rejected_count: 1,
max_devices: 10,
settings: {},
billing: undefined,
Expand All @@ -76,7 +84,9 @@ describe("Namespaces Pinia Store", () => {
],
tenant_id: "a736a52b-5777-4f92-b0b8-e359bf484715",
created_at: "2023-01-01T00:00:00.000Z",
devices_count: 2,
devices_accepted_count: 1,
devices_pending_count: 1,
devices_rejected_count: 0,
max_devices: 10,
settings: {},
billing: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exports[`Namespace Details > Renders the component 1`] = `
<div data-v-1bdec118="" class="text-overline mt-3">
<h3 data-v-1bdec118="">Devices:</h3>
</div>
<div data-v-1bdec118="" data-test="1">
<div data-v-1bdec118="" data-test="namespace-devices-count">
<p data-v-1bdec118="">1</p>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions ui/admin/tests/unit/views/NamespaceDetails/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ const namespaceDetail: INamespace = {
session_record: true,
},
max_devices: 0,
devices_count: 1,
devices_accepted_count: 1,
devices_pending_count: 0,
devices_rejected_count: 0,
created_at: "2022-04-13T11:43:24.668Z",
billing: undefined,
};

const devicesCount = namespaceDetail.devices_accepted_count
+ namespaceDetail.devices_pending_count
+ namespaceDetail.devices_rejected_count;

const mockRoute = {
params: {
id: namespaceDetail.tenant_id,
Expand Down Expand Up @@ -84,7 +90,7 @@ describe("Namespace Details", () => {

it("Should render the props of the Namespace on screen", () => {
expect(wrapper.find(`[data-test='${namespaceDetail.name}']`).text()).toContain(namespaceDetail.name);
expect(wrapper.find(`[data-test='${namespaceDetail.devices_count}']`).text()).toContain(String(namespaceDetail.devices_count));
expect(wrapper.find('[data-test="namespace-devices-count"').text()).toContain(devicesCount);
expect(wrapper.find(`[data-test='${namespaceDetail.owner}']`).text()).toContain(namespaceDetail.owner);
expect(wrapper.find(`[data-test='${namespaceDetail.tenant_id}']`).text()).toContain(namespaceDetail.tenant_id);
expect(wrapper.find(`[data-test='${namespaceDetail.settings.session_record}']`).text())
Expand Down