You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <!--
  2. - @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  3. -
  4. - @author Julius Härtl <jus@bitgrid.net>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -
  21. -->
  22. <template>
  23. <AppContent app-name="settings" :class="{ 'with-app-sidebar': currentApp}"
  24. :content-class="{ 'icon-loading': loadingList }" :navigation-class="{ 'icon-loading': loading }">
  25. <template #navigation>
  26. <ul id="appscategories">
  27. <AppNavigationItem v-for="item in menu" :key="item.key" :item="item" />
  28. </ul>
  29. </template>
  30. <template #content class="app-settings-content" :class="{ 'icon-loading': loadingList }">
  31. <app-list :category="category" :app="currentApp" :search="searchQuery"></app-list>
  32. </template>
  33. <template #sidebar v-if="id && currentApp" >
  34. <app-details :category="category" :app="currentApp"></app-details>
  35. </template>
  36. </AppContent>
  37. </template>
  38. <script>
  39. import { AppContent, AppNavigationItem } from 'nextcloud-vue';
  40. import appList from '../components/appList';
  41. import Vue from 'vue';
  42. import VueLocalStorage from 'vue-localstorage'
  43. import AppDetails from '../components/appDetails';
  44. Vue.use(VueLocalStorage)
  45. export default {
  46. name: 'Apps',
  47. props: {
  48. category: {
  49. type: String,
  50. default: 'installed',
  51. },
  52. id: {
  53. type: String,
  54. default: '',
  55. }
  56. },
  57. components: {
  58. AppContent,
  59. AppDetails,
  60. appList,
  61. AppNavigationItem,
  62. },
  63. methods: {
  64. setSearch(query) {
  65. this.searchQuery = query;
  66. },
  67. resetSearch() {
  68. this.setSearch('');
  69. }
  70. },
  71. beforeMount() {
  72. this.$store.dispatch('getCategories');
  73. this.$store.dispatch('getAllApps');
  74. this.$store.dispatch('getGroups', {offset: 0, limit: 5});
  75. this.$store.commit('setUpdateCount', this.$store.getters.getServerData.updateCount)
  76. },
  77. mounted() {
  78. /**
  79. * Register search
  80. */
  81. this.appSearch = new OCA.Search(this.setSearch, this.resetSearch);
  82. },
  83. data() {
  84. return {
  85. searchQuery: ''
  86. }
  87. },
  88. watch: {
  89. category: function (val, old) {
  90. this.setSearch('');
  91. }
  92. },
  93. computed: {
  94. loading() {
  95. return this.$store.getters.loading('categories');
  96. },
  97. loadingList() {
  98. return this.$store.getters.loading('list');
  99. },
  100. currentApp() {
  101. return this.apps.find(app => app.id === this.id );
  102. },
  103. categories() {
  104. return this.$store.getters.getCategories;
  105. },
  106. apps() {
  107. return this.$store.getters.getAllApps;
  108. },
  109. updateCount() {
  110. return this.$store.getters.getUpdateCount;
  111. },
  112. settings() {
  113. return this.$store.getters.getServerData;
  114. },
  115. // BUILD APP NAVIGATION MENU OBJECT
  116. menu() {
  117. // Data provided php side
  118. let categories = this.$store.getters.getCategories;
  119. categories = Array.isArray(categories) ? categories : [];
  120. // Map groups
  121. categories = categories.map(category => {
  122. let item = {};
  123. item.id = 'app-category-' + category.ident;
  124. item.icon = 'icon-category-' + category.ident;
  125. item.classes = []; // empty classes, active will be set later
  126. item.router = { // router link to
  127. name: 'apps-category',
  128. params: {category: category.ident}
  129. };
  130. item.text = category.displayName;
  131. return item;
  132. });
  133. // Add everyone group
  134. let defaultCategories = [
  135. {
  136. id: 'app-category-your-apps',
  137. classes: [],
  138. router: {name: 'apps'},
  139. icon: 'icon-category-installed',
  140. text: t('settings', 'Your apps'),
  141. },
  142. {
  143. id: 'app-category-enabled',
  144. classes: [],
  145. icon: 'icon-category-enabled',
  146. router: {name: 'apps-category', params: {category: 'enabled'}},
  147. text: t('settings', 'Active apps'),
  148. }, {
  149. id: 'app-category-disabled',
  150. classes: [],
  151. icon: 'icon-category-disabled',
  152. router: {name: 'apps-category', params: {category: 'disabled'}},
  153. text: t('settings', 'Disabled apps'),
  154. }
  155. ];
  156. if (!this.settings.appstoreEnabled) {
  157. return defaultCategories
  158. }
  159. if (this.$store.getters.getUpdateCount > 0) {
  160. defaultCategories.push({
  161. id: 'app-category-updates',
  162. classes: [],
  163. icon: 'icon-download',
  164. router: {name: 'apps-category', params: {category: 'updates'}},
  165. text: t('settings', 'Updates'),
  166. utils: {counter: this.$store.getters.getUpdateCount}
  167. });
  168. }
  169. defaultCategories.push({
  170. id: 'app-category-app-bundles',
  171. classes: [],
  172. icon: 'icon-category-app-bundles',
  173. router: {name: 'apps-category', params: {category: 'app-bundles'}},
  174. text: t('settings', 'App bundles'),
  175. });
  176. categories = defaultCategories.concat(categories);
  177. // Set current group as active
  178. let activeGroup = categories.findIndex(group => group.id === 'app-category-' + this.category);
  179. if (activeGroup >= 0) {
  180. categories[activeGroup].classes.push('active');
  181. } else {
  182. categories[0].classes.push('active');
  183. }
  184. categories.push({
  185. id: 'app-developer-docs',
  186. classes: [],
  187. href: this.settings.developerDocumentation,
  188. text: t('settings', 'Developer documentation') + ' ↗',
  189. });
  190. // Return
  191. return categories
  192. },
  193. }
  194. }
  195. </script>