implementing favorite stations db backend
This commit is contained in:
parent
c835b6d1b8
commit
7a662f6bdb
@ -47,10 +47,10 @@ class StationService {
|
|||||||
|
|
||||||
public function create($stationuuid, $name, $favicon, $url_resolved, $userId) {
|
public function create($stationuuid, $name, $favicon, $url_resolved, $userId) {
|
||||||
$station = new Station();
|
$station = new Station();
|
||||||
$station->setStationUuid($stationuuid);
|
$station->setStationuuid($stationuuid);
|
||||||
$station->setName($name);
|
$station->setName($name);
|
||||||
$station->setFavicon($favicon);
|
$station->setFavicon($favicon);
|
||||||
$station->setUrlResolved($url_resolved);
|
$station->setUrl_resolved($url_resolved);
|
||||||
$station->setUserId($userId);
|
$station->setUserId($userId);
|
||||||
return $this->mapper->insert($station);
|
return $this->mapper->insert($station);
|
||||||
}
|
}
|
||||||
@ -58,10 +58,10 @@ class StationService {
|
|||||||
public function update($id, $stationuuid, $name, $userId) {
|
public function update($id, $stationuuid, $name, $userId) {
|
||||||
try {
|
try {
|
||||||
$station = $this->mapper->find($id, $userId);
|
$station = $this->mapper->find($id, $userId);
|
||||||
$station->setStationUuid($stationuuid);
|
$station->setStationuuid($stationuuid);
|
||||||
$station->setName($name);
|
$station->setName($name);
|
||||||
$station->setFavicon($favicon);
|
$station->setFavicon($favicon);
|
||||||
$station->setUrlResolved($url_resolved);
|
$station->setUrl_resolved($url_resolved);
|
||||||
return $this->mapper->update($station);
|
return $this->mapper->update($station);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->handleException($e);
|
$this->handleException($e);
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -6603,9 +6603,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"howler": {
|
"howler": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/howler/-/howler-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/howler/-/howler-2.2.1.tgz",
|
||||||
"integrity": "sha512-sGPkrAQy7jh5mNDbkRNG0F82R2HFDYNsQXBcX4smXQT0y0F4UMsa/+jXaGwWvcrajWr2tDB7JUkH7G5qSnuIyQ=="
|
"integrity": "sha512-0iIXvuBO/81CcrQ/HSSweYmbT50fT2mIc9XMFb+kxIfk2pW/iKzDbX1n3fZmDXMEIpYvyyfrB+gXwPYSDqUxIQ=="
|
||||||
},
|
},
|
||||||
"html-tags": {
|
"html-tags": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
"@nextcloud/l10n": "^1.4.1",
|
"@nextcloud/l10n": "^1.4.1",
|
||||||
"@nextcloud/router": "^1.2.0",
|
"@nextcloud/router": "^1.2.0",
|
||||||
"@nextcloud/vue": "^2.7.0",
|
"@nextcloud/vue": "^2.7.0",
|
||||||
"howler": "^2.2.0",
|
"howler": "^2.2.1",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"music-metadata": "^7.4.1",
|
"music-metadata": "^7.4.1",
|
||||||
"vue": "^2.6.12",
|
"vue": "^2.6.12",
|
||||||
|
@ -81,36 +81,26 @@ export default {
|
|||||||
this.scroll()
|
this.scroll()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
async onRoute() {
|
async onRoute() {
|
||||||
this.offset = 0
|
this.offset = 0
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
const route = this.$route
|
const route = this.$route
|
||||||
this.loadStations(route.name)
|
this.loadStations(route.name)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Favor a new station by sending the information to the server
|
* Favor a new station by sending the information to the server
|
||||||
* @param {Object} station Station object
|
* @param {Object} station Station object
|
||||||
*/
|
*/
|
||||||
async doFavor(station) {
|
async doFavor(station) {
|
||||||
try {
|
try {
|
||||||
const newStation = {
|
await axios.post(generateUrl('/apps/radio/stations'), station)
|
||||||
id: -1,
|
|
||||||
stationuuid: station.stationuuid,
|
|
||||||
name: station.name,
|
|
||||||
favicon: station.favicon,
|
|
||||||
url_resolved: station.url_resolved,
|
|
||||||
}
|
|
||||||
const response = await axios.post(generateUrl('/apps/radio/stations'), newStation)
|
|
||||||
console.log(response)
|
|
||||||
// const index = this.stations.findIndex((match) => match.id === this.currentStationId)
|
|
||||||
// this.$set(this.stations, index, response.data)
|
|
||||||
// this.currentStationId = response.data.id
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
|
||||||
showError(t('radio', 'Could not favor station'))
|
showError(t('radio', 'Could not favor station'))
|
||||||
}
|
}
|
||||||
this.updating = false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start playing a radio station and counting the playback
|
* Start playing a radio station and counting the playback
|
||||||
* @param {Object} station Station object
|
* @param {Object} station Station object
|
||||||
@ -121,10 +111,7 @@ export default {
|
|||||||
audioPlayer.fade(vm.player.volume, 0, 500)
|
audioPlayer.fade(vm.player.volume, 0, 500)
|
||||||
}
|
}
|
||||||
vm.$store.dispatch('setTitle', station.name)
|
vm.$store.dispatch('setTitle', station.name)
|
||||||
this.$jquery.get(this.$apiUrl + '/json/url/' + station.stationuuid,
|
|
||||||
{
|
|
||||||
'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version, doesnt seem to work
|
|
||||||
})
|
|
||||||
audioPlayer = new Howl({
|
audioPlayer = new Howl({
|
||||||
src: [station.url_resolved],
|
src: [station.url_resolved],
|
||||||
volume: vm.player.volume,
|
volume: vm.player.volume,
|
||||||
@ -153,14 +140,15 @@ export default {
|
|||||||
audioPlayer.play()
|
audioPlayer.play()
|
||||||
audioPlayer.fade(0, vm.player.volume, 500)
|
audioPlayer.fade(0, vm.player.volume, 500)
|
||||||
|
|
||||||
/* const stationMetadata = document.getElementById('stationMetadata')
|
/* Count click */
|
||||||
stationMetadata.textContent = station.name */
|
axios.get(this.$apiUrl + '/json/url/' + station.stationuuid)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetching radio stations using Radio-Browser.info API
|
* Fetching radio stations using Radio-Browser.info API
|
||||||
* @param {String} menuState Entries to load
|
* @param {String} menuState Entries to load
|
||||||
*/
|
*/
|
||||||
loadStations(menuState = 'TOP') {
|
async loadStations(menuState = 'TOP') {
|
||||||
|
|
||||||
const vm = this
|
const vm = this
|
||||||
const queryBase = this.$apiUrl + '/json/stations'
|
const queryBase = this.$apiUrl + '/json/stations'
|
||||||
@ -182,24 +170,24 @@ export default {
|
|||||||
queryURI = queryBase + '/byname/' + searchQuery
|
queryURI = queryBase + '/byname/' + searchQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$jquery.getJSON(queryURI,
|
await axios.get(queryURI, {
|
||||||
{
|
params: {
|
||||||
limit: 20,
|
limit: 20,
|
||||||
order: sortBy,
|
order: sortBy,
|
||||||
reverse: true,
|
reverse: true,
|
||||||
offset: vm.offset,
|
offset: vm.offset,
|
||||||
'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version, doesnt seem to work
|
},
|
||||||
})
|
})
|
||||||
.done(function(data) {
|
.then(function(response) {
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < response.data.length; i++) {
|
||||||
const obj = data[i]
|
const obj = response.data[i]
|
||||||
let blurHash = vm.blurHashes[obj.stationuuid]
|
let blurHash = vm.blurHashes[obj.stationuuid]
|
||||||
if (!blurHash) {
|
if (!blurHash) {
|
||||||
blurHash = 'L1TSUA?bj[?b~qfQfQj[ayfQfQfQ'
|
blurHash = 'L1TSUA?bj[?b~qfQfQj[ayfQfQfQ'
|
||||||
}
|
}
|
||||||
data[i].blurHash = blurHash
|
response.data[i].blurHash = blurHash
|
||||||
}
|
}
|
||||||
vm.tableData = vm.tableData.concat(data)
|
vm.tableData = vm.tableData.concat(response.data)
|
||||||
vm.offset += 20
|
vm.offset += 20
|
||||||
vm.pageLoading = false
|
vm.pageLoading = false
|
||||||
})
|
})
|
||||||
|
@ -27,14 +27,12 @@ import { translate, translatePlural } from '@nextcloud/l10n'
|
|||||||
|
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
|
||||||
import jquery from 'jquery'
|
|
||||||
import VueBlurHash from 'vue-blurhash'
|
import VueBlurHash from 'vue-blurhash'
|
||||||
|
|
||||||
import 'vue-blurhash/dist/vue-blurhash.css'
|
import 'vue-blurhash/dist/vue-blurhash.css'
|
||||||
|
|
||||||
Vue.prototype.t = translate
|
Vue.prototype.t = translate
|
||||||
Vue.prototype.n = translatePlural
|
Vue.prototype.n = translatePlural
|
||||||
Vue.prototype.$jquery = jquery
|
|
||||||
|
|
||||||
Vue.prototype.$apiUrl = 'https://de1.api.radio-browser.info'
|
Vue.prototype.$apiUrl = 'https://de1.api.radio-browser.info'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user