diff --git a/CHANGELOG.md b/CHANGELOG.md index b44c35f..8aed7cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ### Added - Nextcloud 21 & PHP 8 support [#251](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/251) @onny +- Support add stations manually + [#157](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/157) @onny ### Fixed - Cleanup SCSS diff --git a/appinfo/routes.php b/appinfo/routes.php index bb02165..1290f1c 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -25,6 +25,7 @@ return [ 'resources' => [ 'favorite' => ['url' => '/api/favorites'], 'recent' => ['url' => '/api/recent'], + 'export' => ['url' => '/export'], ], 'routes' => [ diff --git a/lib/Controller/ExportController.php b/lib/Controller/ExportController.php new file mode 100644 index 0000000..4fdfd1e --- /dev/null +++ b/lib/Controller/ExportController.php @@ -0,0 +1,59 @@ + + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + * + */ + +namespace OCA\Radio\Controller; + +use OCA\Radio\AppInfo\Application; +use OCA\Radio\Service\FavoriteService; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\DataResponse; +use OCP\IRequest; + +class ExportController extends Controller { + /** @var FavoriteService */ + private $service; + + /** @var string */ + private $userId; + + use Errors; + + public function __construct(IRequest $request, + FavoriteService $service, + $userId) { + parent::__construct(Application::APP_ID, $request); + $this->service = $service; + $this->userId = $userId; + } + + /** + * @NoAdminRequired + */ + public function index() { + header('Content-Type: application/csv'); + header('Content-Disposition: attachment; filename="filename.csv"'); + //return new DataResponse($this->service->findAll($this->userId)); + return "hello"; + } + +} diff --git a/src/main.js b/src/main.js index 6db0542..912c4dc 100644 --- a/src/main.js +++ b/src/main.js @@ -38,7 +38,7 @@ Vue.prototype.t = translate Vue.prototype.n = translatePlural Vue.prototype.OC = window.OC Vue.prototype.OCA = window.OCA -Vue.prototype.$version = '1.0.2' +Vue.prototype.$version = '1.0.3' Vue.use(VueClipboard) Vue.use(VueBlurHash) diff --git a/src/views/Favorites.vue b/src/views/Favorites.vue index d7c08d2..3db0d2c 100644 --- a/src/views/Favorites.vue +++ b/src/views/Favorites.vue @@ -40,7 +40,7 @@ + @click="exportList"> Export favorites @@ -118,9 +118,11 @@ import Navigation from './../components/Navigation' import Table from './../components/Table' import Sidebar from './../components/Sidebar' import { mapGetters, mapActions } from 'vuex' - +import axios from '@nextcloud/axios' +import { generateUrl } from '@nextcloud/router' import { RadioBrowserApi } from './../services/RadioBrowserApi' const apiClient = new RadioBrowserApi() +const requesttoken = axios.defaults.headers.requesttoken export default { name: 'Favorites', @@ -143,7 +145,7 @@ export default { showSidebar: false, sidebarStation: {}, tableData: [], - modal: true, + modal: false, station: { faviconUrl: '', }, @@ -243,13 +245,20 @@ export default { this.modal = false }, + uuidv4() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8) + return v.toString(16) + }) + }, + addCustomStation(e) { e.preventDefault() const station = { name: this.station.name, urlresolved: this.station.streamUrl, favicon: this.station.faviconUrl, - stationuuid: '932eb148-e6f6-11e9-a96c-52543be04c81', + stationuuid: this.uuidv4(), bitrate: '', country: '', language: '', @@ -261,6 +270,17 @@ export default { this.modal = false }, + exportList() { + console.log('export list') + axios.defaults.headers.requesttoken = requesttoken + axios.get(generateUrl('/apps/radio/export')) + .then( + (response) => { + return Promise.resolve(response.data) + }, + ) + }, + }, }