DetailBase.vue 9.05 KB
Newer Older
1
2
3
4
5
6
<template>
  <main v-title="labels.title">
    <div class="ui vertical stripe segment container">
      <div v-if="isLoading" class="ui centered active inline loader"></div>
      <div class="ui stackable grid" v-else-if="object">
        <div class="ui five wide column">
7
          <button class="ui pointing dropdown icon small basic right floated button" ref="dropdown" v-dropdown="{direction: 'downward'}" style="position: absolute; right: 1em; top: 1em;">
8
9
            <i class="ellipsis vertical icon"></i>
            <div class="menu">
10
11
12
13
14
15
16
17
              <a
                :href="object.fid"
                v-if="object.actor.domain != $store.getters['instance/domain']"
                target="_blank"
                class="basic item">
                <i class="external icon"></i>
                <translate :translate-params="{domain: object.actor.domain}" translate-context="Content/*/Button.Label/Verb">View on %{ domain }</translate>
              </a>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
              <div
                role="button"
                class="basic item"
                v-for="obj in getReportableObjs({library: object})"
                :key="obj.target.type + obj.target.id"
                @click.stop.prevent="$store.dispatch('moderation/report', obj.target)">
                <i class="share icon" /> {{ obj.label }}
              </div>

              <div class="divider"></div>
              <router-link class="basic item" v-if="$store.state.auth.availablePermissions['moderation']" :to="{name: 'manage.library.libraries.detail', params: {id: object.uuid}}">
                <i class="wrench icon"></i>
                <translate translate-context="Content/Moderation/Link">Open in moderation interface</translate>
              </router-link>
            </div>
33
          </button>
34
35
36
37
          <h1 class="ui header">
            <div class="ui hidden divider"></div>
            <div class="ellipsis content">
              <i class="layer group small icon"></i>
38
              <span>{{ object.name }}</span>
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
              <div class="ui very small hidden divider"></div>
              <div class="sub header ellipsis" :title="object.full_username">
                <actor-link :avatar="false" :actor="object.actor" :truncate-length="0">
                  <translate translate-context="*/*/*" :translate-params="{username: object.actor.full_username}">Owned by %{ username }</translate>
                </actor-link>
              </div>
            </div>
          </h1>
          <p>
            <span v-if="object.privacy_level === 'me'" :title="labels.tooltips.me">
              <i class="lock icon"></i>
              {{ labels.visibility.me }}
            </span>
            <span
              v-else-if="object.privacy_level === 'instance'" :title="labels.tooltips.instance">
              <i class="lock open icon"></i>
              {{ labels.visibility.instance }}
            </span>
            <span v-else-if="object.privacy_level === 'everyone'" :title="labels.tooltips.everyone">
              <i class="globe icon"></i>
              {{ labels.visibility.everyone }}
            </span> ·
            <i class="music icon"></i>
            <translate translate-context="*/*/*" :translate-params="{count: object.uploads_count}" :translate-n="object.uploads_count" translate-plural="%{ count } tracks">%{ count } track</translate>
            <span v-if="object.size">
              · <i class="database icon"></i>
              {{ object.size | humanSize }}
            </span>
          </p>

          <div class="header-buttons">
            <div class="ui small buttons">
              <radio-button :disabled="!isPlayable" type="library" :object-id="object.uuid"></radio-button>
            </div>
            <div class="ui small buttons" v-if="!isOwner">
              <library-follow-button v-if="$store.state.auth.authenticated" :library="object"></library-follow-button>
            </div>
          </div>

          <template v-if="$store.getters['ui/layoutVersion'] === 'large'">
            <rendered-description
              :content="object.description ? {html: object.description} : null"
              :update-url="`channels/${object.uuid}/`"
              :can-update="false"></rendered-description>
              <div class="ui hidden divider"></div>
          </template>
