diff --git a/lib/Dashboard/RadioWidget.php b/lib/Dashboard/RadioWidget.php index d7023f0..b47d8af 100644 --- a/lib/Dashboard/RadioWidget.php +++ b/lib/Dashboard/RadioWidget.php @@ -14,10 +14,15 @@ class RadioWidget implements IWidget { /** @var IL10N */ private $l10n; + /** @var IURLGenerator */ + private $urlGenerator; + public function __construct( - IL10N $l10n + IL10N $l10n, + IURLGenerator $urlGenerator ) { $this->l10n = $l10n; + $this->urlGenerator = $urlGenerator; } /** @@ -52,15 +57,14 @@ class RadioWidget implements IWidget { * @inheritDoc */ public function getUrl(): ?string { - return \OC::$server->getURLGenerator()->linkToRoute('radio.page.index'); - // return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('radio.page.index')); + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('radio.page.index')); } /** * @inheritDoc */ public function load(): void { - Util::addScript(Application::APP_ID, 'dashboard'); - Util::addStyle(Application::APP_ID, 'dashboard'); - } + Util::addScript(Application::APP_ID, 'radio-dashboard'); + Util::addStyle(Application::APP_ID, 'dashboard'); + } } diff --git a/src/components/Dashboard.vue b/src/components/Dashboard.vue index c6bab86..2421aef 100644 --- a/src/components/Dashboard.vue +++ b/src/components/Dashboard.vue @@ -9,11 +9,6 @@ :icon="emptyContentIcon"> @@ -22,9 +17,8 @@ - - diff --git a/src/dashboard.js b/src/dashboard.js index d1dbab4..29ea55b 100644 --- a/src/dashboard.js +++ b/src/dashboard.js @@ -1,19 +1,15 @@ import Vue from 'vue' -import { translate, translatePlural } from '@nextcloud/l10n' -import Dashboard from './components/Dashboard' +import router from './router' +import store from './store' +import Dashboard from './components/Dashboard.vue' -Vue.prototype.t = translate -Vue.prototype.n = translatePlural -Vue.prototype.OC = window.OC -Vue.prototype.OCA = window.OCA - -document.addEventListener('DOMContentLoaded', function() { - - OCA.Dashboard.register('radio', (el, { widget }) => { - const View = Vue.extend(Dashboard) - new View({ - propsData: { title: widget.title }, - }).$mount(el) +document.addEventListener('DOMContentLoaded', () => { + OCA.Dashboard.register('radio', (el) => { + global.Radio = new Vue({ + el, + store, + router, + render: h => h(Dashboard), + }) }) - }) diff --git a/src/main.js b/src/main.js index 0eee982..7331165 100644 --- a/src/main.js +++ b/src/main.js @@ -27,8 +27,6 @@ import { translate, translatePlural } from '@nextcloud/l10n' import App from './App' -import './dashboard' - import VueBlurHash from 'vue-blurhash' import 'vue-blurhash/dist/vue-blurhash.css' diff --git a/webpack.js b/webpack.js index e5daa92..f1726a2 100644 --- a/webpack.js +++ b/webpack.js @@ -1,3 +1,24 @@ +const { merge } = require('webpack-merge') +const path = require('path') const webpackConfig = require('@nextcloud/webpack-vue-config') -module.exports = webpackConfig +const config = { + entry: { + dashboard: path.join(__dirname, 'src', 'dashboard.js'), + }, + module: { + rules: [ + { + test: /\.vue$/, + loader: 'vue-loader', + }, + ], + }, +} + +const mergedConfigs = merge(config, webpackConfig) + +// Remove duplicate rules by the `test` key +mergedConfigs.module.rules = mergedConfigs.module.rules.filter((v, i, a) => a.findIndex(t => (t.test.toString() === v.test.toString())) === i) + +module.exports = mergedConfigs