diff --git a/source/app/metrics/index.mjs b/source/app/metrics/index.mjs
index e1f07278..3282b367 100644
--- a/source/app/metrics/index.mjs
+++ b/source/app/metrics/index.mjs
@@ -24,8 +24,6 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
//Initialization
const pending = []
const {queries} = conf
- const extras = {css: imports.metadata.plugins.core.extras("extras_css", {...conf.settings, error:false}) ? q["extras.css"] ?? "" : "", js: imports.metadata.plugins.core.extras("extras_js", {...conf.settings, error:false}) ? q["extras.js"] ?? "" : ""}
- const data = {q, animated: true, large: false, base: {}, config: {}, errors: [], plugins: {}, computed: {}, extras, postscripts: []}
const imports = {
plugins: Plugins,
templates: Templates,
@@ -40,6 +38,8 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
}
: null),
}
+ const extras = {css: imports.metadata.plugins.core.extras("extras_css", {...conf.settings, error:false}) ? q["extras.css"] ?? "" : "", js: imports.metadata.plugins.core.extras("extras_js", {...conf.settings, error:false}) ? q["extras.js"] ?? "" : ""}
+ const data = {q, animated: true, large: false, base: {}, config: {}, errors: [], plugins: {}, computed: {}, extras, postscripts: []}
const experimental = new Set(decodeURIComponent(q["experimental.features"] ?? "").split(" ").map(x => x.trim().toLocaleLowerCase()).filter(x => x))
if (conf.settings["debug.headless"])
imports.puppeteer.headless = false
diff --git a/source/app/web/instance.mjs b/source/app/web/instance.mjs
index edd83e13..66808ecb 100644
--- a/source/app/web/instance.mjs
+++ b/source/app/web/instance.mjs
@@ -130,6 +130,8 @@ export default async function({sandbox = false} = {}) {
app.get("/.templates/:template", limiter, (req, res) => req.params.template in conf.templates ? res.status(200).json(conf.templates[req.params.template]) : res.sendStatus(404))
for (const template in conf.templates)
app.use(`/.templates/${template}/partials`, express.static(`${conf.paths.templates}/${template}/partials`))
+ //Modes
+ app.get("/.modes", limiter, (req, res) => res.status(200).json(conf.settings.modes))
//Styles
app.get("/.css/style.css", limiter, (req, res) => res.sendFile(`${conf.paths.statics}/style.css`))
app.get("/.css/style.vars.css", limiter, (req, res) => res.sendFile(`${conf.paths.statics}/style.vars.css`))
diff --git a/source/app/web/statics/app.js b/source/app/web/statics/app.js
index ff820280..ef23221c 100644
--- a/source/app/web/statics/app.js
+++ b/source/app/web/statics/app.js
@@ -6,7 +6,6 @@
async mounted() {
//Interpolate config from browser
try {
- this.config.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
this.palette = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
}
catch (error) {}
@@ -17,26 +16,6 @@
const {data: requests} = await axios.get("/.requests")
this.requests = requests
})(),
- //Templates
- (async () => {
- const {data: templates} = await axios.get("/.templates")
- templates.sort((a, b) => (a.name.startsWith("@") ^ b.name.startsWith("@")) ? (a.name.startsWith("@") ? 1 : -1) : a.name.localeCompare(b.name))
- this.templates.list = templates
- this.templates.selected = templates[0]?.name || "classic"
- })(),
- //Plugins
- (async () => {
- const {data: plugins} = await axios.get("/.plugins")
- this.plugins.list = plugins.filter(({name}) => metadata[name]?.supports.includes("user") || metadata[name]?.supports.includes("organization"))
- const categories = [...new Set(this.plugins.list.map(({category}) => category))]
- this.plugins.categories = Object.fromEntries(categories.map(category => [category, this.plugins.list.filter(value => category === value.category)]))
- })(),
- //Base
- (async () => {
- const {data: base} = await axios.get("/.plugins.base")
- this.plugins.base = base
- this.plugins.enabled.base = Object.fromEntries(base.map(key => [key, true]))
- })(),
//Version
(async () => {
const {data: version} = await axios.get("/.version")
@@ -47,28 +26,15 @@
const {data: hosted} = await axios.get("/.hosted")
this.hosted = hosted
})(),
+ //Modes
+ (async () => {
+ const {data: modes} = await axios.get("/.modes")
+ this.modes = modes
+ })(),
])
- //Generate placeholder
- this.mock({timeout: 200})
- setInterval(() => {
- const marker = document.querySelector("#metrics-end")
- if (marker) {
- this.mockresize()
- marker.remove()
- }
- }, 100)
},
//Watchers
watch: {
- tab: {
- immediate: true,
- handler(current) {
- if (current === "action")
- this.clipboard = new ClipboardJS(".copy-action")
- else
- this.clipboard?.destroy()
- },
- },
palette: {
immediate: true,
handler(current, previous) {
@@ -80,14 +46,12 @@
//Data initialization
data: {
version: "",
- user: "",
- tab: "overview",
+ user1: "",
+ user2: "",
palette: "light",
- clipboard: null,
requests: {rest: {limit: 0, used: 0, remaining: 0, reset: NaN}, graphql: {limit: 0, used: 0, remaining: 0, reset: NaN}},
- cached: new Map(),
-
hosted: null,
+ modes: [],
},
//Computed data
computed: {
@@ -95,6 +59,22 @@
preview() {
return /-preview$/.test(this.version)
},
+ //Rate limit reset
+ rlreset() {
+ const reset = new Date(Math.max(this.requests.graphql.reset, this.requests.rest.reset))
+ return `${reset.getHours()}:${reset.getMinutes()}`
+ },
},
+ //Methods
+ methods:{
+ //Metrics insights
+ async insights() {
+ window.location.href = `/insights?user=${this.user1}`
+ },
+ //Metrics embed
+ async embed() {
+ window.location.href = `/embed?user=${this.user2}`
+ }
+ }
})
})()
diff --git a/source/app/web/statics/embed/app.js b/source/app/web/statics/embed/app.js
index 26b94dd4..438467ce 100644
--- a/source/app/web/statics/embed/app.js
+++ b/source/app/web/statics/embed/app.js
@@ -85,7 +85,7 @@
//Data initialization
data: {
version: "",
- user: "",
+ user: new URLSearchParams(location.search).get("user") || "",
tab: "overview",
palette: "light",
clipboard: null,
diff --git a/source/app/web/statics/embed/index.html b/source/app/web/statics/embed/index.html
index 8649b937..5ea70517 100644
--- a/source/app/web/statics/embed/index.html
+++ b/source/app/web/statics/embed/index.html
@@ -19,7 +19,7 @@