85
86
87
88
89
90
91
92
93
          <div class="ui form">
            <div class="field">
              <label for="copy-input">
                <translate translate-context="Content/Library/Title">Sharing link</translate>
              </label>
              <p><translate translate-context="Content/Library/Paragraph">Share this link with other users so they can request access to this library by copy-pasting it in their pod search bar.</translate></p>
              <copy-input :value="object.fid" />
            </div>
          </div>
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
        </div>
        <div class="ui eleven wide column">
          <div class="ui head vertical stripe segment">
            <div class="ui container">
              <div class="ui secondary pointing center aligned menu">
                <router-link class="item" :exact="true" :to="{name: 'library.detail'}">
                  <translate translate-context="*/*/*">Artists</translate>
                </router-link>
                <router-link class="item" :exact="true" :to="{name: 'library.detail.albums'}">
                  <translate translate-context="*/*/*">Albums</translate>
                </router-link>
                <router-link class="item" :exact="true" :to="{name: 'library.detail.tracks'}">
                  <translate translate-context="*/*/*">Tracks</translate>
                </router-link>
                <router-link v-if="isOwner" class="item" :exact="true" :to="{name: 'library.detail.upload'}">
                  <i class="upload icon"></i>
                  <translate translate-context="Content/Library/Card.Button.Label/Verb">Upload</translate>
                </router-link>
                <router-link v-if="isOwner" class="item" :exact="true" :to="{name: 'library.detail.edit'}">
                  <i class="pencil icon"></i>
                  <translate translate-context="Content/*/Button.Label/Verb">Edit</translate>
                </router-link>
              </div>
              <div class="ui hidden divider"></div>
                <router-view
                  @updated="fetchData"
                  @uploads-finished="object.uploads_count += $event"
                  :is-owner="isOwner"
                  :object="object"></router-view>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>
</template>

<script>
import axios from "axios"
import PlayButton from "@/components/audio/PlayButton"
import LibraryFollowButton from "@/components/audio/LibraryFollowButton"
import ReportMixin from '@/components/mixins/Report'
import RadioButton from '@/components/radios/Button'

export default {
  mixins: [ReportMixin],
  props: ["id"],
  components: {
    PlayButton,
    RadioButton,
    LibraryFollowButton
  },
  data() {
    return {
      isLoading: true,
      object: null,
      latestTracks: null,
    }
  },
  beforeRouteUpdate (to, from, next) {
    to.meta.preserveScrollPosition = true
    next()
  },
  async created() {
    await this.fetchData()
159
160
161
162
    let authenticated = this.$store.state.auth.authenticated
    if (!authenticated && this.$store.getters['instance/domain'] != this.object.actor.domain) {
      this.$router.push({name: 'login', query: {next: this.$route.fullPath}})
    }
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  },
  methods: {
    async fetchData() {
      var self = this
      this.isLoading = true
      let libraryPromise = axios.get(`libraries/${this.id}`).then(response => {
        self.object = response.data
      })
      await libraryPromise
      self.isLoading = false
    },
  },
  computed: {
    isOwner () {
      return this.$store.state.auth.authenticated && this.object.actor.full_username === this.$store.state.auth.fullUsername
    },
    labels () {
      return {
        title: this.$pgettext('*/*/*', 'Library'),
        visibility: {
          me: this.$pgettext('Content/Library/Card.Help text', 'Private'),
          instance: this.$pgettext('Content/Library/Card.Help text', 'Restricted'),
          everyone: this.$pgettext('Content/Library/Card.Help text', 'Public'),
        },
        tooltips: {
          me: this.$pgettext('Content/Library/Card.Help text', 'This library is private and your approval from its owner is needed to access its content'),
          instance: this.$pgettext('Content/Library/Card.Help text', 'This library is restricted to users on this pod only'),
          everyone: this.$pgettext('Content/Library/Card.Help text', 'This library is public and you can access its content freely'),
        }
      }
    },
    isPlayable () {
      return this.object.uploads_count > 0 && (
        this.isOwner ||
197
        this.object.privacy_level === 'everyone' ||
198
199
200
201
202
203
204
205
206
207
208
209
        (this.object.privacy_level === 'instance' && this.$store.state.auth.authenticated && this.object.actor.domain === this.$store.getters['instance/domain']) ||
        (this.$store.getters['libraries/follow'](this.object.uuid) || {}).approved === true
      )
    },
  },
  watch: {
    id() {
      this.fetchData()
    }
  }
}
</script>