implementing favorite stations
This commit is contained in:
parent
7a662f6bdb
commit
ebf8da0198
@ -50,9 +50,9 @@ class StationApiController extends ApiController {
|
|||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function create(string $stationuuid, string $name, string $favicon, string $url_resolved): DataResponse {
|
public function create(string $stationuuid, string $name, string $favicon, string $urlresolved): DataResponse {
|
||||||
return new DataResponse($this->service->create($stationuuid, $name,
|
return new DataResponse($this->service->create($stationuuid, $name,
|
||||||
$favicon, $url_resolved, $this->userId));
|
$favicon, $urlresolved, $this->userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,8 +62,8 @@ class StationApiController extends ApiController {
|
|||||||
*/
|
*/
|
||||||
public function update(int $id, string $title,
|
public function update(int $id, string $title,
|
||||||
string $content): DataResponse {
|
string $content): DataResponse {
|
||||||
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $url_resolved) {
|
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $urlresolved) {
|
||||||
return $this->service->update($id, $stationuuid, $name, $favicon, $url_resolved, $this->userId);
|
return $this->service->update($id, $stationuuid, $name, $favicon, $urlresolved, $this->userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,18 +42,18 @@ class StationController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function create(string $stationuuid, string $name, string $favicon, string $url_resolved): DataResponse {
|
public function create(string $stationuuid, string $name, string $favicon, string $urlresolved = "lol"): DataResponse {
|
||||||
return new DataResponse($this->service->create($stationuuid, $name,
|
return new DataResponse($this->service->create($stationuuid, $name,
|
||||||
$favicon, $url_resolved, $this->userId));
|
$favicon, $urlresolved, $this->userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function update(int $id, string $stationuuid,
|
public function update(int $id, string $stationuuid,
|
||||||
string $name, string $favicon, string $url_resolved): DataResponse {
|
string $name, string $favicon, string $urlresolved): DataResponse {
|
||||||
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $url_resolved) {
|
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $urlresolved) {
|
||||||
return $this->service->update($id, $stationuuid, $name, $favicon, $url_resolved, $this->userId);
|
return $this->service->update($id, $stationuuid, $name, $favicon, $urlresolved, $this->userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class Station extends Entity implements JsonSerializable {
|
|||||||
protected $stationuuid;
|
protected $stationuuid;
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $favicon;
|
protected $favicon;
|
||||||
protected $url_resolved;
|
protected $urlresolved;
|
||||||
protected $userId;
|
protected $userId;
|
||||||
|
|
||||||
public function jsonSerialize(): array {
|
public function jsonSerialize(): array {
|
||||||
@ -19,7 +19,7 @@ class Station extends Entity implements JsonSerializable {
|
|||||||
'stationuuid' => $this->stationuuid,
|
'stationuuid' => $this->stationuuid,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'favicon' => $this->favicon,
|
'favicon' => $this->favicon,
|
||||||
'url_resolved' => $this->url_resolved
|
'url_resolved' => $this->urlresolved
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,24 +29,15 @@ class Version000000Date20181013124731 extends SimpleMigrationStep {
|
|||||||
]);
|
]);
|
||||||
$table->addColumn('stationuuid', 'string', [
|
$table->addColumn('stationuuid', 'string', [
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 200,
|
|
||||||
]);
|
]);
|
||||||
$table->addColumn('user_id', 'string', [
|
$table->addColumn('user_id', 'string', [
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 200,
|
|
||||||
]);
|
]);
|
||||||
$table->addColumn('name', 'text', [
|
$table->addColumn('name', 'text', [
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
'length' => 200,
|
|
||||||
]);
|
|
||||||
$table->addColumn('favicon', 'text', [
|
|
||||||
'notnull' => true,
|
|
||||||
'length' => 200,
|
|
||||||
]);
|
|
||||||
$table->addColumn('url_resolved', 'text', [
|
|
||||||
'notnull' => true,
|
|
||||||
'length' => 200,
|
|
||||||
]);
|
]);
|
||||||
|
$table->addColumn('favicon', 'text');
|
||||||
|
$table->addColumn('urlresolved', 'text');
|
||||||
|
|
||||||
$table->setPrimaryKey(['id']);
|
$table->setPrimaryKey(['id']);
|
||||||
$table->addIndex(['user_id'], 'radio_user_id_index');
|
$table->addIndex(['user_id'], 'radio_user_id_index');
|
||||||
|
@ -45,23 +45,23 @@ class StationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($stationuuid, $name, $favicon, $url_resolved, $userId) {
|
public function create($stationuuid, $name, $favicon, $urlresolved, $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->setUrl_resolved($url_resolved);
|
$station->setUrlresolved($urlresolved);
|
||||||
$station->setUserId($userId);
|
$station->setUserId($userId);
|
||||||
return $this->mapper->insert($station);
|
return $this->mapper->insert($station);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id, $stationuuid, $name, $userId) {
|
public function update($id, $stationuuid, $name, $favicon, $urlresolved, $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->setUrl_resolved($url_resolved);
|
$station->setUrlresolved($urlresolved);
|
||||||
return $this->mapper->update($station);
|
return $this->mapper->update($station);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->handleException($e);
|
$this->handleException($e);
|
||||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -7179,11 +7179,6 @@
|
|||||||
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
|
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"jquery": {
|
|
||||||
"version": "3.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",
|
|
||||||
"integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg=="
|
|
||||||
},
|
|
||||||
"js-base64": {
|
"js-base64": {
|
||||||
"version": "2.6.2",
|
"version": "2.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.2.tgz",
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
"@nextcloud/router": "^1.2.0",
|
"@nextcloud/router": "^1.2.0",
|
||||||
"@nextcloud/vue": "^2.7.0",
|
"@nextcloud/vue": "^2.7.0",
|
||||||
"howler": "^2.2.1",
|
"howler": "^2.2.1",
|
||||||
"jquery": "^3.5.1",
|
|
||||||
"music-metadata": "^7.4.1",
|
"music-metadata": "^7.4.1",
|
||||||
"vue": "^2.6.12",
|
"vue": "^2.6.12",
|
||||||
"vue-blurhash": "^0.1.2",
|
"vue-blurhash": "^0.1.2",
|
||||||
|
@ -52,6 +52,7 @@ export default {
|
|||||||
offset: 0,
|
offset: 0,
|
||||||
pageLoading: false,
|
pageLoading: false,
|
||||||
blurHashes: require('../assets/blurHashes.json'),
|
blurHashes: require('../assets/blurHashes.json'),
|
||||||
|
favorites: null,
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
player() {
|
player() {
|
||||||
@ -75,6 +76,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.loadSettings()
|
this.loadSettings()
|
||||||
|
this.loadFavorites()
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.onRoute()
|
this.onRoute()
|
||||||
@ -106,6 +108,7 @@ export default {
|
|||||||
* @param {Object} station Station object
|
* @param {Object} station Station object
|
||||||
*/
|
*/
|
||||||
doPlay(station) {
|
doPlay(station) {
|
||||||
|
|
||||||
const vm = this
|
const vm = this
|
||||||
if (audioPlayer !== null) {
|
if (audioPlayer !== null) {
|
||||||
audioPlayer.fade(vm.player.volume, 0, 500)
|
audioPlayer.fade(vm.player.volume, 0, 500)
|
||||||
@ -168,6 +171,8 @@ export default {
|
|||||||
if (menuState === 'SEARCH') {
|
if (menuState === 'SEARCH') {
|
||||||
const searchQuery = vm.$route.params.query
|
const searchQuery = vm.$route.params.query
|
||||||
queryURI = queryBase + '/byname/' + searchQuery
|
queryURI = queryBase + '/byname/' + searchQuery
|
||||||
|
} else if (menuState === 'FAVORITES') {
|
||||||
|
queryURI = generateUrl('/apps/radio/stations')
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.get(queryURI, {
|
await axios.get(queryURI, {
|
||||||
@ -205,6 +210,12 @@ export default {
|
|||||||
loadSettings() {
|
loadSettings() {
|
||||||
this.$store.dispatch('getVolumeState')
|
this.$store.dispatch('getVolumeState')
|
||||||
},
|
},
|
||||||
|
async loadFavorites() {
|
||||||
|
await axios.get(generateUrl('/apps/radio/stations'))
|
||||||
|
.then(function(response) {
|
||||||
|
this.favorites = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user