Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2020-12-07 00:54:42 +0300
committerdartcafe <github@dartcafe.de>2020-12-07 00:54:42 +0300
commit4b72db6c82552572ac90381d8e250c6f70b38d2b (patch)
tree8f6fa54628a12550df630572828e5a90bad18b17 /src/js/store
parent9f7537b6b526d5ef56a742dc354b12d0531b785e (diff)
Adding admin section
Diffstat (limited to 'src/js/store')
-rw-r--r--src/js/store/modules/pollsAdmin.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/js/store/modules/pollsAdmin.js b/src/js/store/modules/pollsAdmin.js
new file mode 100644
index 00000000..b3299acf
--- /dev/null
+++ b/src/js/store/modules/pollsAdmin.js
@@ -0,0 +1,74 @@
+/*
+ * @copyright Copyright (c) 2019 Rene Gieling <github@dartcafe.de>
+ *
+ * @author Rene Gieling <github@dartcafe.de>
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @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 axios from '@nextcloud/axios'
+import { getCurrentUser } from '@nextcloud/auth'
+import { generateUrl } from '@nextcloud/router'
+
+const state = {
+ list: [],
+}
+
+const namespaced = true
+
+const mutations = {
+ set(state, payload) {
+ Object.assign(state, payload)
+ },
+}
+
+const getters = {
+ filtered: (state) => (filterId) => {
+ return state.list
+ },
+}
+
+const actions = {
+ load(context) {
+ const endPoint = 'apps/polls/administration'
+ if (getCurrentUser().isAdmin) {
+ return axios.get(generateUrl(endPoint + '/polls'))
+ .then((response) => {
+ context.commit('set', { list: response.data })
+ })
+ .catch((error) => {
+ console.error('Error loading polls', { error: error.response })
+ })
+ }
+ },
+
+ takeOver(context, payload) {
+ const endPoint = 'apps/polls/administration'
+ if (getCurrentUser().isAdmin) {
+ return axios.get(generateUrl(endPoint + '/poll/' + payload.pollId + '/takeover'))
+ .then((response) => {
+ return response
+ })
+ .catch((error) => {
+ throw error
+ })
+ }
+ },
+}
+
+export default { namespaced, state, mutations, getters, actions }