summaryrefslogtreecommitdiffstats
path: root/core/js/public
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-07-05 20:29:00 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-07-05 20:29:00 +0200
commitca6094f3900fd463449d9973589b1d49aed28b2a (patch)
tree89b404a60b20bd5bf6b02271e0a2c57a7c99fac7 /core/js/public
parent772bbd99bee83d17707c73a630a4d47c4b8bc807 (diff)
downloadnextcloud-server-ca6094f3900fd463449d9973589b1d49aed28b2a.tar.gz
nextcloud-server-ca6094f3900fd463449d9973589b1d49aed28b2a.zip
wire the frontend
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'core/js/public')
-rw-r--r--core/js/public/whatsnew.js94
1 files changed, 87 insertions, 7 deletions
diff --git a/core/js/public/whatsnew.js b/core/js/public/whatsnew.js
index dc5862e8572..20a871ada27 100644
--- a/core/js/public/whatsnew.js
+++ b/core/js/public/whatsnew.js
@@ -14,10 +14,13 @@
query: function(options) {
options = options || {};
+ var dismissOptions = options.dismiss || {};
$.ajax({
type: 'GET',
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
});
},
@@ -31,20 +34,97 @@
success: options.success || this._onDismissSuccess,
error: options.error || this._onDismissError
});
+ // remove element immediately
+ $('.whatsNewPopover').remove();
},
- _onQuerySuccess: function(data, statusText) {
- console.debug('querying Whats New data was successful: ' + data || statusText);
+ _onQuerySuccess: function(data, statusText, xhr, dismissOptions) {
+ console.debug('querying Whats New data was successful: ' + statusText);
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) {
- console.debug(o);
- console.debug('querying Whats New Data resulted in an error: ' + t +e);
+ _onQueryError: function (x, t, e) {
+ console.debug('querying Whats New Data resulted in an error: ' + t + e);
+ console.debug(x);
},
_onDismissSuccess: function(data) {
- console.debug('dismissing Whats New data was successful: ' + data);
+ //noop
},
_onDismissError: function (data) {