Use webpack variables for app version
This commit is contained in:
parent
eb2d41dc4b
commit
19a99d077c
|
@ -12,7 +12,7 @@ module.exports = {
|
|||
OC: false,
|
||||
OCA: false,
|
||||
moment: true,
|
||||
oca_tasks: true,
|
||||
appVersion: true,
|
||||
},
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
|
|
|
@ -26,7 +26,6 @@ use \OCP\AppFramework\Controller;
|
|||
use \OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\IRequest;
|
||||
use \OCP\IUserSession;
|
||||
use \OCP\IConfig;
|
||||
|
||||
/**
|
||||
* Controller class for main page.
|
||||
|
@ -38,21 +37,14 @@ class PageController extends Controller {
|
|||
*/
|
||||
private $userSession;
|
||||
|
||||
/**
|
||||
* @var IConfig
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param IRequest $request an instance of the request
|
||||
* @param IUserSession $userSession
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(string $appName, IRequest $request, IUserSession $userSession, IConfig $config) {
|
||||
public function __construct(string $appName, IRequest $request, IUserSession $userSession) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userSession = $userSession;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,23 +55,6 @@ class PageController extends Controller {
|
|||
* @return TemplateResponse
|
||||
*/
|
||||
public function index():TemplateResponse {
|
||||
\OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex');
|
||||
return new TemplateResponse('tasks', 'main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add parameters to javascript for user sites
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function addJavaScriptVariablesForIndex(array $array) {
|
||||
$user = $this->userSession->getUser();
|
||||
if ($user === null) {
|
||||
return;
|
||||
}
|
||||
$appversion = $this->config->getAppValue($this->appName, 'installed_version');
|
||||
$array['array']['oca_tasks'] = \json_encode([
|
||||
'versionstring' => $appversion,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ Vue.prototype.t = t
|
|||
Vue.prototype.n = n
|
||||
Vue.prototype.OC = OC
|
||||
Vue.prototype.OCA = OCA
|
||||
Vue.prototype.appVersion = appVersion
|
||||
|
||||
OCA.Tasks.App = new Vue({
|
||||
el: '.app-tasks',
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* @copyright Copyright (c) 2018 Georg Ehrke
|
||||
*
|
||||
* @author Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* returns the version string of the calendar app
|
||||
*
|
||||
* @returns {String}
|
||||
*/
|
||||
export function getAppVersion() {
|
||||
return oca_tasks.versionstring
|
||||
}
|
|
@ -26,7 +26,6 @@ import Task from '../models/task'
|
|||
import { isParentInList, momentToICALTime } from './storeHelper'
|
||||
import ICAL from 'ical.js'
|
||||
import TaskStatus from '../models/taskStatus'
|
||||
import { getAppVersion } from '../services/productInformationProvider'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
@ -525,7 +524,7 @@ const actions = {
|
|||
taskData.calendar = context.getters.getDefaultCalendar
|
||||
}
|
||||
|
||||
let task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Nextcloud Tasks v' + getAppVersion() + '\nEND:VCALENDAR', taskData.calendar)
|
||||
let task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Nextcloud Tasks v' + appVersion + '\nEND:VCALENDAR', taskData.calendar)
|
||||
|
||||
task.created = ICAL.Time.now()
|
||||
task.summary = taskData.summary
|
||||
|
|
|
@ -43,7 +43,13 @@ module.exports = {
|
|||
}
|
||||
]
|
||||
},
|
||||
plugins: [new VueLoaderPlugin(), new StyleLintPlugin()],
|
||||
plugins: [
|
||||
new VueLoaderPlugin(),
|
||||
new StyleLintPlugin(),
|
||||
new webpack.DefinePlugin({
|
||||
appVersion: JSON.stringify(require('./package.json').version)
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['*', '.js', '.vue', '.json']
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue