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 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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" v-bind:class="{ selected: isSelected }" v-on:click="showAppDetails">
  24. <div class="app-image app-image-icon" v-on:click="showAppDetails">
  25. <div v-if="(listView && !app.preview) || (!listView && !app.screenshot)" class="icon-settings-dark"></div>
  26. <svg v-if="listView && app.preview" width="32" height="32" viewBox="0 0 32 32">
  27. <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"></feColorMatrix></filter></defs>
  28. <image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" :filter="filterUrl" :xlink:href="app.preview" class="app-icon"></image>
  29. </svg>
  30. <img v-if="!listView && app.screenshot" :src="app.screenshot" width="100%" />
  31. </div>
  32. <div class="app-name" v-on:click="showAppDetails">
  33. {{ app.name }}
  34. </div>
  35. <div class="app-summary" v-if="!listView">{{ app.summary }}</div>
  36. <div class="app-version" v-if="listView">
  37. <span v-if="app.version">{{ app.version }}</span>
  38. <span v-else-if="app.appstoreData.releases[0].version">{{ app.appstoreData.releases[0].version }}</span>
  39. </div>
  40. <div class="app-level">
  41. <span class="official icon-checkmark" v-if="app.level === 200"
  42. v-tooltip.auto="t('settings', 'Official apps are developed by and within the community. They offer central functionality and are ready for production use.')">
  43. {{ t('settings', 'Official') }}</span>
  44. <app-score v-if="!listView" :score="app.score"></app-score>
  45. </div>
  46. <div class="actions">
  47. <div class="warning" v-if="app.error">{{ app.error }}</div>
  48. <div class="icon icon-loading-small" v-if="loading(app.id)"></div>
  49. <input v-if="app.update" class="update primary" type="button" :value="t('settings', 'Update to {update}', {update:app.update})" v-on:click.stop="update(app.id)" :disabled="installing || loading(app.id)" />
  50. <input v-if="app.canUnInstall" class="uninstall" type="button" :value="t('settings', 'Remove')" v-on:click.stop="remove(app.id)" :disabled="installing || loading(app.id)" />
  51. <input v-if="app.active" class="enable" type="button" :value="t('settings','Disable')" v-on:click.stop="disable(app.id)" :disabled="installing || loading(app.id)" />
  52. <input v-if="!app.active && (app.canInstall || app.isCompatible)" class="enable" type="button" :value="enableButtonText" v-on:click.stop="enable(app.id)" v-tooltip.auto="enableButtonTooltip" :disabled="!app.canInstall || installing || loading(app.id)" />
  53. <input v-else-if="!app.active" class="enable force" type="button" :value="forceEnableButtonText" v-on:click.stop="forceEnable(app.id)" v-tooltip.auto="forceEnableButtonTooltip" :disabled="installing || loading(app.id)" />
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import Multiselect from 'vue-multiselect';
  59. import AppScore from './appScore';
  60. import AppManagement from '../appManagement';
  61. import SvgFilterMixin from '../svgFilterMixin';
  62. export default {
  63. name: 'appItem',
  64. mixins: [AppManagement, SvgFilterMixin],
  65. props: {
  66. app: {},
  67. category: {},
  68. listView: {
  69. type: Boolean,
  70. default: true,
  71. }
  72. },
  73. watch: {
  74. '$route.params.id': function (id) {
  75. this.isSelected = (this.app.id === id);
  76. }
  77. },
  78. components: {
  79. Multiselect,
  80. AppScore,
  81. },
  82. data() {
  83. return {
  84. isSelected: false,
  85. scrolled: false,
  86. };
  87. },
  88. mounted() {
  89. this.isSelected = (this.app.id === this.$route.params.id);
  90. },
  91. computed: {
  92. },
  93. watchers: {
  94. },
  95. methods: {
  96. showAppDetails(event) {
  97. if (event.currentTarget.tagName === 'INPUT' || event.currentTarget.tagName === 'A') {
  98. return;
  99. }
  100. this.$router.push({
  101. name: 'apps-details',
  102. params: {category: this.category, id: this.app.id}
  103. });
  104. },
  105. prefix(prefix, content) {
  106. return prefix + '_' + content;
  107. },
  108. }
  109. }
  110. </script>
  111. <style scoped>
  112. .force {
  113. background: var(--color-main-background);
  114. border-color: var(--color-error);
  115. color: var(--color-error);
  116. }
  117. .force:hover,
  118. .force:active {
  119. background: var(--color-error);
  120. border-color: var(--color-error) !important;
  121. color: var(--color-main-background);
  122. }
  123. </style>