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.

AppItem.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. <div class="section" :class="{ selected: isSelected }" @click="showAppDetails">
  24. <div class="app-image app-image-icon" @click="showAppDetails">
  25. <div v-if="(listView && !app.preview) || (!listView && !app.screenshot)" class="icon-settings-dark" />
  26. <svg v-if="listView && app.preview"
  27. width="32"
  28. height="32"
  29. viewBox="0 0 32 32">
  30. <defs><filter :id="filterId"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" /></filter></defs>
  31. <image x="0"
  32. y="0"
  33. width="32"
  34. height="32"
  35. preserveAspectRatio="xMinYMin meet"
  36. :filter="filterUrl"
  37. :xlink:href="app.preview"
  38. class="app-icon" />
  39. </svg>
  40. <img v-if="!listView && app.screenshot" :src="app.screenshot" width="100%">
  41. </div>
  42. <div class="app-name" @click="showAppDetails">
  43. {{ app.name }}
  44. </div>
  45. <div v-if="!listView" class="app-summary">
  46. {{ app.summary }}
  47. </div>
  48. <div v-if="listView" class="app-version">
  49. <span v-if="app.version">{{ app.version }}</span>
  50. <span v-else-if="app.appstoreData.releases[0].version">{{ app.appstoreData.releases[0].version }}</span>
  51. </div>
  52. <div class="app-level">
  53. <span v-if="app.level === 300"
  54. v-tooltip.auto="t('settings', 'This app is supported via your current Nextcloud subscription.')"
  55. class="supported icon-checkmark-color">
  56. {{ t('settings', 'Supported') }}</span>
  57. <span v-if="app.level === 200"
  58. v-tooltip.auto="t('settings', 'Official apps are developed by and within the community. They offer central functionality and are ready for production use.')"
  59. class="official icon-checkmark">
  60. {{ t('settings', 'Official') }}</span>
  61. <AppScore v-if="hasRating && !listView" :score="app.score" />
  62. </div>
  63. <div class="actions">
  64. <div v-if="app.error" class="warning">
  65. {{ app.error }}
  66. </div>
  67. <div v-if="loading(app.id)" class="icon icon-loading-small" />
  68. <input v-if="app.update"
  69. class="update primary"
  70. type="button"
  71. :value="t('settings', 'Update to {update}', {update:app.update})"
  72. :disabled="installing || loading(app.id)"
  73. @click.stop="update(app.id)">
  74. <input v-if="app.canUnInstall"
  75. class="uninstall"
  76. type="button"
  77. :value="t('settings', 'Remove')"
  78. :disabled="installing || loading(app.id)"
  79. @click.stop="remove(app.id)">
  80. <input v-if="app.active"
  81. class="enable"
  82. type="button"
  83. :value="t('settings','Disable')"
  84. :disabled="installing || loading(app.id)"
  85. @click.stop="disable(app.id)">
  86. <input v-if="!app.active && (app.canInstall || app.isCompatible)"
  87. v-tooltip.auto="enableButtonTooltip"
  88. class="enable"
  89. type="button"
  90. :value="enableButtonText"
  91. :disabled="!app.canInstall || installing || loading(app.id)"
  92. @click.stop="enable(app.id)">
  93. <input v-else-if="!app.active"
  94. v-tooltip.auto="forceEnableButtonTooltip"
  95. class="enable force"
  96. type="button"
  97. :value="forceEnableButtonText"
  98. :disabled="installing || loading(app.id)"
  99. @click.stop="forceEnable(app.id)">
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import AppScore from './AppScore'
  105. import AppManagement from '../AppManagement'
  106. import SvgFilterMixin from '../SvgFilterMixin'
  107. export default {
  108. name: 'AppItem',
  109. components: {
  110. AppScore
  111. },
  112. mixins: [AppManagement, SvgFilterMixin],
  113. props: {
  114. app: {},
  115. category: {},
  116. listView: {
  117. type: Boolean,
  118. default: true
  119. }
  120. },
  121. data() {
  122. return {
  123. isSelected: false,
  124. scrolled: false
  125. }
  126. },
  127. computed: {
  128. hasRating() {
  129. return this.app.appstoreData && this.app.appstoreData.ratingNumOverall > 5
  130. }
  131. },
  132. watch: {
  133. '$route.params.id': function(id) {
  134. this.isSelected = (this.app.id === id)
  135. }
  136. },
  137. mounted() {
  138. this.isSelected = (this.app.id === this.$route.params.id)
  139. },
  140. watchers: {
  141. },
  142. methods: {
  143. showAppDetails(event) {
  144. if (event.currentTarget.tagName === 'INPUT' || event.currentTarget.tagName === 'A') {
  145. return
  146. }
  147. this.$router.push({
  148. name: 'apps-details',
  149. params: { category: this.category, id: this.app.id }
  150. })
  151. },
  152. prefix(prefix, content) {
  153. return prefix + '_' + content
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped>
  159. .force {
  160. background: var(--color-main-background);
  161. border-color: var(--color-error);
  162. color: var(--color-error);
  163. }
  164. .force:hover,
  165. .force:active {
  166. background: var(--color-error);
  167. border-color: var(--color-error) !important;
  168. color: var(--color-main-background);
  169. }
  170. </style>