mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 09:00:50 +00:00
update query
This commit is contained in:
parent
78bd81ea5d
commit
d27f79b89f
@ -14,9 +14,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export const queryNamespaces = {
|
||||
query: `namespaces: listNamespaces`,
|
||||
};
|
||||
|
||||
export const queryContainers = {
|
||||
variable: "$condition: ContainerQueryCondition",
|
||||
@ -33,6 +30,5 @@ export const queryStreamingLogs = {
|
||||
contentType
|
||||
content
|
||||
}
|
||||
total
|
||||
}`,
|
||||
};
|
||||
|
@ -15,14 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
queryContainers,
|
||||
queryStreamingLogs,
|
||||
queryNamespaces,
|
||||
} from "../fragments/demand-log";
|
||||
import { queryContainers, queryStreamingLogs } from "../fragments/demand-log";
|
||||
|
||||
export const fetchContainers = `query queryContainers(${queryContainers.variable}) {${queryContainers.query}}`;
|
||||
|
||||
export const fetchDemandPodLogs = `query queryStreamingLogs(${queryStreamingLogs.variable}) {${queryStreamingLogs.query}}`;
|
||||
|
||||
export const fetchNamespaces = `query queryContainers {${queryNamespaces.query}}`;
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { defineStore } from "pinia";
|
||||
import { Option } from "@/types/app";
|
||||
import { Instance } from "@/types/selector";
|
||||
import { store } from "@/store";
|
||||
import graphql from "@/graphql";
|
||||
@ -31,7 +30,6 @@ interface DemandLogState {
|
||||
selectorStore: any;
|
||||
logs: Log[];
|
||||
loadLogs: boolean;
|
||||
namespaces: Option[];
|
||||
}
|
||||
|
||||
export const demandLogStore = defineStore({
|
||||
@ -40,17 +38,13 @@ export const demandLogStore = defineStore({
|
||||
containers: [{ label: "Detail", value: "Detail" }],
|
||||
instances: [{ value: "", label: "" }],
|
||||
conditions: {
|
||||
namespace: "",
|
||||
container: "",
|
||||
serviceId: "",
|
||||
serviceInstanceId: "",
|
||||
queryDuration: useAppStoreWithOut().durationTime,
|
||||
paging: { pageNum: 1, pageSize: -1 },
|
||||
},
|
||||
selectorStore: useSelectorStore(),
|
||||
logs: [],
|
||||
loadLogs: false,
|
||||
namespaces: [],
|
||||
}),
|
||||
actions: {
|
||||
setLogCondition(data: Conditions) {
|
||||
@ -71,23 +65,7 @@ export const demandLogStore = defineStore({
|
||||
this.instances = res.data.data.pods || [];
|
||||
return res.data;
|
||||
},
|
||||
async getNamespaces() {
|
||||
const res: AxiosResponse = await graphql
|
||||
.query("fetchNamespaces")
|
||||
.params({});
|
||||
|
||||
if (res.data.errors) {
|
||||
return res.data;
|
||||
}
|
||||
this.namespaces = (res.data.data.namespaces || []).map((d: string) => {
|
||||
return {
|
||||
label: d,
|
||||
value: d,
|
||||
};
|
||||
});
|
||||
return res.data;
|
||||
},
|
||||
async getContainers(namespace: string, serviceInstanceId: string) {
|
||||
async getContainers(serviceInstanceId: string) {
|
||||
if (!this.selectorStore.currentService) {
|
||||
return new Promise((resolve) => resolve({ errors: "No service" }));
|
||||
}
|
||||
@ -95,7 +73,6 @@ export const demandLogStore = defineStore({
|
||||
const condition = {
|
||||
serviceId,
|
||||
serviceInstanceId,
|
||||
namespace,
|
||||
};
|
||||
const res: AxiosResponse = await graphql
|
||||
.query("fetchContainers")
|
||||
|
@ -14,15 +14,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DurationTime, Paging } from "./app";
|
||||
import { DurationTime } from "./app";
|
||||
|
||||
export interface Conditions {
|
||||
namespace: string;
|
||||
container: string;
|
||||
serviceId: string;
|
||||
serviceInstanceId: string;
|
||||
queryDuration: DurationTime;
|
||||
paging: Paging;
|
||||
keywordsOfContent?: string[];
|
||||
excludingKeywordsOfContent?: string;
|
||||
}
|
||||
|
@ -25,17 +25,6 @@ limitations under the License. -->
|
||||
class="selectors"
|
||||
/>
|
||||
</div>
|
||||
<div class="mr-5 mb-5">
|
||||
<span class="grey mr-5">{{ t("namespace") }}:</span>
|
||||
<Selector
|
||||
size="small"
|
||||
:value="state.namespace.value"
|
||||
:options="demandLogStore.namespaces"
|
||||
placeholder="Select a namespace"
|
||||
@change="changeField('namespace', $event)"
|
||||
class="selectors"
|
||||
/>
|
||||
</div>
|
||||
<div class="mr-5 mb-5">
|
||||
<span class="grey mr-5">{{ t("container") }}:</span>
|
||||
<Selector
|
||||
@ -169,7 +158,6 @@ const intervalTime = ref<number>(1);
|
||||
const state = reactive<any>({
|
||||
instance: { value: "", label: "" },
|
||||
container: { value: "", label: "None" },
|
||||
namespace: { value: "", label: "None" },
|
||||
duration: { label: "Last 30 min", value: 1800 },
|
||||
});
|
||||
const rangeTime = computed(() => {
|
||||
@ -199,22 +187,10 @@ async function fetchSelectors() {
|
||||
} else {
|
||||
await getInstances();
|
||||
}
|
||||
await getNamespaces();
|
||||
getContainers();
|
||||
}
|
||||
async function getNamespaces() {
|
||||
const resp = await demandLogStore.getNamespaces();
|
||||
if (resp.errors) {
|
||||
ElMessage.error(resp.errors);
|
||||
return;
|
||||
}
|
||||
state.namespace = demandLogStore.namespaces[0];
|
||||
}
|
||||
async function getContainers() {
|
||||
const resp = await demandLogStore.getContainers(
|
||||
state.namespace,
|
||||
state.instance.id || ""
|
||||
);
|
||||
const resp = await demandLogStore.getContainers(state.instance.id || "");
|
||||
if (resp.errors) {
|
||||
ElMessage.error(resp.errors);
|
||||
return;
|
||||
@ -235,10 +211,7 @@ function searchLogs() {
|
||||
instance = selectorStore.currentPod.id;
|
||||
}
|
||||
demandLogStore.setLogCondition({
|
||||
serviceId:
|
||||
(selectorStore.currentService && selectorStore.currentService.id) || "",
|
||||
serviceInstanceId: instance || state.instance.id || "",
|
||||
namespace: state.namespace.value,
|
||||
container: state.container.value,
|
||||
queryDuration: rangeTime.value,
|
||||
keywordsOfContent: keywordsOfContent.value,
|
||||
|
Loading…
Reference in New Issue
Block a user