aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/src
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2020-08-18 10:54:46 +0200
committerGeorg Ehrke <developer@georgehrke.com>2020-08-20 15:43:34 +0200
commitbd6a6cf3bff74dc5690fe032a4203165227f01d2 (patch)
treee66324bec9e142b859d171b051060850295bad5d /apps/user_status/src
parent03603db486debbb31dfa05486f3b10338a28b50c (diff)
downloadnextcloud-server-bd6a6cf3bff74dc5690fe032a4203165227f01d2.tar.gz
nextcloud-server-bd6a6cf3bff74dc5690fe032a4203165227f01d2.zip
Add Status Dashboard
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/user_status/src')
-rw-r--r--apps/user_status/src/dashboard.js48
-rw-r--r--apps/user_status/src/main-user-status-menu.js21
-rw-r--r--apps/user_status/src/views/Dashboard.vue100
3 files changed, 169 insertions, 0 deletions
diff --git a/apps/user_status/src/dashboard.js b/apps/user_status/src/dashboard.js
new file mode 100644
index 00000000000..8b85b695f77
--- /dev/null
+++ b/apps/user_status/src/dashboard.js
@@ -0,0 +1,48 @@
+/**
+ * @copyright Copyright (c) 2020 Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+import Vue from 'vue'
+import { generateFilePath } from '@nextcloud/router'
+import { getRequestToken } from '@nextcloud/auth'
+import { translate, translatePlural } from '@nextcloud/l10n'
+import Dashboard from './views/Dashboard'
+
+// eslint-disable-next-line
+__webpack_nonce__ = btoa(getRequestToken())
+
+// eslint-disable-next-line
+__webpack_public_path__ = generateFilePath('user_status', '', 'js/')
+
+Vue.prototype.t = translate
+Vue.prototype.n = translatePlural
+Vue.prototype.OC = OC
+Vue.prototype.OCA = OCA
+
+document.addEventListener('DOMContentLoaded', function() {
+ OCA.Dashboard.register('user_status', (el) => {
+ const View = Vue.extend(Dashboard)
+ new View({
+ propsData: {},
+ }).$mount(el)
+ })
+
+})
diff --git a/apps/user_status/src/main-user-status-menu.js b/apps/user_status/src/main-user-status-menu.js
index c6d23337526..322585c3f0c 100644
--- a/apps/user_status/src/main-user-status-menu.js
+++ b/apps/user_status/src/main-user-status-menu.js
@@ -1,3 +1,24 @@
+/**
+ * @copyright Copyright (c) 2020 Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
import Vue from 'vue'
import { getRequestToken } from '@nextcloud/auth'
import App from './App'
diff --git a/apps/user_status/src/views/Dashboard.vue b/apps/user_status/src/views/Dashboard.vue
new file mode 100644
index 00000000000..2a1545d0596
--- /dev/null
+++ b/apps/user_status/src/views/Dashboard.vue
@@ -0,0 +1,100 @@
+<!--
+ - @copyright Copyright (c) 2020 Georg Ehrke <oc.list@georgehrke.com>
+ - @author Georg Ehrke <oc.list@georgehrke.com>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <DashboardWidget
+ id="user-status_panel"
+ :items="items"
+ :loading="loading">
+ <template v-slot:empty-content>
+ <EmptyContent
+ id="user_status-widget-empty-content"
+ icon="icon-user-status">
+ {{ t('user_status', 'No recent status changes') }}
+ </EmptyContent>
+ </template>
+ </DashboardWidget>
+</template>
+
+<script>
+import { DashboardWidget } from '@nextcloud/vue-dashboard'
+import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
+import { loadState } from '@nextcloud/initial-state'
+import moment from '@nextcloud/moment'
+
+export default {
+ name: 'Dashboard',
+ components: {
+ DashboardWidget,
+ EmptyContent,
+ },
+ data() {
+ return {
+ statuses: [],
+ loading: true,
+ }
+ },
+ computed: {
+ items() {
+ return this.statuses.map((item) => {
+ const icon = item.icon || ''
+ const message = item.message || ''
+ const status = `${icon} ${message}`
+
+ let subText
+ if (item.icon === null && item.message === null && item.timestamp === null) {
+ subText = ''
+ } else if (item.icon === null && item.message === null && item.timestamp !== null) {
+ subText = moment(item.timestamp, 'X').fromNow()
+ } else if (item.timestamp !== null) {
+ subText = this.t('user_status', '{status}, {timestamp}', {
+ status,
+ timestamp: moment(item.timestamp, 'X').fromNow(),
+ })
+ } else {
+ subText = status
+ }
+
+ return {
+ mainText: item.displayName,
+ subText,
+ avatarUsername: item.userId,
+ }
+ })
+ },
+ },
+ mounted() {
+ try {
+ this.statuses = loadState('user_status', 'dashboard_data')
+ this.loading = false
+ } catch (e) {
+ console.error(e)
+ }
+ },
+}
+</script>
+
+<style lang="scss">
+#user_status-widget-empty-content {
+ text-align: center;
+ margin-top: 5vh;
+}
+</style>