From 125d1d3d4e7494a0982b1f2adec1e8de2b91b5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 10 May 2018 13:26:29 +0200 Subject: [PATCH] Add file skeleton for app settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- settings/Controller/AppSettingsController.php | 2 + settings/src/components/appDetails.vue | 187 ++++++++++++++++++ settings/src/components/appList.vue | 116 +++++++++++ settings/src/router.js | 21 ++ settings/src/store/apps.js | 99 ++++++++++ settings/src/store/index.js | 2 + settings/src/views/Apps.vue | 157 +++++++++++++++ 7 files changed, 584 insertions(+) create mode 100644 settings/src/components/appDetails.vue create mode 100644 settings/src/components/appList.vue create mode 100644 settings/src/store/apps.js create mode 100644 settings/src/views/Apps.vue diff --git a/settings/Controller/AppSettingsController.php b/settings/Controller/AppSettingsController.php index 234001e1899..15b688736fa 100644 --- a/settings/Controller/AppSettingsController.php +++ b/settings/Controller/AppSettingsController.php @@ -150,7 +150,9 @@ class AppSettingsController extends Controller { $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com'); $templateResponse->setContentSecurityPolicy($policy); + return new TemplateResponse('settings', 'settings', ['serverData' => $params]); return $templateResponse; + } private function getAllCategories() { diff --git a/settings/src/components/appDetails.vue b/settings/src/components/appDetails.vue new file mode 100644 index 00000000000..d007555dd5b --- /dev/null +++ b/settings/src/components/appDetails.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/settings/src/components/appList.vue b/settings/src/components/appList.vue new file mode 100644 index 00000000000..8dc7fede01d --- /dev/null +++ b/settings/src/components/appList.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/settings/src/router.js b/settings/src/router.js index 270949d542c..bfcff91e992 100644 --- a/settings/src/router.js +++ b/settings/src/router.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import Router from 'vue-router'; import Users from './views/Users'; +import Apps from './views/Apps'; Vue.use(Router); @@ -32,6 +33,26 @@ export default new Router({ component: Users } ] + }, + { + path: '/:index(index.php/)?settings/apps', + component: Apps, + props: true, + name: 'apps', + children: [ + { + path: ':category', + name: 'apps-category', + component: Apps, + children: [ + { + path: ':id', + name: 'apps-details', + component: Apps + } + ] + } + ] } ] }); diff --git a/settings/src/store/apps.js b/settings/src/store/apps.js new file mode 100644 index 00000000000..d9888465dd6 --- /dev/null +++ b/settings/src/store/apps.js @@ -0,0 +1,99 @@ +/* + * @copyright Copyright (c) 2018 Julius Härtl + * + * @author Julius Härtl + * + * @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 . + * + */ + +import api from './api'; + +const state = { + apps: [], + categories: [], + updateCount: 0 +}; + +const mutations = { + initCategories(state, {categories, updateCount}) { + state.categories = categories; + state.updateCount = updateCount; + }, + + setUpdateCount(state, updateCount) { + state.updateCount = updateCount; + }, + + addCategory(state, category) { + state.categories.push(category); + }, + + appendCategories(state, categoriesArray) { + // convert obj to array + state.categories = categoriesArray; + }, + + setApps(state, apps) { + state.apps = apps; + }, + + reset(state) { + state.apps = []; + state.categories = []; + state.updateCount = 0; + } +}; + +const getters = { + getCategories(state) { + return state.categories; + }, + getApps(state) { + return state.apps; + }, + getUpdateCount(state) { + return state.updateCount; + } +}; + +const actions = { + + getApps(context, { category }) { + return api.get(OC.generateUrl(`settings/apps/list?category=${category}`)) + .then((response) => { + context.commit('setApps', response.data.apps); + return true; + }) + .catch((error) => context.commit('API_FAILURE', error)) + + }, + + getCategories(context) { + return api.get(OC.generateUrl('settings/apps/categories')) + .then((response) => { + if (response.data.length > 0) { + context.commit('appendCategories', response.data); + return true; + } + return false; + }) + .catch((error) => context.commit('API_FAILURE', error)); + }, + +}; + +export default { state, mutations, getters, actions }; \ No newline at end of file diff --git a/settings/src/store/index.js b/settings/src/store/index.js index 2bd8d76e41b..00f3ad809ad 100644 --- a/settings/src/store/index.js +++ b/settings/src/store/index.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import Vuex from 'vuex'; import users from './users'; +import apps from './apps'; import settings from './settings'; import oc from './oc'; @@ -23,6 +24,7 @@ const mutations = { export default new Vuex.Store({ modules: { users, + apps, settings, oc }, diff --git a/settings/src/views/Apps.vue b/settings/src/views/Apps.vue new file mode 100644 index 00000000000..eac9bec7527 --- /dev/null +++ b/settings/src/views/Apps.vue @@ -0,0 +1,157 @@ + + + + + +