fix settingscontroller bug, add more props to db backend

This commit is contained in:
Jonas Heinrich 2020-11-19 22:35:13 +01:00
parent ff3a745441
commit 05d6634d0c
11 changed files with 130 additions and 51 deletions

View File

@ -44,20 +44,29 @@ class FavoriteController extends Controller {
/**
* @NoAdminRequired
*/
public function create(string $stationuuid, string $name, string $favicon, string $urlresolved): DataResponse {
return new DataResponse($this->service->create($stationuuid, $name,
$favicon, $urlresolved, $this->userId));
}
public function create(string $stationuuid, string $name, string $favicon, string $urlresolved,
string $bitrate, string $country, string $language, string $homepage,
string $codec, string $tags): DataResponse {
return new DataResponse($this->service->create($stationuuid, $name,
$favicon, $urlresolved, $bitrate, $country, $language, $homepage, $codec,
$tags, $this->userId));
}
/**
* @NoAdminRequired
*/
public function update(int $id, string $stationuuid,
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);
});
}
public function update(int $id, string $stationuuid,
string $name, string $favicon, string $urlresolved,
string $bitrate, string $country, string $language, string $homepage,
string $codec, string $tags): DataResponse {
return $this->handleNotFound(function () use ($id, $stationuuid, $name,
$favicon, $urlresolved, $bitrate, $country, $language, $homepage, $codec,
$tags) {
return $this->service->update($id, $stationuuid, $name, $favicon,
$urlresolved, $bitrate, $country, $language, $homepage, $codec,
$tags, $this->userId);
});
}
/**
* @NoAdminRequired

View File

@ -44,18 +44,26 @@ class RecentController extends Controller {
/**
* @NoAdminRequired
*/
public function create(string $stationuuid, string $name, string $favicon, string $urlresolved): DataResponse {
public function create(string $stationuuid, string $name, string $favicon, string $urlresolved,
string $bitrate, string $country, string $language, string $homepage,
string $codec, string $tags): DataResponse {
return new DataResponse($this->service->create($stationuuid, $name,
$favicon, $urlresolved, $this->userId));
$favicon, $urlresolved, $bitrate, $country, $language, $homepage, $codec,
$tags, $this->userId));
}
/**
* @NoAdminRequired
*/
public function update(int $id, string $stationuuid,
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);
public function update(int $id, string $stationuuid, string $name,
string $favicon, string $urlresolved, string $bitrate, string $country,
string $language, string $homepage, string $codec, string $tags): DataResponse {
return $this->handleNotFound(function () use ($id, $stationuuid, $name,
$favicon, $urlresolved, $bitrate, $country, $language, $homepage, $codec,
$tags) {
return $this->service->update($id, $stationuuid, $name, $favicon,
$urlresolved, $bitrate, $country, $language, $homepage, $codec,
$tags, $this->userId);
});
}

View File

@ -79,7 +79,7 @@ class SettingsController extends ApiController {
*/
public function setMenuState($menuState = ""): JSONResponse {
if ($menuState == 'SEARCH') {
return true;
return new JSONResponse(['status' => 'success'], Http::STATUS_OK);
};
$legalArguments = ['TOP', 'RECENT', 'NEW', 'FAVORITES', 'CATEGORIES'];
if (!in_array($menuState, $legalArguments)) {

View File

@ -27,6 +27,12 @@ class RecentMapper extends QBMapper {
->addSelect('name')
->addSelect('favicon')
->addSelect('urlresolved')
->addSelect('bitrate')
->addSelect('country')
->addSelect('language')
->addSelect('homepage')
->addSelect('codec')
->addSelect('tags')
->from('recent')
->orderBy('id', 'DESC')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
@ -45,6 +51,12 @@ class RecentMapper extends QBMapper {
->addSelect('name')
->addSelect('favicon')
->addSelect('urlresolved')
->addSelect('bitrate')
->addSelect('country')
->addSelect('language')
->addSelect('homepage')
->addSelect('codec')
->addSelect('tags')
->from('recent')
->orderBy('id', 'DESC')
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));

View File

@ -11,6 +11,12 @@ class Station extends Entity implements JsonSerializable {
protected $name;
protected $favicon;
protected $urlresolved;
protected $bitrate;
protected $country;
protected $language;
protected $homepage;
protected $codec;
protected $tags;
protected $userId;
public function jsonSerialize(): array {
@ -19,7 +25,13 @@ class Station extends Entity implements JsonSerializable {
'stationuuid' => $this->stationuuid,
'name' => $this->name,
'favicon' => $this->favicon,
'urlresolved' => $this->urlresolved
'urlresolved' => $this->urlresolved,
'bitrate' => $this->bitrate,
'country' => $this->country,
'language' => $this->language,
'homepage' => $this->homepage,
'codec' => $this->codec,
'tags' => $this->tags
];
}
}

View File

@ -38,6 +38,12 @@ class Version000000Date20181013124731 extends SimpleMigrationStep {
]);
$table->addColumn('favicon', 'text');
$table->addColumn('urlresolved', 'text');
$table->addColumn('bitrate', 'text');
$table->addColumn('country', 'text');
$table->addColumn('language', 'text');
$table->addColumn('homepage', 'text');
$table->addColumn('codec', 'text');
$table->addColumn('tags', 'text');
$table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'favorites_user_id_index');
@ -60,6 +66,12 @@ class Version000000Date20181013124731 extends SimpleMigrationStep {
]);
$table->addColumn('favicon', 'text');
$table->addColumn('urlresolved', 'text');
$table->addColumn('bitrate', 'text');
$table->addColumn('country', 'text');
$table->addColumn('language', 'text');
$table->addColumn('homepage', 'text');
$table->addColumn('codec', 'text');
$table->addColumn('tags', 'text');
$table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'recent_user_id_index');

