summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDevlin Junker <devlin.junker@gmail.com>2023-08-05 19:16:39 -0700
committerBenjamin Brahmer <info@b-brahmer.de>2023-08-09 11:08:04 +0200
commit923f986e67413ac548cc98d6d59fa01de9681035 (patch)
treea3d1fb38fd28388686b0c394d4824af30b959fd7 /src
parent450047ef4be0d39ba8a5e5e5ac0d6e87b7203ebb (diff)
upmerged from master
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/AdminSettings.vue29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue
index 33a24cebe..881b57d27 100644
--- a/src/components/AdminSettings.vue
+++ b/src/components/AdminSettings.vue
@@ -7,6 +7,15 @@ SPDX-Licence-Identifier: AGPL-3.0-or-later
<NcSettingsSection :title="t('news', 'News')"
class="news-settings"
doc-url="https://nextcloud.github.io/news/admin/">
+ <template v-if="lastCron !== 0">
+ <NcNoteCard v-if="oldExecution" type="error">
+ {{ t('news', 'Last job execution ran {relativeTime}. Something seems wrong.', {relativeTime}) }}
+ </NcNoteCard>
+
+ <NcNoteCard v-else type="success">
+ {{ t('news', 'Last job ran {relativeTime}.', {relativeTime}) }}
+ </NcNoteCard>
+ </template>
<NcCheckboxRadioSwitch type="switch"
:checked.sync="useCronUpdates"
@update:checked="update('useCronUpdates', useCronUpdates)">
@@ -100,6 +109,8 @@ SPDX-Licence-Identifier: AGPL-3.0-or-later
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
+import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
+import moment from '@nextcloud/moment'
import { loadState } from '@nextcloud/initial-state'
import { showError, showSuccess } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
@@ -110,8 +121,8 @@ import { confirmPassword } from '@nextcloud/password-confirmation'
* Debounce helper for method
* TODO: Should we remove this and use library?
*
- * @param {Function} func function to debounce
- * @param {number} wait milliseconds to wait
+ * @param {function()} func - The callback function
+ * @param {number} wait - Time to wait in miliseconds
*/
function debounce(func, wait) {
let timeout
@@ -124,10 +135,8 @@ function debounce(func, wait) {
}
}
-const successMessage = debounce(
- () => showSuccess(t('news', 'Successfully updated news configuration')),
- 500,
-)
+const successMessage = debounce(() => showSuccess(t('news', 'Successfully updated news configuration')), 500)
+const lastCron = loadState('news', 'lastCron')
export default {
name: 'AdminSettings',
@@ -135,6 +144,7 @@ export default {
NcCheckboxRadioSwitch,
NcSettingsSection,
NcTextField,
+ NcNoteCard,
},
data() {
return {
@@ -145,8 +155,15 @@ export default {
feedFetcherTimeout: loadState('news', 'feedFetcherTimeout'),
exploreUrl: loadState('news', 'exploreUrl'),
updateInterval: loadState('news', 'updateInterval'),
+ relativeTime: moment(lastCron * 1000).fromNow(),
+ lastCron,
}
},
+ computed: {
+ oldExecution() {
+ return Date.now() / 1000 - this.lastCron > (parseInt(this.updateInterval) * 2) + 900
+ },
+ },
methods: {
async update(key, value) {
await confirmPassword()