implementing favorite stations

This commit is contained in:
Jonas Heinrich 2020-11-07 10:26:41 +01:00
parent 7a662f6bdb
commit ebf8da0198
8 changed files with 28 additions and 32 deletions

View File

@ -50,9 +50,9 @@ class StationApiController extends ApiController {
* @NoCSRFRequired
* @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,
$favicon, $url_resolved, $this->userId));
$favicon, $urlresolved, $this->userId));
}
/**
@ -62,8 +62,8 @@ class StationApiController extends ApiController {
*/
public function update(int $id, string $title,
string $content): DataResponse {
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $url_resolved) {
return $this->service->update($id, $stationuuid, $name, $favicon, $url_resolved, $this->userId);
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $urlresolved) {
return $this->service->update($id, $stationuuid, $name, $favicon, $urlresolved, $this->userId);
});
}

View File

@ -42,18 +42,18 @@ class StationController extends Controller {
/**
* @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,
$favicon, $url_resolved, $this->userId));
$favicon, $urlresolved, $this->userId));
}
/**
* @NoAdminRequired
*/
public function update(int $id, string $stationuuid,
string $name, string $favicon, string $url_resolved): DataResponse {
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $url_resolved) {
return $this->service->update($id, $stationuuid, $name, $favicon, $url_resolved, $this->userId);
string $name, string $favicon, string $urlresolved): DataResponse {
return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $urlresolved) {
return $this->service->update($id, $stationuuid, $name, $favicon, $urlresolved, $this->userId);
});
}

View File

@ -10,7 +10,7 @@ class Station extends Entity implements JsonSerializable {
protected $stationuuid;
protected $name;
protected $favicon;
protected $url_resolved;
protected $urlresolved;
protected $userId;
public function jsonSerialize(): array {
@ -19,7 +19,7 @@ class Station extends Entity implements JsonSerializable {
'stationuuid' => $this->stationuuid,
'name' => $this->name,
'favicon' => $this->favicon,
'url_resolved' => $this->url_resolved
'url_resolved' => $this->urlresolved
];
}
}

View File

@ -29,24 +29,15 @@ class Version000000Date20181013124731 extends SimpleMigrationStep {
]);
$table->addColumn('stationuuid', 'string', [
'notnull' => true,
'length' => 200,
]);
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 200,
]);
$table->addColumn('name', 'text', [
'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->addIndex(['user_id'], 'radio_user_id_index');

View File

@ -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->setStationuuid($stationuuid);
$station->setName($name);
$station->setFavicon($favicon);
$station->setUrl_resolved($url_resolved);
$station->setUrlresolved($urlresolved);
$station->setUserId($userId);
return $this->mapper->insert($station);
}
public function update($id, $stationuuid, $name, $userId) {
public function update($id, $stationuuid, $name, $favicon, $urlresolved, $userId) {
try {
$station = $this->mapper->find($id, $userId);
$station->setStationuuid($stationuuid);
$station->setName($name);
$station->setFavicon($favicon);
$station->setUrl_resolved($url_resolved);
$station->setUrlresolved($urlresolved);
return $this->mapper->update($station);
} catch (Exception $e) {
$this->handleException($e);

5
package-lock.json generated
View File

@ -7179,11 +7179,6 @@
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
"dev": true
},
"jquery": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",
"integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg=="
},
"js-base64": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.2.tgz",

View File

@ -36,7 +36,6 @@
"@nextcloud/router": "^1.2.0",
"@nextcloud/vue": "^2.7.0",
"howler": "^2.2.1",
"jquery": "^3.5.1",
"music-metadata": "^7.4.1",
"vue": "^2.6.12",
"vue-blurhash": "^0.1.2",

View File

@ -52,6 +52,7 @@ export default {
offset: 0,
pageLoading: false,
blurHashes: require('../assets/blurHashes.json'),
favorites: null,
}),
computed: {
player() {
@ -75,6 +76,7 @@ export default {
},
created() {
this.loadSettings()
this.loadFavorites()
},
mounted() {
this.onRoute()
@ -106,6 +108,7 @@ export default {
* @param {Object} station Station object
*/
doPlay(station) {
const vm = this
if (audioPlayer !== null) {
audioPlayer.fade(vm.player.volume, 0, 500)
@ -168,6 +171,8 @@ export default {
if (menuState === 'SEARCH') {
const searchQuery = vm.$route.params.query
queryURI = queryBase + '/byname/' + searchQuery
} else if (menuState === 'FAVORITES') {
queryURI = generateUrl('/apps/radio/stations')
}
await axios.get(queryURI, {
@ -205,6 +210,12 @@ export default {
loadSettings() {
this.$store.dispatch('getVolumeState')
},
async loadFavorites() {
await axios.get(generateUrl('/apps/radio/stations'))
.then(function(response) {
this.favorites = response.data
})
},
},
}
</script>