App.vue 7.47 KB
Newer Older
1
2
<template>
  <div id="app">
3
4
    <div class="ui main text container instance-chooser" v-if="!$store.state.instance.instanceUrl">
      <div class="ui padded segment">
5
        <h1 class="ui header"><translate>Choose your instance</translate></h1>
6
        <form class="ui form" @submit.prevent="$store.dispatch('instance/setUrl', instanceUrl)">
7
          <p><translate>You need to select an instance in order to continue</translate></p>
8
9
          <div class="ui action input">
            <input type="text" v-model="instanceUrl">
10
            <button type="submit" class="ui button"><translate>Submit</translate></button>
11
          </div>
12
          <p>{{ $gettext('Suggested choices') }}</p>
13
14
15
          <div class="ui bulleted list">
            <div class="ui item" v-for="url in suggestedInstances">
              <a @click="instanceUrl = url">{{ url }}</a>
16
17
            </div>
          </div>
18
19
20
21
22
23
24
25
26
27
28
29
        </form>
      </div>
    </div>
    <template v-else>
      <sidebar></sidebar>
      <service-messages v-if="messages.length > 0" />
      <router-view :key="$route.fullPath"></router-view>
      <div class="ui fitted divider"></div>
      <div id="footer" class="ui vertical footer segment">
        <div class="ui container">
          <div class="ui stackable equal height stackable grid">
            <div class="three wide column">
30
              <h4 v-translate class="ui header">Links</h4>
31
32
              <div class="ui link list">
                <router-link class="item" to="/about">
33
                  <translate>About this instance</translate>
34
                </router-link>
35
36
                <a href="https://funkwhale.audio" class="item" target="_blank"><translate>Official website</translate></a>
                <a href="https://docs.funkwhale.audio" class="item" target="_blank"><translate>Documentation</translate></a>
37
                <a href="https://code.eliotberriot.com/funkwhale/funkwhale" class="item" target="_blank">
38
39
                  <translate :translate-params="{version: version}" v-if="version">Source code (%{version})</translate>
                  <translate v-else>Source code</translate>
40
                </a>
41
                <a href="https://code.eliotberriot.com/funkwhale/funkwhale/issues" class="item" target="_blank"><translate>Issue tracker</translate></a>
42
                <a @click="switchInstance" class="item" >
43
                  <translate>Use another instance</translate>
44
45
46
47
48
                  <template v-if="$store.state.instance.instanceUrl !== '/'">
                    <br>
                    ({{ $store.state.instance.instanceUrl }})
                  </template>
                </a>
49
50
51
              </div>
            </div>
            <div class="ten wide column">
52
              <h4 v-translate class="ui header">About Funkwhale</h4>
53
              <p>
54
                <translate>Funkwhale is a free and open-source project run by volunteers. You can help us improve the platform by reporting bugs, suggesting features and share the project with your friends!</translate>
55
56
              </p>
              <p>
57
                <translate>The funkwhale logo was kindly designed and provided by Francis Gading.</translate>
58
59
              </p>
            </div>
60
61
62
63
64
65
66
67
68
69
70
71
            <div class="three wide column">
              <h4 v-translate class="ui header">Options</h4>
              <div class="ui form">
                <div class="ui field">
                  <label>{{ $gettext('Change language') }}</label>
                  <select class="ui dropdown" v-model="$language.current">
                    <option v-for="(language, key) in $language.available" :value="key">{{ language }}</option>
                  </select>
                </div>
              </div>
            </div>

72
73
74
          </div>
        </div>
      </div>
75
76
77
78
79
80
      <raven
        v-if="$store.state.instance.settings.raven.front_enabled.value"
        :dsn="$store.state.instance.settings.raven.front_dsn.value">
      </raven>
      <playlist-modal v-if="$store.state.auth.authenticated"></playlist-modal>
    </template>
81
82
83
84
  </div>
</template>

<script>
85
86
import axios from 'axios'
import _ from 'lodash'
87
import {mapState} from 'vuex'
88

89
import Sidebar from '@/components/Sidebar'
Eliot Berriot's avatar
Eliot Berriot committed
90
import Raven from '@/components/Raven'
91
import ServiceMessages from '@/components/ServiceMessages'
92

Eliot Berriot's avatar
Eliot Berriot committed
93
94
import PlaylistModal from '@/components/playlists/PlaylistModal'

