mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-17 02:35:24 +00:00
feat: set utc
This commit is contained in:
parent
34f16e244d
commit
eda6bfe2d2
@ -18,6 +18,7 @@ export const TypeOfMetrics = {
|
|||||||
variable: "$name: String!",
|
variable: "$name: String!",
|
||||||
query: `typeOfMetrics(name: $name)`,
|
query: `typeOfMetrics(name: $name)`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const listMetrics = {
|
export const listMetrics = {
|
||||||
variable: "$regex: String",
|
variable: "$regex: String",
|
||||||
query: `
|
query: `
|
||||||
@ -29,3 +30,12 @@ export const listMetrics = {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAllTemplates = {
|
||||||
|
query: `
|
||||||
|
getAllTemplates {
|
||||||
|
id,
|
||||||
|
configuration,
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
@ -14,8 +14,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { TypeOfMetrics, listMetrics } from "../fragments/dashboard";
|
import {
|
||||||
|
TypeOfMetrics,
|
||||||
|
listMetrics,
|
||||||
|
getAllTemplates,
|
||||||
|
} from "../fragments/dashboard";
|
||||||
|
|
||||||
export const queryTypeOfMetrics = `query typeOfMetrics(${TypeOfMetrics.variable}) {${TypeOfMetrics.query}}`;
|
export const queryTypeOfMetrics = `query typeOfMetrics(${TypeOfMetrics.variable}) {${TypeOfMetrics.query}}`;
|
||||||
|
|
||||||
export const queryMetrics = `query queryData(${listMetrics.variable}) {${listMetrics.query}}`;
|
export const queryMetrics = `query queryData(${listMetrics.variable}) {${listMetrics.query}}`;
|
||||||
|
|
||||||
|
export const getTemplates = `query queryOAPTimeInfo {${getAllTemplates.query}}`;
|
||||||
|
@ -46,11 +46,9 @@ const route = useRoute();
|
|||||||
const pageName = ref<string>("");
|
const pageName = ref<string>("");
|
||||||
const timeRange = ref<number>(0);
|
const timeRange = ref<number>(0);
|
||||||
const theme = ref<string>("light");
|
const theme = ref<string>("light");
|
||||||
let utc = localStorage.getItem("utc") || "";
|
let utc = appStore.utc || "";
|
||||||
if (!utc.includes(":")) {
|
if (!utc.includes(":")) {
|
||||||
utc =
|
utc = (appStore.utc || -(new Date().getTimezoneOffset() / 60)) + ":0";
|
||||||
(localStorage.getItem("utc") || -(new Date().getTimezoneOffset() / 60)) +
|
|
||||||
":0";
|
|
||||||
}
|
}
|
||||||
const utcArr = (utc || "").split(":");
|
const utcArr = (utc || "").split(":");
|
||||||
const utcHour = isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]);
|
const utcHour = isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]);
|
||||||
|
@ -16,9 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
|
import graphql from "@/graphql";
|
||||||
import { Duration, DurationTime } from "@/types/app";
|
import { Duration, DurationTime } from "@/types/app";
|
||||||
import getLocalTime from "@/utils/localtime";
|
import getLocalTime from "@/utils/localtime";
|
||||||
import getDurationRow from "@/utils/dateTime";
|
import getDurationRow from "@/utils/dateTime";
|
||||||
|
import { AxiosResponse } from "axios";
|
||||||
import dateFormatStep, { dateFormatTime } from "@/utils/dateFormat";
|
import dateFormatStep, { dateFormatTime } from "@/utils/dateFormat";
|
||||||
/*global Nullable*/
|
/*global Nullable*/
|
||||||
interface AppState {
|
interface AppState {
|
||||||
@ -116,7 +118,6 @@ export const appStore = defineStore({
|
|||||||
this.utcMin = utcMin;
|
this.utcMin = utcMin;
|
||||||
this.utcHour = utcHour;
|
this.utcHour = utcHour;
|
||||||
this.utc = `${utcHour}:${utcMin}`;
|
this.utc = `${utcHour}:${utcMin}`;
|
||||||
localStorage.setItem("utc", this.utc);
|
|
||||||
},
|
},
|
||||||
setEventStack(funcs: (() => void)[]): void {
|
setEventStack(funcs: (() => void)[]): void {
|
||||||
this.eventStack = funcs;
|
this.eventStack = funcs;
|
||||||
@ -139,6 +140,21 @@ export const appStore = defineStore({
|
|||||||
500
|
500
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
async queryOAPTimeInfo() {
|
||||||
|
const res: AxiosResponse = await graphql
|
||||||
|
.query("queryOAPTimeInfo")
|
||||||
|
.params({});
|
||||||
|
if (
|
||||||
|
!res.data ||
|
||||||
|
!res.data.data ||
|
||||||
|
!res.data.data.getTimeInfo ||
|
||||||
|
!res.data.data.getTimeInfo.timezone
|
||||||
|
) {
|
||||||
|
this.utc = -(new Date().getTimezoneOffset() / 60) + ":0";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.utc = res.data.data.getTimeInfo.timezone / 100 + ":0";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
export function useAppStoreWithOut(): any {
|
export function useAppStoreWithOut(): any {
|
||||||
|
@ -14,9 +14,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import graphql from "@/graphql";
|
|
||||||
import { AxiosResponse } from "axios";
|
|
||||||
|
|
||||||
const getLocalTime = (utc: string, time: Date): Date => {
|
const getLocalTime = (utc: string, time: Date): Date => {
|
||||||
const utcArr = utc.split(":");
|
const utcArr = utc.split(":");
|
||||||
const utcHour = isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]);
|
const utcHour = isNaN(Number(utcArr[0])) ? 0 : Number(utcArr[0]);
|
||||||
@ -28,31 +25,4 @@ const getLocalTime = (utc: string, time: Date): Date => {
|
|||||||
return new Date(utcTime + 3600000 * utcHour + utcMin * 60000);
|
return new Date(utcTime + 3600000 * utcHour + utcMin * 60000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTimezoneOffset = () => {
|
|
||||||
window.localStorage.setItem(
|
|
||||||
"utc",
|
|
||||||
-(new Date().getTimezoneOffset() / 60) + ":0"
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const queryOAPTimeInfo = async (): Promise<void> => {
|
|
||||||
let utc = window.localStorage.getItem("utc");
|
|
||||||
if (!utc) {
|
|
||||||
const res: AxiosResponse = await graphql
|
|
||||||
.query("queryOAPTimeInfo")
|
|
||||||
.params({});
|
|
||||||
if (
|
|
||||||
!res.data ||
|
|
||||||
!res.data.data ||
|
|
||||||
!res.data.data.getTimeInfo ||
|
|
||||||
!res.data.data.getTimeInfo.timezone
|
|
||||||
) {
|
|
||||||
setTimezoneOffset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
utc = res.data.data.getTimeInfo.timezone / 100 + ":0";
|
|
||||||
window.localStorage.setItem("utc", utc);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default getLocalTime;
|
export default getLocalTime;
|
||||||
|
@ -65,7 +65,6 @@ const tagsList = ref<string[]>([]);
|
|||||||
function removeTags(index: number) {
|
function removeTags(index: number) {
|
||||||
tagsList.value.splice(index, 1);
|
tagsList.value.splice(index, 1);
|
||||||
updateTags();
|
updateTags();
|
||||||
localStorage.setItem("traceTags", JSON.stringify(this.tagsList));
|
|
||||||
}
|
}
|
||||||
function addLabels() {
|
function addLabels() {
|
||||||
if (!tags.value) {
|
if (!tags.value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user