Skip to content

Commit f692f92

Browse files
committed
Refactor serviceControlStore to be a rest client instead
1 parent 6fb9a65 commit f692f92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+218
-317
lines changed

src/Frontend/src/components/AutoRefreshDataView.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { onMounted, onUnmounted, ref, watch } from "vue";
33
import ItemsPerPage from "@/components/ItemsPerPage.vue";
44
import PaginationStrip from "@/components/PaginationStrip.vue";
55
import type DataViewPageModel from "./DataViewPageModel";
6-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
6+
import serviceControlClient from "@/components/serviceControlClient";
77
88
const props = withDefaults(
99
defineProps<{
@@ -20,8 +20,6 @@ const props = withDefaults(
2020
let refreshTimer: number | undefined;
2121
const viewModel = defineModel<DataViewPageModel<T>>({ required: true });
2222
23-
const store = useServiceControlStore();
24-
2523
const pageNumber = ref(1);
2624
const itemsPerPage = ref(props.itemsPerPage);
2725
@@ -37,7 +35,7 @@ watch(itemsPerPage, () => loadData());
3735
watch(pageNumber, () => loadData());
3836
3937
async function loadData() {
40-
const [response, data] = await store.fetchTypedFromServiceControl<T[]>(`${props.apiUrl}?page=${pageNumber.value}&per_page=${itemsPerPage.value}`);
38+
const [response, data] = await serviceControlClient.fetchTypedFromServiceControl<T[]>(`${props.apiUrl}?page=${pageNumber.value}&per_page=${itemsPerPage.value}`);
4139
if (response.ok) {
4240
viewModel.value.totalCount = parseInt(response.headers.get("Total-Count") ?? "0");
4341
viewModel.value.data = data;

src/Frontend/src/components/BackendChecksNotifications.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { useShowToast } from "@/composables/toast";
77
import { TYPE } from "vue-toastification";
88
import useConnectionsAndStatsAutoRefresh from "@/composables/useConnectionsAndStatsAutoRefresh";
99
import useEnvironmentAndVersionsAutoRefresh from "@/composables/useEnvironmentAndVersionsAutoRefresh";
10-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
11-
import { storeToRefs } from "pinia";
10+
import serviceControlClient from "@/components/serviceControlClient";
1211
import monitoringClient from "./monitoring/monitoringClient";
1312
1413
const router = useRouter();
@@ -17,8 +16,6 @@ const connectionState = connectionStore.connectionState;
1716
const monitoringConnectionState = connectionStore.monitoringConnectionState;
1817
const { store: environmentStore } = useEnvironmentAndVersionsAutoRefresh();
1918
const environment = environmentStore.environment;
20-
const serviceControlStore = useServiceControlStore();
21-
const { serviceControlUrl } = storeToRefs(serviceControlStore);
2219
const primaryConnectionFailure = computed(() => connectionState.unableToConnect);
2320
const monitoringConnectionFailure = computed(() => monitoringConnectionState.unableToConnect);
2421
@@ -27,9 +24,9 @@ watch(primaryConnectionFailure, (newValue, oldValue) => {
2724
if (newValue !== oldValue && !(oldValue === null && newValue === false)) {
2825
const connectionUrl = router.resolve(routeLinks.configuration.connections.link).href;
2926
if (newValue) {
30-
useShowToast(TYPE.ERROR, "Error", `Could not connect to ServiceControl at ${serviceControlUrl.value}. <a class="btn btn-default" href="${connectionUrl}">View connection settings</a>`);
27+
useShowToast(TYPE.ERROR, "Error", `Could not connect to ServiceControl at ${serviceControlClient.url}. <a class="btn btn-default" href="${connectionUrl}">View connection settings</a>`);
3128
} else {
32-
useShowToast(TYPE.SUCCESS, "Success", `Connection to ServiceControl was successful at ${serviceControlUrl.value}.`);
29+
useShowToast(TYPE.SUCCESS, "Success", `Connection to ServiceControl was successful at ${serviceControlClient.url}.`);
3330
}
3431
}
3532
});

src/Frontend/src/components/PageFooter.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import FAIcon from "@/components/FAIcon.vue";
66
import { faArrowTurnUp, faPlus } from "@fortawesome/free-solid-svg-icons";
77
import useConnectionsAndStatsAutoRefresh from "@/composables/useConnectionsAndStatsAutoRefresh";
88
import useEnvironmentAndVersionsAutoRefresh from "@/composables/useEnvironmentAndVersionsAutoRefresh";
9-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
9+
import serviceControlClient from "@/components/serviceControlClient";
1010
import { storeToRefs } from "pinia";
1111
import { useConfigurationStore } from "@/stores/ConfigurationStore";
1212
import { useLicenseStore } from "@/stores/LicenseStore";
@@ -18,14 +18,12 @@ const monitoringConnectionState = connectionStore.monitoringConnectionState;
1818
const { store: environmentAndVersionsStore } = useEnvironmentAndVersionsAutoRefresh();
1919
const newVersions = environmentAndVersionsStore.newVersions;
2020
const environment = environmentAndVersionsStore.environment;
21-
const serviceControlStore = useServiceControlStore();
22-
const { serviceControlUrl } = storeToRefs(serviceControlStore);
2321
const licenseStore = useLicenseStore();
2422
const { licenseStatus, license } = licenseStore;
2523
const isMonitoringEnabled = monitoringClient.isMonitoringEnabled;
2624
2725
const scAddressTooltip = computed(() => {
28-
return `ServiceControl URL ${serviceControlUrl.value}`;
26+
return `ServiceControl URL ${serviceControlClient.url}`;
2927
});
3028
3129
const scMonitoringAddressTooltip = computed(() => {

src/Frontend/src/components/ServiceControlAvailable.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
import ConditionalRender from "@/components/ConditionalRender.vue";
33
import routeLinks from "@/router/routeLinks";
44
import useConnectionsAndStatsAutoRefresh from "@/composables/useConnectionsAndStatsAutoRefresh";
5-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
6-
import { storeToRefs } from "pinia";
5+
import serviceControlClient from "@/components/serviceControlClient";
76
87
const { store: connectionStore } = useConnectionsAndStatsAutoRefresh();
98
const connectionState = connectionStore.connectionState;
10-
const serviceControlStore = useServiceControlStore();
11-
const { serviceControlUrl } = storeToRefs(serviceControlStore);
129
</script>
1310

1411
<template>
@@ -19,7 +16,7 @@ const { serviceControlUrl } = storeToRefs(serviceControlStore);
1916
<h1>Cannot connect to ServiceControl</h1>
2017
<p>
2118
ServicePulse is unable to connect to the ServiceControl instance at
22-
<span id="serviceControlUrl">{{ serviceControlUrl }}</span
19+
<span id="serviceControlUrl">{{ serviceControlClient.url }}</span
2320
>. Please ensure that ServiceControl is running and accessible from your machine.
2421
</p>
2522
<div class="action-toolbar">

src/Frontend/src/components/configuration/EndpointConnection.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { onMounted, ref } from "vue";
33
import LicenseNotExpired from "../LicenseNotExpired.vue";
44
import ServiceControlAvailable from "../ServiceControlAvailable.vue";
55
import CodeEditor from "@/components/CodeEditor.vue";
6-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
7-
import { storeToRefs } from "pinia";
6+
import serviceControlClient from "@/components/serviceControlClient";
87
import LoadingSpinner from "../LoadingSpinner.vue";
98
import monitoringClient, { MetricsConnectionDetails } from "../monitoring/monitoringClient";
109
@@ -13,9 +12,6 @@ interface ServiceControlInstanceConnection {
1312
errors: string[];
1413
}
1514
16-
const serviceControlStore = useServiceControlStore();
17-
const { serviceControlUrl } = storeToRefs(serviceControlStore);
18-
1915
const loading = ref(true);
2016
const showCodeOnlyTab = ref(true);
2117
const jsonSnippet = ref("");
@@ -88,10 +84,10 @@ async function serviceControlConnections() {
8884
8985
async function getServiceControlConnection() {
9086
try {
91-
const [, data] = await serviceControlStore.fetchTypedFromServiceControl<ServiceControlInstanceConnection>("connection");
87+
const [, data] = await serviceControlClient.fetchTypedFromServiceControl<ServiceControlInstanceConnection>("connection");
9288
return data;
9389
} catch {
94-
return { errors: [`Error reaching ServiceControl at ${serviceControlUrl.value} connection`] } as ServiceControlInstanceConnection;
90+
return { errors: [`Error reaching ServiceControl at ${serviceControlClient.url} connection`] } as ServiceControlInstanceConnection;
9591
}
9692
}
9793
</script>

src/Frontend/src/components/configuration/PlatformConnections.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ import { ref } from "vue";
33
import { faCheck, faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
44
import FAIcon from "@/components/FAIcon.vue";
55
import useConnectionsAndStatsAutoRefresh from "@/composables/useConnectionsAndStatsAutoRefresh";
6-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
6+
import serviceControlClient from "@/components/serviceControlClient";
77
import monitoringClient from "../monitoring/monitoringClient";
88
99
const { store: connectionStore } = useConnectionsAndStatsAutoRefresh();
1010
const connectionState = connectionStore.connectionState;
1111
const monitoringConnectionState = connectionStore.monitoringConnectionState;
1212
13-
const serviceControlStore = useServiceControlStore();
14-
serviceControlStore.refresh();
15-
const localServiceControlUrl = ref(serviceControlStore.serviceControlUrl);
13+
const localServiceControlUrl = ref(serviceControlClient.url);
1614
const localMonitoringUrl = ref(monitoringClient.url);
1715
const isMonitoringDisabled = monitoringClient.isMonitoringDisabled;
1816
const testingServiceControl = ref(false);

src/Frontend/src/components/configuration/RetryRedirects.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import FAIcon from "@/components/FAIcon.vue";
1313
import ActionButton from "@/components/ActionButton.vue";
1414
import { faClock } from "@fortawesome/free-regular-svg-icons";
1515
import useEnvironmentAndVersionsAutoRefresh from "@/composables/useEnvironmentAndVersionsAutoRefresh";
16-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
16+
import serviceControlClient from "@/components/serviceControlClient";
1717
import { useRedirectsStore } from "@/stores/RedirectsStore";
1818
import LoadingSpinner from "../LoadingSpinner.vue";
1919
2020
const { store: environmentStore } = useEnvironmentAndVersionsAutoRefresh();
2121
const hasResponseStatusInHeader = environmentStore.serviceControlIsGreaterThan("5.2.0");
22-
const serviceControlStore = useServiceControlStore();
22+
2323
const redirectsStore = useRedirectsStore();
2424
2525
const loadingData = ref(true);
@@ -64,7 +64,7 @@ async function saveUpdatedRedirect(redirect: RetryRedirect) {
6464
redirectSaveSuccessful.value = null;
6565
showEdit.value = false;
6666
const result = handleResponse(
67-
await serviceControlStore.putToServiceControl(`redirects/${redirect.redirectId}`, {
67+
await serviceControlClient.putToServiceControl(`redirects/${redirect.redirectId}`, {
6868
id: redirect.redirectId,
6969
fromphysicaladdress: redirect.sourceQueue,
7070
tophysicaladdress: redirect.targetQueue,
@@ -93,7 +93,7 @@ async function saveCreatedRedirect(redirect: RetryRedirect) {
9393
redirectSaveSuccessful.value = null;
9494
showEdit.value = false;
9595
const result = handleResponse(
96-
await serviceControlStore.postToServiceControl("redirects", {
96+
await serviceControlClient.postToServiceControl("redirects", {
9797
fromphysicaladdress: redirect.sourceQueue,
9898
tophysicaladdress: redirect.targetQueue,
9999
})
@@ -121,7 +121,7 @@ function deleteRedirect(redirect: Redirect) {
121121
}
122122
123123
async function saveDeletedRedirect() {
124-
const result = handleResponse(await serviceControlStore.deleteFromServiceControl(`redirects/${selectedRedirect.value.message_redirect_id}`));
124+
const result = handleResponse(await serviceControlClient.deleteFromServiceControl(`redirects/${selectedRedirect.value.message_redirect_id}`));
125125
if (result.message === "success") {
126126
redirectSaveSuccessful.value = true;
127127
useShowToast(TYPE.INFO, "Info", "Redirect deleted");

src/Frontend/src/components/failedmessages/DeletedMessageGroups.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import MetadataItem from "@/components/MetadataItem.vue";
1616
import ActionButton from "@/components/ActionButton.vue";
1717
import { faArrowRotateRight, faEnvelope } from "@fortawesome/free-solid-svg-icons";
1818
import { faClock } from "@fortawesome/free-regular-svg-icons";
19-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
19+
import serviceControlClient from "@/components/serviceControlClient";
2020
2121
const statusesForRestoreOperation = ["restorestarted", "restoreprogressing", "restorefinalizing", "restorecompleted"] as const;
2222
type RestoreOperationStatus = (typeof statusesForRestoreOperation)[number];
@@ -55,15 +55,14 @@ const router = useRouter();
5555
const showRestoreGroupModal = ref(false);
5656
const selectedGroup = ref<ExtendedFailureGroupView>();
5757
58-
const serviceControlStore = useServiceControlStore();
5958
const messageGroupClient = createMessageGroupClient();
6059
6160
const groupRestoreSuccessful = ref<boolean | null>(null);
6261
const selectedClassifier = ref<string | null>(null);
6362
const classifiers = ref<string[]>([]);
6463
6564
async function getGroupingClassifiers() {
66-
const [, data] = await serviceControlStore.fetchTypedFromServiceControl<string[]>("recoverability/classifiers");
65+
const [, data] = await serviceControlClient.fetchTypedFromServiceControl<string[]>("recoverability/classifiers");
6766
classifiers.value = data;
6867
}
6968
@@ -82,7 +81,7 @@ async function classifierChanged(classifier: string) {
8281
8382
async function getArchiveGroups(classifier: string) {
8483
//get all deleted message groups
85-
const [, result] = await serviceControlStore.fetchTypedFromServiceControl<FailureGroupView[]>(`errors/groups/${classifier}`);
84+
const [, result] = await serviceControlClient.fetchTypedFromServiceControl<FailureGroupView[]>(`errors/groups/${classifier}`);
8685
8786
if (result.length === 0 && undismissedRestoreGroups.value.length > 0) {
8887
undismissedRestoreGroups.value.forEach((deletedGroup) => {

src/Frontend/src/components/failedmessages/DeletedMessages.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { TYPE } from "vue-toastification";
1414
import FailureGroup from "@/resources/FailureGroup";
1515
import FAIcon from "@/components/FAIcon.vue";
1616
import { faArrowRotateRight } from "@fortawesome/free-solid-svg-icons";
17-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
17+
import serviceControlClient from "@/components/serviceControlClient";
1818
import { useConfigurationStore } from "@/stores/ConfigurationStore";
1919
import { storeToRefs } from "pinia";
2020
@@ -39,7 +39,6 @@ watch(pageNumber, () => loadMessages());
3939
4040
const configurationStore = useConfigurationStore();
4141
const { configuration } = storeToRefs(configurationStore);
42-
const serviceControlStore = useServiceControlStore();
4342
4443
function loadMessages() {
4544
let startDate = new Date(0);
@@ -67,7 +66,7 @@ function loadMessages() {
6766
}
6867
6968
async function loadGroupDetails(groupId: string) {
70-
const [, data] = await serviceControlStore.fetchTypedFromServiceControl<FailureGroup>(`archive/groups/id/${groupId}`);
69+
const [, data] = await serviceControlClient.fetchTypedFromServiceControl<FailureGroup>(`archive/groups/id/${groupId}`);
7170
groupName.value = data.title;
7271
}
7372
@@ -80,7 +79,7 @@ function loadPagedMessages(groupId?: string, page: number = 1, sortBy: string =
8079
8180
async function loadDelMessages() {
8281
try {
83-
const [response, data] = await serviceControlStore.fetchTypedFromServiceControl<ExtendedFailedMessage[]>(
82+
const [response, data] = await serviceControlClient.fetchTypedFromServiceControl<ExtendedFailedMessage[]>(
8483
`${groupId ? `recoverability/groups/${groupId}/` : ""}errors?status=archived&page=${page}&per_page=${perPage}&sort=${sortBy}&direction=${direction}&modified=${dateRange}`
8584
);
8685
@@ -152,7 +151,7 @@ async function restoreSelectedMessages() {
152151
selectedMessages.forEach((m) => (m.restoreInProgress = true));
153152
useShowToast(TYPE.INFO, "Info", `restoring ${selectedMessages.length} messages...`);
154153
155-
await serviceControlStore.patchToServiceControl(
154+
await serviceControlClient.patchToServiceControl(
156155
"errors/unarchive",
157156
selectedMessages.map((m) => m.id)
158157
);

src/Frontend/src/components/failedmessages/FailedMessageGroups.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import SortOptions, { SortDirection } from "@/resources/SortOptions";
1010
import GroupOperation from "@/resources/GroupOperation";
1111
import getSortFunction from "@/components/getSortFunction";
1212
import { faArrowDownAZ, faArrowDownZA, faArrowDownShortWide, faArrowDownWideShort, faArrowDown19, faArrowDown91 } from "@fortawesome/free-solid-svg-icons";
13-
import { useServiceControlStore } from "@/stores/ServiceControlStore";
14-
15-
const serviceControlStore = useServiceControlStore();
13+
import serviceControlClient from "@/components/serviceControlClient";
1614
1715
const selectedClassifier = ref<string>("");
1816
const classifiers = ref<string[]>([]);
@@ -60,7 +58,7 @@ const sortOptions: SortOptions<GroupOperation>[] = [
6058
];
6159
6260
async function getGroupingClassifiers() {
63-
const [, data] = await serviceControlStore.fetchTypedFromServiceControl<string[]>("recoverability/classifiers");
61+
const [, data] = await serviceControlClient.fetchTypedFromServiceControl<string[]>("recoverability/classifiers");
6462
classifiers.value = data;
6563
}
6664

0 commit comments

Comments
 (0)