Compare commits

...

18 commits

Author SHA1 Message Date
Wampie Driessen
5c080d8324
Merge aff6a5bf7f into 8a432ac937 2024-11-12 18:00:24 +00:00
Ionys
8a432ac937
fix(status page): Make sure the group deletion is correctly handled when groupIDList is empty (#5340)
Some checks failed
Auto Test / check-linters (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
2024-11-12 19:00:09 +01:00
Wampie Driessen
aff6a5bf7f Merge branch 'master' into feature/locale_on_status_page 2023-10-16 09:43:08 +02:00
Wampie Driessen
821a70f2f3
Merge branch 'master' into feature/locale_on_status_page 2023-09-28 09:02:42 +02:00
Wampie Driessen
144794b770 Fix linter warning 2023-09-13 11:35:52 +02:00
Wampie Driessen
60271ffa0b Convert migration to knex migration 2023-09-13 11:32:55 +02:00
Wampie Driessen
bb7c098aec Merge branch 'master' into feature/locale_on_status_page 2023-09-13 11:32:00 +02:00
Wampie Driessen
f6e7da67fd
Merge branch 'master' into feature/locale_on_status_page 2023-08-10 11:50:44 +02:00
Wampie Driessen
47fed3eb99 Merge branch 'master' into feature/locale_on_status_page 2023-08-10 11:49:21 +02:00
Wampie Driessen
722ac84f99
Merge branch 'master' into feature/locale_on_status_page 2023-08-07 10:47:07 +02:00
Wampie Driessen
af45fa844e
Update src/mixins/lang.js 2023-08-05 18:47:57 +02:00
Wampie Driessen
8fa40d02aa
Update src/mixins/lang.js 2023-08-05 18:47:52 +02:00
Wampie Driessen
4cb9406a2e
Merge branch 'master' into feature/locale_on_status_page 2023-08-05 17:56:11 +02:00
Wampie Driessen
a50209b6c8
Update src/mixins/lang.js
Co-authored-by: Matthew Nickson <mnickson@sidingsmedia.com>
2023-08-05 17:55:27 +02:00
Wampie Driessen
1ceb8e98d6
Merge branch 'master' into feature/locale_on_status_page 2023-08-04 12:21:33 +02:00
Wampie Driessen
be461a0efd Fix linter issues 2023-08-03 16:43:59 +02:00
Wampie Driessen
deaec80cb0 Allow a 'default locale' and locale switcher on status pages 2023-08-03 16:32:52 +02:00
Wampie Driessen
6412514cae Allow a 'default locale' and locale switcher on status pages 2023-08-03 16:30:43 +02:00
6 changed files with 73 additions and 8 deletions

View file

@ -0,0 +1,15 @@
exports.up = function (knex) {
return knex.schema
.alterTable("status_page", function (table) {
table.boolean("show_locale_selector").notNullable().defaultTo(false);
table.string("default_locale").nullable().defaultTo("");
});
};
exports.down = function (knex) {
return knex.schema
.alterTable("status_page", function (table) {
table.dropColumn("default_locale");
table.dropColumn("show_locale_selector");
});
};

View file

@ -403,6 +403,8 @@ class StatusPage extends BeanModel {
autoRefreshInterval: this.autoRefreshInterval, autoRefreshInterval: this.autoRefreshInterval,
published: !!this.published, published: !!this.published,
showTags: !!this.show_tags, showTags: !!this.show_tags,
showLocaleSelector: !!this.show_locale_selector,
defaultLocale: this.default_locale,
domainNameList: this.getDomainNameList(), domainNameList: this.getDomainNameList(),
customCSS: this.custom_css, customCSS: this.custom_css,
footerText: this.footer_text, footerText: this.footer_text,
@ -427,6 +429,8 @@ class StatusPage extends BeanModel {
theme: this.theme, theme: this.theme,
published: !!this.published, published: !!this.published,
showTags: !!this.show_tags, showTags: !!this.show_tags,
showLocaleSelector: !!this.show_locale_selector,
defaultLocale: this.default_locale,
customCSS: this.custom_css, customCSS: this.custom_css,
footerText: this.footer_text, footerText: this.footer_text,
showPoweredBy: !!this.show_powered_by, showPoweredBy: !!this.show_powered_by,

View file

@ -160,6 +160,8 @@ module.exports.statusPageSocketHandler = (socket) => {
//statusPage.published = ; //statusPage.published = ;
//statusPage.search_engine_index = ; //statusPage.search_engine_index = ;
statusPage.show_tags = config.showTags; statusPage.show_tags = config.showTags;
statusPage.show_locale_selector = config.showLocaleSelector;
statusPage.default_locale = config.defaultLocale;
//statusPage.password = null; //statusPage.password = null;
statusPage.footer_text = config.footerText; statusPage.footer_text = config.footerText;
statusPage.custom_css = config.customCSS; statusPage.custom_css = config.customCSS;
@ -220,6 +222,9 @@ module.exports.statusPageSocketHandler = (socket) => {
// Delete groups that are not in the list // Delete groups that are not in the list
log.debug("socket", "Delete groups that are not in the list"); log.debug("socket", "Delete groups that are not in the list");
if (groupIDList.length === 0) {
await R.exec("DELETE FROM `group` WHERE status_page_id = ?", [ statusPage.id ]);
} else {
const slots = groupIDList.map(() => "?").join(","); const slots = groupIDList.map(() => "?").join(",");
const data = [ const data = [
@ -227,6 +232,7 @@ module.exports.statusPageSocketHandler = (socket) => {
statusPage.id statusPage.id
]; ];
await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data); await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data);
}
const server = UptimeKumaServer.getInstance(); const server = UptimeKumaServer.getInstance();

View file

@ -291,6 +291,8 @@
"Switch to Light Theme": "Switch to Light Theme", "Switch to Light Theme": "Switch to Light Theme",
"Switch to Dark Theme": "Switch to Dark Theme", "Switch to Dark Theme": "Switch to Dark Theme",
"Show Tags": "Show Tags", "Show Tags": "Show Tags",
"Show Locale Selector": "Show Locale Selector",
"Default Locale": "Default Locale",
"Hide Tags": "Hide Tags", "Hide Tags": "Hide Tags",
"Description": "Description", "Description": "Description",
"No monitors available.": "No monitors available.", "No monitors available.": "No monitors available.",

View file

@ -33,6 +33,17 @@ export default {
this.$i18n.locale = lang; this.$i18n.locale = lang;
localStorage.locale = lang; localStorage.locale = lang;
setPageLocale(); setPageLocale();
},
/**
* Change the language for the current page (no localstore set)
* @param {string} lang Code of language to switch to.
* @returns {Promise<void>}
*/
async changeCurrentPageLang(lang) {
let message = (await langModules["../lang/" + lang + ".json"]()).default;
this.$i18n.setLocaleMessage(lang, message);
this.$i18n.locale = lang;
setPageLocale();
} }
} }
}; };