View File

@ -45,23 +45,37 @@ class FavoriteService {
}
}
public function create($stationuuid, $name, $favicon, $urlresolved, $userId) {
public function create($stationuuid, $name, $favicon, $urlresolved,
$bitrate, $country, $language, $homepage, $codec, $tags, $userId) {
$station = new Station();
$station->setStationuuid($stationuuid);
$station->setName($name);
$station->setFavicon($favicon);
$station->setUrlresolved($urlresolved);
$station->setBitrate($bitrate);
$station->setCountry($country);
$station->setLanguage($language);
$station->setHomepage($homepage);
$station->setCodec($codec);
$station->setTags($tags);
$station->setUserId($userId);
return $this->mapper->insert($station);
}
public function update($id, $stationuuid, $name, $favicon, $urlresolved, $userId) {
public function update($id, $stationuuid, $name, $favicon, $urlresolved,
$bitrate, $country, $language, $homepage, $codec, $tags, $userId) {
try {
$station = $this->mapper->find($id, $userId);
$station->setStationuuid($stationuuid);
$station->setName($name);
$station->setFavicon($favicon);
$station->setUrlresolved($urlresolved);
$station->setBitrate($bitrate);
$station->setCountry($country);
$station->setLanguage($language);
$station->setHomepage($homepage);
$station->setCodec($codec);
$station->setTags($tags);
return $this->mapper->update($station);
} catch (Exception $e) {
$this->handleException($e);

View File

@ -45,23 +45,37 @@ class RecentService {
}
}
public function create($stationuuid, $name, $favicon, $urlresolved, $userId) {
public function create($stationuuid, $name, $favicon, $urlresolved,
$bitrate, $country, $language, $homepage, $codec, $tags, $userId) {
$station = new Station();
$station->setStationuuid($stationuuid);
$station->setName($name);
$station->setFavicon($favicon);
$station->setUrlresolved($urlresolved);
$station->setBitrate($bitrate);
$station->setCountry($country);
$station->setLanguage($language);
$station->setHomepage($homepage);
$station->setCodec($codec);
$station->setTags($tags);
$station->setUserId($userId);
return $this->mapper->insert($station);
}
public function update($id, $stationuuid, $name, $favicon, $urlresolved, $userId) {
public function update($id, $stationuuid, $name, $favicon, $urlresolved,
$bitrate, $country, $language, $homepage, $codec, $tags, $userId) {
try {
$station = $this->mapper->find($id, $userId);
$station->setStationuuid($stationuuid);
$station->setName($name);
$station->setFavicon($favicon);
$station->setUrlresolved($urlresolved);
$station->setBitrate($bitrate);
$station->setCountry($country);
$station->setLanguage($language);
$station->setHomepage($homepage);
$station->setCodec($codec);
$station->setTags($tags);
return $this->mapper->update($station);
} catch (Exception $e) {
$this->handleException($e);

View File

@ -55,7 +55,7 @@ export default {
targetUrl: generateUrl('/apps/radio/#/favorites'),
avatarUrl: n.favicon,
mainText: n.name,
subText: n.tags,
subText: n.tags.replaceAll(',', ', '),
}
})
},

View File

@ -61,7 +61,7 @@ export default {
blurHashes: require('../assets/blurHashes.json'),
favorites: [],
showSidebar: false,
sidebarStation: [],
sidebarStation: {},
}),
computed: {
player() {
@ -161,10 +161,16 @@ export default {
}
const stationMap = {
id: -1,
name: station.name,
urlresolved: stationSrc,
favicon: station.favicon,
stationuuid: station.stationuuid,
name: station.name.toString(),
urlresolved: stationSrc.toString(),
favicon: station.favicon.toString(),
stationuuid: station.stationuuid.toString(),
bitrate: station.bitrate.toString(),
country: station.country.toString(),
language: station.language.toString(),
homepage: station.homepage.toString(),
codec: station.codec.toString(),
tags: station.tags.toString(),
}
await axios
.post(generateUrl('/apps/radio/api/favorites'), stationMap)
@ -246,10 +252,16 @@ export default {
}
const stationMap = {
id: -1,
name: station.name,
urlresolved: stationSrc,
favicon: station.favicon,
stationuuid: station.stationuuid,
name: station.name.toString(),
urlresolved: stationSrc.toString(),
favicon: station.favicon.toString(),
stationuuid: station.stationuuid.toString(),
bitrate: station.bitrate.toString(),
country: station.country.toString(),
language: station.language.toString(),
homepage: station.homepage.toString(),
codec: station.codec.toString(),
tags: station.tags.toString(),
}
await axios
.post(generateUrl('/apps/radio/api/recent'), stationMap)
@ -390,27 +402,10 @@ export default {
<style>
/* Make breadcrumbs sticky and intransparent.
Move them to the right and show navigation
toggle on smaller screens */
.breadcrumbs {
background-color: var(--color-main-background-translucent);
z-index: 60;
position: sticky;
position: -webkit-sticky;
top: 50px;
padding-bottom: 5px;
margin-left: 35px;
}
@media only screen and (min-width: 1024px) {
.app-navigation-toggle {
display: none;
}
.breadcrumbs {
margin-left: 0px;
}
}
</style>

View File

@ -79,8 +79,10 @@ export default {
default() { return false },
},
sidebarStation: {
type: Array,
default() { return [] },
type: Object,
default() {
return {}
},
},
},
computed: {
@ -103,6 +105,7 @@ export default {
this.$emit('toggleSidebar')
},
copyLink() {
console.log(this.sidebarStation.favicon)
this.$copyText(this.urlResolved).then(
function() {
showSuccess(t('radio', 'Link copied to clipboard'))