95
96
export default {
  name: 'app',
Eliot Berriot's avatar
Eliot Berriot committed
97
98
  components: {
    Sidebar,
Eliot Berriot's avatar
Eliot Berriot committed
99
    Raven,
100
101
    PlaylistModal,
    ServiceMessages
Eliot Berriot's avatar
Eliot Berriot committed
102
  },
103
104
  data () {
    return {
105
106
      nodeinfo: null,
      instanceUrl: null
107
108
    }
  },
109
  created () {
Eliot Berriot's avatar
Eliot Berriot committed
110
    let self = this
111
112
113
114
    setInterval(() => {
      // used to redraw ago dates every minute
      self.$store.commit('ui/computeLastDate')
    }, 1000 * 60)
115
116
117
118
119
120
    if (this.$store.state.instance.instanceUrl) {
      this.$store.commit('instance/instanceUrl', this.$store.state.instance.instanceUrl)
      this.$store.dispatch('auth/check')
      this.$store.dispatch('instance/fetchSettings')
      this.fetchNodeInfo()
    }
121
122
123
124
125
126
127
  },
  methods: {
    fetchNodeInfo () {
      let self = this
      axios.get('instance/nodeinfo/2.0/').then(response => {
        self.nodeinfo = response.data
      })
128
129
    },
    switchInstance () {
130
      let confirm = window.confirm(this.$gettext('This will erase your local data and disconnect you, do you want to continue?'))
131
132
133
      if (confirm) {
        this.$store.commit('instance/instanceUrl', null)
      }
134
135
136
    }
  },
  computed: {
137
138
139
    ...mapState({
      messages: state => state.ui.messages
    }),
140
141
142
143
144
145
146
147
    suggestedInstances () {
      let rootUrl = (
        window.location.protocol + '//' + window.location.hostname +
        (window.location.port ? ':' + window.location.port : '')
      )
      let instances = [rootUrl, 'https://demo.funkwhale.audio']
      return instances
    },
148
149
150
151
152
153
    version () {
      if (!this.nodeinfo) {
        return null
      }
      return _.get(this.nodeinfo, 'software.version')
    }
154
155
156
157
158
  },
  watch: {
    '$store.state.instance.instanceUrl' () {
      this.$store.dispatch('instance/fetchSettings')
      this.fetchNodeInfo()
159
160
161
    },
    '$language.current' (newValue) {
      this.$store.commit('ui/currentLanguage', newValue)
162
    }
163
  }
164
165
166
167
168
169
170
171
172
}
</script>

<style lang="scss">
// we do the import here instead in main.js
// as resolve order is not deterministric in webpack
// and we end up with CSS rules not applied,
// see https://github.com/webpack/webpack/issues/215
@import 'semantic/semantic.css';
173
@import 'style/vendor/media';
174
175


176
177
html, body {
  @include media("<desktop") {
178
    font-size: 90%;
179
180
  }
}
181
182
183
184
185
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
186
187
188
189
190

.instance-chooser {
  margin-top: 2em;
}

191
.main.pusher, .footer {
192
193
194
  @include media(">desktop") {
    margin-left: 350px !important;
  }
195
  transform: none !important;
196
}
197
198
199
200
201
202
203
204
.service-messages {
  position: fixed;
  bottom: 1em;
  left: 1em;
  @include media(">desktop") {
    left: 350px;
  }
}
205
.main-pusher {
206
207
  padding: 1.5rem 0;
}
208
209
210
211
212
.ui.stripe.segment, #footer {
  padding: 2em;
  @include media(">tablet") {
    padding: 4em;
  }
213
214
}

215
216
217
218
219
220
.ellipsis {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
.ui.small.text.container {
  max-width: 500px !important;
}

.button.icon.tiny {
    padding: 0.5em !important;
}

.sidebar {
  .logo {
    path {
      fill: white;
    }
  }
}

.discrete.link {
    color: rgba(0, 0, 0, 0.87);
239
    cursor: pointer;
240
241
242
243
244
}

.floated.buttons .button ~ .dropdown {
  border-left: none;
}
245
246
247
248

.ui.icon.header .circular.icon {
  display: flex;
  justify-content: center;
249

250
251
252
253
254
255
}

.segment-content .button{
  margin:  0.5em;
}

256
</style>