mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-12 00:55:34 +00:00
chore: fix some linting issues
This commit is contained in:
@@ -20,12 +20,6 @@ import App from './resources/vue/App.vue'
|
|||||||
import { initWebsocket } from './js/websocket.js'
|
import { initWebsocket } from './js/websocket.js'
|
||||||
import combinedTranslations from '../lang/combined_output.json'
|
import combinedTranslations from '../lang/combined_output.json'
|
||||||
|
|
||||||
import {
|
|
||||||
initMarshaller
|
|
||||||
} from './js/marshaller.js'
|
|
||||||
|
|
||||||
import { checkWebsocketConnection } from './js/websocket.js'
|
|
||||||
|
|
||||||
function getSelectedLanguage() {
|
function getSelectedLanguage() {
|
||||||
const storedLanguage = localStorage.getItem('olivetin-language');
|
const storedLanguage = localStorage.getItem('olivetin-language');
|
||||||
|
|
||||||
@@ -38,7 +32,22 @@ function getSelectedLanguage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (navigator.languages && navigator.languages.length > 0) {
|
if (navigator.languages && navigator.languages.length > 0) {
|
||||||
return navigator.languages[0];
|
const available = Object.keys(combinedTranslations.messages || {})
|
||||||
|
|
||||||
|
for (const candidate of navigator.languages) {
|
||||||
|
const lowerCandidate = candidate.toLowerCase()
|
||||||
|
const exact = available.find(locale => locale.toLowerCase() === lowerCandidate)
|
||||||
|
|
||||||
|
if (exact) {
|
||||||
|
return exact
|
||||||
|
}
|
||||||
|
|
||||||
|
const prefix = available.find(locale => locale.toLowerCase().startsWith(lowerCandidate.split('-')[0] + '-'))
|
||||||
|
|
||||||
|
if (prefix) {
|
||||||
|
return prefix
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'en';
|
return 'en';
|
||||||
@@ -77,24 +86,17 @@ function setupVue (i18nSettings) {
|
|||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(i18nSettings)
|
app.use(i18nSettings)
|
||||||
|
|
||||||
// Make i18n instance accessible globally for language switching
|
|
||||||
window.i18n = i18nSettings.global
|
window.i18n = i18nSettings.global
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
}
|
}
|
||||||
|
|
||||||
function main () {
|
async function main () {
|
||||||
initClient()
|
const i18nSettings = await initClient()
|
||||||
|
|
||||||
initWebsocket()
|
initWebsocket()
|
||||||
|
|
||||||
setupVue()
|
|
||||||
|
|
||||||
const i18nSettings = await initClient()
|
|
||||||
|
|
||||||
setupVue(i18nSettings)
|
setupVue(i18nSettings)
|
||||||
|
|
||||||
initMarshaller()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -183,11 +183,13 @@ function renderSidebar() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rootDashboards = window.initResponse?.rootDashboards || []
|
||||||
|
|
||||||
if (typeof sidebar.value.clear === 'function') {
|
if (typeof sidebar.value.clear === 'function') {
|
||||||
sidebar.value.clear()
|
sidebar.value.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const rootDashboard of window.initResponse.rootDashboards) {
|
for (const rootDashboard of rootDashboards) {
|
||||||
sidebar.value.addNavigationLink({
|
sidebar.value.addNavigationLink({
|
||||||
id: rootDashboard,
|
id: rootDashboard,
|
||||||
name: rootDashboard,
|
name: rootDashboard,
|
||||||
|
|||||||
@@ -330,10 +330,10 @@ onMounted(() => {
|
|||||||
document.addEventListener('fullscreenchange', (e) => {
|
document.addEventListener('fullscreenchange', (e) => {
|
||||||
setTimeout(() => { // Wait for the DOM to settle
|
setTimeout(() => { // Wait for the DOM to settle
|
||||||
if (document.fullscreenElement) {
|
if (document.fullscreenElement) {
|
||||||
window.terminal.fit()
|
terminal.fit()
|
||||||
} else {
|
} else {
|
||||||
window.terminal.resize(80, 40)
|
terminal.resize(80, 40)
|
||||||
window.terminal.fit()
|
terminal.fit()
|
||||||
}
|
}
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ func buildDefaultDashboard(rr *DashboardRenderRequest) *apiv1.Dashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sortActions(components []*apiv1.DashboardComponent) []*apiv1.DashboardComponent {
|
func sortActions(components []*apiv1.DashboardComponent) []*apiv1.DashboardComponent {
|
||||||
log.Infof("sortActions: %+v", components)
|
|
||||||
sort.Slice(components, func(i, j int) bool {
|
sort.Slice(components, func(i, j int) bool {
|
||||||
if components[i].Action == nil || components[j].Action == nil {
|
if components[i].Action == nil || components[j].Action == nil {
|
||||||
return components[i].Title < components[j].Title
|
return components[i].Title < components[j].Title
|
||||||
|
|||||||
Reference in New Issue
Block a user