View file

@ -56,6 +56,18 @@
<label class="form-check-label" for="showTags">{{ $t("Show Tags") }}</label> <label class="form-check-label" for="showTags">{{ $t("Show Tags") }}</label>
</div> </div>
<div class="my-3 form-check form-switch">
<input id="showLocaleSelector" v-model="config.showLocaleSelector" class="form-check-input" type="checkbox">
<label class="form-check-label" for="showLocaleSelector">{{ $t("Show Locale Selector") }}</label>
</div>
<div class="my-3">
<label for="defaultLocale" class="form-label">{{ $t("Default Locale") }}</label>
<select id="defaultLocale" v-model="config.defaultLocale" class="form-select">
<option v-for="locale in $i18n.availableLocales" :key="locale" :value="locale" :text="$i18n.messages[locale].languageName"></option>
</select>
</div>
<!-- Show Powered By --> <!-- Show Powered By -->
<div class="my-3 form-check form-switch"> <div class="my-3 form-check form-switch">
<input id="show-powered-by" v-model="config.showPoweredBy" class="form-check-input" type="checkbox" data-testid="show-powered-by-checkbox"> <input id="show-powered-by" v-model="config.showPoweredBy" class="form-check-input" type="checkbox" data-testid="show-powered-by-checkbox">
@ -128,7 +140,7 @@
<!-- Main Status Page --> <!-- Main Status Page -->
<div :class="{ edit: enableEditMode}" class="main"> <div :class="{ edit: enableEditMode}" class="main">
<!-- Logo & Title --> <!-- Logo, Title & Language -->
<h1 class="mb-4 title-flex"> <h1 class="mb-4 title-flex">
<!-- Logo --> <!-- Logo -->
<span class="logo-wrapper" @click="showImageCropUploadMethod"> <span class="logo-wrapper" @click="showImageCropUploadMethod">
@ -151,7 +163,14 @@
/> />
<!-- Title --> <!-- Title -->
<Editable v-model="config.title" tag="span" :contenteditable="editMode" :noNL="true" /> <Editable v-model="config.title" class="title" tag="span" :contenteditable="editMode" :noNL="true" />
<!-- Locale Selector -->
<span class="language-selector">
<select v-model="$root.language" class="form-select">
<option v-for="locale in $i18n.availableLocales" :key="locale" :value="locale" :text="$i18n.messages[locale].languageName"></option>
</select>
</span>
</h1> </h1>
<!-- Admin functions --> <!-- Admin functions -->
@ -715,6 +734,10 @@ export default {
this.maintenanceList = res.data.maintenanceList; this.maintenanceList = res.data.maintenanceList;
this.$root.publicGroupList = res.data.publicGroupList; this.$root.publicGroupList = res.data.publicGroupList;
if (!localStorage.locale && this.config.defaultLocale) {
this.$root.changeCurrentPageLang(this.config.defaultLocale);
}
this.loading = false; this.loading = false;
// Configure auto-refresh loop // Configure auto-refresh loop
@ -1143,6 +1166,10 @@ footer {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
.title {
flex-grow: 1;
}
} }
.logo-wrapper { .logo-wrapper {