Verified Commit bb3ed760 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch 'release/0.4'

parents c7d6ad95 a38ca1ed
......@@ -41,14 +41,13 @@
</template>
<script>
import axios from 'axios'
import logger from '@/logging'
import backend from '@/audio/backend'
import PlayButton from '@/components/audio/PlayButton'
import TrackTable from '@/components/audio/track/Table'
import config from '@/config'
const FETCH_URL = config.API_URL + 'albums/'
const FETCH_URL = 'albums/'
export default {
props: ['id'],
......@@ -71,7 +70,7 @@ export default {
this.isLoading = true
let url = FETCH_URL + this.id + '/'
logger.default.debug('Fetching album "' + this.id + '"')
this.$http.get(url).then((response) => {
axios.get(url).then((response) => {
self.album = backend.Album.clean(response.data)
self.isLoading = false
})
......
......@@ -41,15 +41,14 @@
</template>
<script>
import axios from 'axios'
import logger from '@/logging'
import backend from '@/audio/backend'
import AlbumCard from '@/components/audio/album/Card'
import RadioButton from '@/components/radios/Button'
import PlayButton from '@/components/audio/PlayButton'
import config from '@/config'
const FETCH_URL = config.API_URL + 'artists/'
const FETCH_URL = 'artists/'
export default {
props: ['id'],
......@@ -74,7 +73,7 @@ export default {
this.isLoading = true
let url = FETCH_URL + this.id + '/'
logger.default.debug('Fetching artist "' + this.id + '"')
this.$http.get(url).then((response) => {
axios.get(url).then((response) => {
self.artist = response.data
self.albums = JSON.parse(JSON.stringify(self.artist.albums)).map((album) => {
return backend.Album.clean(album)
......
......@@ -57,10 +57,10 @@
</template>
<script>
import axios from 'axios'
import _ from 'lodash'
import $ from 'jquery'
import config from '@/config'
import backend from '@/audio/backend'
import logger from '@/logging'
......@@ -69,7 +69,7 @@ import PaginationMixin from '@/components/mixins/Pagination'
import ArtistCard from '@/components/audio/artist/Card'
import Pagination from '@/components/Pagination'
const FETCH_URL = config.API_URL + 'artists/'
const FETCH_URL = 'artists/'
export default {
mixins: [OrderingMixin, PaginationMixin],
......@@ -124,7 +124,7 @@ export default {
ordering: this.getOrderingAsString()
}
logger.default.debug('Fetching artists')
this.$http.get(url, {params: params}).then((response) => {
axios.get(url, {params: params}).then((response) => {
self.result = response.data
self.result.results.map((artist) => {
var albums = JSON.parse(JSON.stringify(artist.albums)).map((album) => {
......
......@@ -24,14 +24,14 @@
</template>
<script>
import axios from 'axios'
import Search from '@/components/audio/Search'
import backend from '@/audio/backend'
import logger from '@/logging'
import ArtistCard from '@/components/audio/artist/Card'
import config from '@/config'
import RadioCard from '@/components/radios/Card'
const ARTISTS_URL = config.API_URL + 'artists/'
const ARTISTS_URL = 'artists/'
export default {
name: 'library',
......@@ -58,7 +58,7 @@ export default {
}
let url = ARTISTS_URL
logger.default.time('Loading latest artists')
this.$http.get(url, {params: params}).then((response) => {
axios.get(url, {params: params}).then((response) => {
self.artists = response.data.results
self.artists.map((artist) => {
var albums = JSON.parse(JSON.stringify(artist.albums)).map((album) => {
......
......@@ -22,8 +22,12 @@ export default {
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">
@import '../../style/vendor/media';
.library.pusher > .ui.secondary.menu {
margin: 0 2.5rem;
@include media(">tablet") {
margin: 0 2.5rem;
}
.item {
padding-top: 1.5em;
padding-bottom: 1.5em;
......@@ -37,7 +41,10 @@ export default {
padding: 0;
.segment-content {
margin: 0 auto;
padding: 4em;
padding: 2em;
@include media(">tablet") {
padding: 4em;
}
}
&.with-background {
.header {
......
......@@ -59,10 +59,10 @@
</template>
<script>
import axios from 'axios'
import _ from 'lodash'
import $ from 'jquery'
import config from '@/config'
import logger from '@/logging'
import OrderingMixin from '@/components/mixins/Ordering'
......@@ -70,7 +70,7 @@ import PaginationMixin from '@/components/mixins/Pagination'
import RadioCard from '@/components/radios/Card'
import Pagination from '@/components/Pagination'
const FETCH_URL = config.API_URL + 'radios/radios/'
const FETCH_URL = 'radios/radios/'
export default {
mixins: [OrderingMixin, PaginationMixin],
......@@ -125,7 +125,7 @@ export default {
ordering: this.getOrderingAsString()
}
logger.default.debug('Fetching radios')
this.$http.get(url, {params: params}).then((response) => {
axios.get(url, {params: params}).then((response) => {
self.result = response.data
self.isLoading = false
})
......
......@@ -60,15 +60,14 @@
</template>
<script>
import axios from 'axios'
import url from '@/utils/url'
import logger from '@/logging'
import backend from '@/audio/backend'
import PlayButton from '@/components/audio/PlayButton'
import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
import config from '@/config'
const FETCH_URL = config.API_URL + 'tracks/'
const FETCH_URL = 'tracks/'
export default {
props: ['id'],
......@@ -94,7 +93,7 @@ export default {
this.isLoadingTrack = true
let url = FETCH_URL + this.id + '/'
logger.default.debug('Fetching track "' + this.id + '"')
this.$http.get(url).then((response) => {
axios.get(url).then((response) => {
self.track = response.data
self.isLoadingTrack = false
})
......@@ -104,7 +103,7 @@ export default {
this.isLoadingLyrics = true
let url = FETCH_URL + this.id + '/lyrics/'
logger.default.debug('Fetching lyrics for track "' + this.id + '"')
this.$http.get(url).then((response) => {
axios.get(url).then((response) => {
self.lyrics = response.data
self.isLoadingLyrics = false
}, (response) => {
......
......@@ -37,8 +37,8 @@
<script>
import Vue from 'vue'
import axios from 'axios'
import logger from '@/logging'
import config from '@/config'
import ImportMixin from './ImportMixin'
import ReleaseImport from './ReleaseImport'
......@@ -92,9 +92,8 @@ export default Vue.extend({
fetchReleaseGroupsData () {
let self = this
this.releaseGroups.forEach(group => {
let url = config.API_URL + 'providers/musicbrainz/releases/browse/' + group.id + '/'
let resource = Vue.resource(url)
resource.get({}).then((response) => {
let url = 'providers/musicbrainz/releases/browse/' + group.id + '/'
return axios.get(url).then((response) => {
logger.default.info('successfully fetched release group', group.id)
let release = response.data['release-list'].filter(r => {
return r.status === 'Official'
......
......@@ -17,7 +17,7 @@
<div v-if="batch.status === 'pending'" class="label">Importing {{ batch.jobs.length }} tracks...</div>
<div v-if="batch.status === 'finished'" class="label">Imported {{ batch.jobs.length }} tracks!</div>
</div>
<table class="ui table">
<table class="ui unstackable table">
<thead>
<tr>
<th>Job ID</th>
......@@ -52,11 +52,10 @@
</template>
<script>
import axios from 'axios'
import logger from '@/logging'
import config from '@/config'
const FETCH_URL = config.API_URL + 'import-batches/'
const FETCH_URL = 'import-batches/'
export default {
props: ['id'],
......@@ -75,7 +74,7 @@ export default {
this.isLoading = true
let url = FETCH_URL + this.id + '/'
logger.default.debug('Fetching batch "' + this.id + '"')
this.$http.get(url).then((response) => {
axios.get(url).then((response) => {
self.batch = response.data
self.isLoading = false
if (self.batch.status === 'pending') {
......
......@@ -12,7 +12,7 @@
:disabled="!nextLink">Next <i class="right arrow icon"></i></button>
<div class="ui hidden clearing divider"></div>
<div class="ui hidden clearing divider"></div>
<table v-if="results.length > 0" class="ui table">
<table v-if="results.length > 0" class="ui unstackable table">
<thead>
<tr>
<th>ID</th>
......@@ -42,10 +42,10 @@
</template>
<script>
import axios from 'axios'
import logger from '@/logging'
import config from '@/config'
const BATCHES_URL = config.API_URL + 'import-batches/'
const BATCHES_URL = 'import-batches/'
export default {
components: {},
......@@ -65,7 +65,7 @@ export default {
var self = this
this.isLoading = true
logger.default.time('Loading import batches')
this.$http.get(url, {}).then((response) => {
axios.get(url, {}).then((response) => {
self.results = response.data.results
self.nextLink = response.data.next
self.previousLink = response.data.previous
......
......@@ -62,10 +62,9 @@
</template>
<script>
import Vue from 'vue'
import axios from 'axios'
import logger from '@/logging'
import FileUploadWidget from './FileUploadWidget'
import config from '@/config'
export default {
components: {
......@@ -74,7 +73,7 @@ export default {
data () {
return {
files: [],
uploadUrl: config.API_URL + 'import-jobs/',
uploadUrl: 'import-jobs/',
batch: null
}
},
......@@ -106,9 +105,7 @@ export default {
},
createBatch () {
let self = this
let url = config.API_URL + 'import-batches/'
let resource = Vue.resource(url)
resource.save({}, {}).then((response) => {
return axios.post('import-batches/', {}).then((response) => {
self.batch = response.data
}, (response) => {
logger.default.error('error while launching creating batch')
......
......@@ -3,9 +3,8 @@
</template>
<script>
import axios from 'axios'
import logger from '@/logging'
import config from '@/config'
import Vue from 'vue'
import router from '@/router'
export default {
......@@ -31,10 +30,9 @@ export default {
launchImport () {
let self = this
this.isImporting = true
let url = config.API_URL + 'submit/' + self.importType + '/'
let url = 'submit/' + self.importType + '/'
let payload = self.importData
let resource = Vue.resource(url)
resource.save({}, payload).then((response) => {
axios.post(url, payload).then((response) => {
logger.default.info('launched import for', self.type, self.metadata.id)
self.isImporting = false
router.push({
......
......@@ -70,9 +70,9 @@
</template>
<script>
import axios from 'axios'
import Vue from 'vue'
import time from '@/utils/time'
import config from '@/config'
import logger from '@/logging'
import ImportMixin from './ImportMixin'
......@@ -117,10 +117,8 @@ export default Vue.extend({
search () {
let self = this
this.isLoading = true
let url = config.API_URL + 'providers/' + this.currentBackendId + '/search/'
let resource = Vue.resource(url)
resource.get({query: this.query}).then((response) => {
let url = 'providers/' + this.currentBackendId + '/search/'
axios.get(url, {params: {query: this.query}}).then((response) => {
logger.default.debug('searching', self.query, 'on', self.currentBackendId)
self.results = response.data
self.isLoading = false
......
......@@ -67,7 +67,7 @@
</div>
</template>
<script>
import config from '@/config'
import axios from 'axios'
import $ from 'jquery'
import _ from 'lodash'
import BuilderFilter from './Filter'
......@@ -107,8 +107,8 @@ export default {
methods: {
fetchFilters: function () {
let self = this
let url = config.API_URL + 'radios/radios/filters/'
return this.$http.get(url).then((response) => {
let url = 'radios/radios/filters/'
return axios.get(url).then((response) => {
self.availableFilters = response.data
})
},
......@@ -130,8 +130,8 @@ export default {
},
fetch: function () {
let self = this
let url = config.API_URL + 'radios/radios/' + this.id + '/'
this.$http.get(url).then((response) => {
let url = 'radios/radios/' + this.id + '/'
axios.get(url).then((response) => {
self.filters = response.data.config.map(f => {
return {
config: f,
......@@ -145,7 +145,7 @@ export default {
},
fetchCandidates: function () {
let self = this
let url = config.API_URL + 'radios/radios/validate/'
let url = 'radios/radios/validate/'
let final = this.filters.map(f => {
let c = _.clone(f.config)
c.type = f.filter.type
......@@ -156,7 +156,7 @@ export default {
{'type': 'group', filters: final}
]
}
this.$http.post(url, final).then((response) => {
axios.post(url, final).then((response) => {
self.checkResult = response.data.filters[0]
})
},
......@@ -173,12 +173,12 @@ export default {
'config': final
}
if (this.id) {
let url = config.API_URL + 'radios/radios/' + this.id + '/'
this.$http.put(url, final).then((response) => {
let url = 'radios/radios/' + this.id + '/'
axios.put(url, final).then((response) => {
})
} else {
let url = config.API_URL + 'radios/radios/'
this.$http.post(url, final).then((response) => {
let url = 'radios/radios/'
axios.post(url, final).then((response) => {
self.$router.push({
name: 'library.radios.edit',
params: {
......
......@@ -62,6 +62,7 @@
</tr>
</template>
<script>
import axios from 'axios'
import config from '@/config'
import $ from 'jquery'
import _ from 'lodash'
......@@ -132,11 +133,11 @@ export default {
methods: {
fetchCandidates: function () {
let self = this
let url = config.API_URL + 'radios/radios/validate/'
let url = 'radios/radios/validate/'
let final = _.clone(this.config)
final.type = this.filter.type
final = {'filters': [final]}
this.$http.post(url, final).then((response) => {
axios.post(url, final).then((response) => {
self.checkResult = response.data.filters[0]
})
}
......
......@@ -3,11 +3,9 @@
</template>
<script>
import axios from 'axios'
import logger from '@/logging'
import config from '@/config'
import Vue from 'vue'
export default {
props: {
mbId: {type: String, required: true}
......@@ -25,9 +23,8 @@ export default {
fetchData () {
let self = this
this.isLoading = true
let url = config.API_URL + 'providers/musicbrainz/' + this.type + 's/' + this.mbId + '/'
let resource = Vue.resource(url)
resource.get({}).then((response) => {
let url = 'providers/musicbrainz/' + this.type + 's/' + this.mbId + '/'
axios.get(url).then((response) => {
logger.default.info('successfully fetched', self.type, self.mbId)
self.data = response.data[self.type]
this.$emit('metadata-changed', self.data)
......
class Config {
constructor () {
this.BACKEND_URL = process.env.BACKEND_URL
if (this.BACKEND_URL === '/') {
this.BACKEND_URL = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port
}
if (!this.BACKEND_URL.endsWith('/')) {
this.BACKEND_URL += '/'
}
this.API_URL = this.BACKEND_URL + 'api/v1/'
}
}
......
......@@ -8,9 +8,13 @@ logger.default.debug('Environment variables:', process.env)
import Vue from 'vue'
import App from './App'
import router from './router'
import VueResource from 'vue-resource'
import axios from 'axios'
import VueLazyload from 'vue-lazyload'
import store from './store'
import config from './config'
import { sync } from 'vuex-router-sync'
sync(store, router)
window.$ = window.jQuery = require('jquery')
......@@ -19,25 +23,33 @@ window.$ = window.jQuery = require('jquery')
// require('./semantic/semantic.css')
require('semantic-ui-css/semantic.js')
Vue.use(VueResource)
Vue.use(VueLazyload)
Vue.config.productionTip = false
Vue.http.interceptors.push(function (request, next) {
// modify headers
axios.defaults.baseURL = config.API_URL
axios.interceptors.request.use(function (config) {
// Do something before request is sent
if (store.state.auth.authenticated) {
request.headers.set('Authorization', store.getters['auth/header'])
config.headers['Authorization'] = store.getters['auth/header']
}
next(function (response) {
// redirect to login form when we get unauthorized response from server
if (response.status === 401) {
store.commit('auth/authenticated', false)
logger.default.warn('Received 401 response from API, redirecting to login form')
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
}
})
return config
}, function (error) {
// Do something with request error
return Promise.reject(error)
})
// Add a response interceptor
axios.interceptors.response.use(function (response) {
return response
}, function (error) {
if (error.response.status === 401) {
store.commit('auth/authenticated', false)
logger.default.warn('Received 401 response from API, redirecting to login form')
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
}
// Do something with response error
return Promise.reject(error)
})
store.dispatch('auth/check')
/* eslint-disable no-new */
new Vue({
......
......@@ -515,7 +515,7 @@ body {
}
 
html {
font-size: 14px;
font-size: 100%;
}
 
body {
......@@ -525,7 +525,7 @@ body {
min-width: 320px;
background: #FFFFFF;
font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
font-size: 14px;
font-size: 100%;
line-height: 1.4285em;
color: rgba(0, 0, 0, 0.87);
font-smoothing: antialiased;
......
import Vue from 'vue'
import axios from 'axios'
import jwtDecode from 'jwt-decode'
import config from '@/config'
import logger from '@/logging'
import router from '@/router'
const LOGIN_URL = config.API_URL + 'token/'
const REFRESH_TOKEN_URL = config.API_URL + 'token/refresh/'
const USER_PROFILE_URL = config.API_URL + 'users/users/me/'
export default {
namespaced: true,
state: {
......@@ -54,9 +49,8 @@ export default {
},
actions: {