wire the frontend

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-07-05 20:29:00 +02:00
parent 772bbd99be
commit ca6094f390
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
4 changed files with 130 additions and 9 deletions

View File

@ -2,3 +2,4 @@
@import 'upload.scss'; @import 'upload.scss';
@import 'mobile.scss'; @import 'mobile.scss';
@import 'detailsView.scss'; @import 'detailsView.scss';
@import '../../../core/css/whatsnew.scss';

View File

@ -29,6 +29,7 @@ use OC\Updater\ChangesCheck;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\Defaults;
use OCP\IConfig; use OCP\IConfig;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserManager; use OCP\IUserManager;
@ -45,6 +46,8 @@ class WhatsNewController extends OCSController {
private $whatsNewService; private $whatsNewService;
/** @var IFactory */ /** @var IFactory */
private $langFactory; private $langFactory;
/** @var Defaults */
private $defaults;
public function __construct( public function __construct(
string $appName, string $appName,
@ -55,13 +58,15 @@ class WhatsNewController extends OCSController {
Manager $keyManager, Manager $keyManager,
IConfig $config, IConfig $config,
ChangesCheck $whatsNewService, ChangesCheck $whatsNewService,
IFactory $langFactory IFactory $langFactory,
Defaults $defaults
) { ) {
parent::__construct($appName, $request, $capabilitiesManager, $userSession, $userManager, $keyManager); parent::__construct($appName, $request, $capabilitiesManager, $userSession, $userManager, $keyManager);
$this->config = $config; $this->config = $config;
$this->userSession = $userSession; $this->userSession = $userSession;
$this->whatsNewService = $whatsNewService; $this->whatsNewService = $whatsNewService;
$this->langFactory = $langFactory; $this->langFactory = $langFactory;
$this->defaults = $defaults;
} }
/** /**
@ -82,7 +87,11 @@ class WhatsNewController extends OCSController {
try { try {
$iterator = $this->langFactory->getLanguageIterator(); $iterator = $this->langFactory->getLanguageIterator();
$whatsNew = $this->whatsNewService->getChangesForVersion($currentVersion); $whatsNew = $this->whatsNewService->getChangesForVersion($currentVersion);
$resultData = ['changelogURL' => $whatsNew['changelogURL']]; $resultData = [
'changelogURL' => $whatsNew['changelogURL'],
'product' => $this->defaults->getName(),
'version' => $currentVersion,
];
do { do {
$lang = $iterator->current(); $lang = $iterator->current();
if(isset($whatsNew['whatsNew'][$lang])) { if(isset($whatsNew['whatsNew'][$lang])) {

31
core/css/whatsnew.scss Normal file
View File

@ -0,0 +1,31 @@
/**
* @copyright Copyright (c) 2018, Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @license GNU AGPL version 3 or any later version
*
*/
.whatsNewPopover {
bottom: 35px !important;
left: 15px !important;
width: 270px;
background-color: var(--color-background-dark);
}
.whatsNewPopover p {
width: auto !important;
}
.whatsNewPopover .caption {
font-weight: bolder;
cursor: auto !important;
}
.whatsNewPopover .icon-close {
position: absolute;
right: 0;
}
.whatsNewPopover::after {
content: none;
}

View File

@ -14,10 +14,13 @@
query: function(options) { query: function(options) {
options = options || {}; options = options || {};
var dismissOptions = options.dismiss || {};
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: options.url || OC.linkToOCS('core', 2) + 'whatsnew?format=json', url: options.url || OC.linkToOCS('core', 2) + 'whatsnew?format=json',
success: options.success || this._onQuerySuccess, success: options.success || function(data, statusText, xhr) {
OCP.WhatsNew._onQuerySuccess(data, statusText, xhr, dismissOptions);
},
error: options.error || this._onQueryError error: options.error || this._onQueryError
}); });
}, },
@ -31,20 +34,97 @@
success: options.success || this._onDismissSuccess, success: options.success || this._onDismissSuccess,
error: options.error || this._onDismissError error: options.error || this._onDismissError
}); });
// remove element immediately
$('.whatsNewPopover').remove();
}, },
_onQuerySuccess: function(data, statusText) { _onQuerySuccess: function(data, statusText, xhr, dismissOptions) {
console.debug('querying Whats New data was successful: ' + data || statusText); console.debug('querying Whats New data was successful: ' + statusText);
console.debug(data); console.debug(data);
if(xhr.status !== 200) {
return;
}
var item, menuItem, text, icon;
var div = document.createElement('div');
div.classList.add('popovermenu', 'open', 'whatsNewPopover', 'menu-left');
var list = document.createElement('ul');
// header
item = document.createElement('li');
menuItem = document.createElement('span');
menuItem.className = "menuitem";
text = document.createElement('span');
text.innerText = t('core', 'New in') + ' ' + data['ocs']['data']['product'];
text.className = 'caption';
menuItem.appendChild(text);
icon = document.createElement('span');
icon.className = 'icon-close';
icon.onclick = function () {
OCP.WhatsNew.dismiss(data['ocs']['data']['version'], dismissOptions);
};
menuItem.appendChild(icon);
item.appendChild(menuItem);
list.appendChild(item);
// Highlights
for (var i in data['ocs']['data']['whatsNew']['regular']) {
var whatsNewTextItem = data['ocs']['data']['whatsNew']['regular'][i];
item = document.createElement('li');
menuItem = document.createElement('span');
menuItem.className = "menuitem";
icon = document.createElement('span');
icon.className = 'icon-star-dark';
menuItem.appendChild(icon);
text = document.createElement('p');
text.innerHTML = _.escape(whatsNewTextItem);
menuItem.appendChild(text);
item.appendChild(menuItem);
list.appendChild(item);
}
// Changelog URL
if(!_.isUndefined(data['ocs']['data']['changelogURL'])) {
item = document.createElement('li');
menuItem = document.createElement('a');
menuItem.href = data['ocs']['data']['changelogURL'];
menuItem.rel = 'noreferrer noopener';
menuItem.target = '_blank';
icon = document.createElement('span');
icon.className = 'icon-link';
menuItem.appendChild(icon);
text = document.createElement('span');
text.innerText = t('core', 'View changelog');
menuItem.appendChild(text);
item.appendChild(menuItem);
list.appendChild(item);
}
div.appendChild(list);
document.body.appendChild(div);
}, },
_onQueryError: function (o, t, e) { _onQueryError: function (x, t, e) {
console.debug(o); console.debug('querying Whats New Data resulted in an error: ' + t + e);
console.debug('querying Whats New Data resulted in an error: ' + t +e); console.debug(x);
}, },
_onDismissSuccess: function(data) { _onDismissSuccess: function(data) {
console.debug('dismissing Whats New data was successful: ' + data); //noop
}, },
_onDismissError: function (data) { _onDismissError: function (data) {