mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-05-06 16:34:06 +02:00
Cleanup JS and prolong error notification
This commit is contained in:
parent
45474dc862
commit
6a4e56e727
@ -19,7 +19,7 @@
|
||||
"strict": true,
|
||||
"maxparams": false,
|
||||
"maxdepth": 3,
|
||||
"maxlen": 80,
|
||||
"maxlen": 120,
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"jquery": true,
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.config(
|
||||
function ($routeProvider, $provide, $httpProvider, $locationProvider) {
|
||||
app.config(function ($routeProvider, $provide, $httpProvider, $locationProvider) {
|
||||
'use strict';
|
||||
|
||||
var feedType = {
|
||||
@ -68,16 +67,21 @@ app.config(
|
||||
return {
|
||||
responseError: function (response) {
|
||||
// status 0 is a network error
|
||||
if (response.status in errorMessages) {
|
||||
if (timer) {
|
||||
$timeout.cancel(timer);
|
||||
}
|
||||
OC.Notification.hide();
|
||||
function sendNotification() {
|
||||
OC.Notification.showHtml(errorMessages[response.status]);
|
||||
timer = $timeout(function () {
|
||||
OC.Notification.hide();
|
||||
}, 5000);
|
||||
}
|
||||
if (response.status in errorMessages) {
|
||||
if (timer) {
|
||||
timer.then(function (){
|
||||
sendNotification();
|
||||
});
|
||||
} else {
|
||||
sendNotification();
|
||||
}
|
||||
}
|
||||
return $q.reject(response);
|
||||
}
|
||||
};
|
||||
|
@ -7,9 +7,8 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.run(function ($rootScope, $location, $http, $q, $interval, $route, Loading,
|
||||
ItemResource, FeedResource, FolderResource, SettingsResource,
|
||||
Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) {
|
||||
app.run(function ($rootScope, $location, $http, $q, $interval, $route, Loading, ItemResource, FeedResource,
|
||||
FolderResource, SettingsResource, Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) {
|
||||
'use strict';
|
||||
|
||||
// show Loading screen
|
||||
@ -24,8 +23,7 @@ app.run(function ($rootScope, $location, $http, $q, $interval, $route, Loading,
|
||||
Publisher.subscribe(SettingsResource).toChannels(['settings']);
|
||||
|
||||
// load feeds, settings and last read feed
|
||||
var settingsPromise = $http.get(BASE_URL + '/settings').then(
|
||||
function (response) {
|
||||
var settingsPromise = $http.get(BASE_URL + '/settings').then(function (response) {
|
||||
Publisher.publishAll(response.data);
|
||||
return response.data;
|
||||
});
|
||||
@ -34,9 +32,7 @@ app.run(function ($rootScope, $location, $http, $q, $interval, $route, Loading,
|
||||
var activeFeedPromise = $http.get(BASE_URL + '/feeds/active')
|
||||
.then(function (response) {
|
||||
var url;
|
||||
|
||||
switch (response.data.activeFeed.type) {
|
||||
|
||||
case FEED_TYPE.FEED:
|
||||
url = '/items/feeds/' + response.data.activeFeed.id;
|
||||
break;
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('AppController',
|
||||
function (Loading, FeedResource, FolderResource) {
|
||||
app.controller('AppController', function (Loading, FeedResource, FolderResource) {
|
||||
'use strict';
|
||||
|
||||
this.loading = Loading;
|
||||
|
@ -7,10 +7,9 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('ContentController',
|
||||
function (Publisher, FeedResource, ItemResource, SettingsResource, data,
|
||||
$route, $routeParams, $location, FEED_TYPE, ITEM_AUTO_PAGE_SIZE,
|
||||
Loading, $filter) {
|
||||
app.controller('ContentController', function (Publisher, FeedResource, ItemResource, SettingsResource, data, $route,
|
||||
$routeParams, $location, FEED_TYPE, ITEM_AUTO_PAGE_SIZE, Loading,
|
||||
$filter) {
|
||||
'use strict';
|
||||
|
||||
var self = this;
|
||||
@ -35,11 +34,7 @@ app.controller('ContentController',
|
||||
// the interface should show a hint if there are not enough items sent
|
||||
// it's assumed that theres nothing to autpage
|
||||
|
||||
if (ItemResource.size() >= ITEM_AUTO_PAGE_SIZE) {
|
||||
this.isNothingMoreToAutoPage = false;
|
||||
} else {
|
||||
this.isNothingMoreToAutoPage = true;
|
||||
}
|
||||
this.isNothingMoreToAutoPage = ItemResource.size() < ITEM_AUTO_PAGE_SIZE;
|
||||
|
||||
this.getItems = function () {
|
||||
return ItemResource.getAll();
|
||||
@ -177,8 +172,7 @@ app.controller('ContentController',
|
||||
|
||||
Loading.setLoading('autopaging', true);
|
||||
|
||||
ItemResource.autoPage(type, id, oldestFirst, showAll, search)
|
||||
.then(function (response) {
|
||||
ItemResource.autoPage(type, id, oldestFirst, showAll, search).then(function (response) {
|
||||
Publisher.publishAll(response.data);
|
||||
|
||||
if (response.data.items.length >= ITEM_AUTO_PAGE_SIZE) {
|
||||
@ -201,9 +195,7 @@ app.controller('ContentController',
|
||||
this.getRelativeDate = function (timestamp) {
|
||||
if (timestamp !== undefined && timestamp !== '') {
|
||||
var languageCode = SettingsResource.get('language');
|
||||
var date =
|
||||
moment.unix(timestamp).locale(languageCode).fromNow() + '';
|
||||
return date;
|
||||
return moment.unix(timestamp).locale(languageCode).fromNow() + '';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@ -224,4 +216,4 @@ app.controller('ContentController',
|
||||
};
|
||||
|
||||
this.activeItem = this.getFirstItem();
|
||||
});
|
||||
});
|
@ -7,8 +7,7 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('ExploreController',
|
||||
function (sites, $rootScope, FeedResource, SettingsResource, $location) {
|
||||
app.controller('ExploreController', function (sites, $rootScope, FeedResource, SettingsResource, $location) {
|
||||
'use strict';
|
||||
|
||||
this.sites = sites;
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('NavigationController',
|
||||
function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
|
||||
app.controller('NavigationController', function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
|
||||
SettingsResource, Publisher, $rootScope, $location, $q) {
|
||||
'use strict';
|
||||
|
||||
@ -84,7 +83,7 @@ function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
|
||||
return this.getFeedUnreadCount(feedId) > 0;
|
||||
};
|
||||
|
||||
this.getFolderUnreadCount= function (folderId) {
|
||||
this.getFolderUnreadCount = function (folderId) {
|
||||
return FeedResource.getFolderUnreadCount(folderId);
|
||||
};
|
||||
|
||||
@ -175,15 +174,11 @@ function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
|
||||
// is closed or has no unread articles
|
||||
existingFolder.getsFeed = true;
|
||||
|
||||
FeedResource.create(feed.url, existingFolder.id, undefined,
|
||||
feed.user, feed.password)
|
||||
.then(function (data) {
|
||||
|
||||
FeedResource.create(feed.url, existingFolder.id, undefined, feed.user, feed.password).then(function (data) {
|
||||
Publisher.publishAll(data);
|
||||
|
||||
// set folder as default
|
||||
$location.path('/items/feeds/' + data.feeds[0].id + '/');
|
||||
|
||||
}).finally(function () {
|
||||
existingFolder.getsFeed = undefined;
|
||||
feed.url = '';
|
||||
|
@ -7,9 +7,8 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.controller('SettingsController',
|
||||
function ($route, $q, SettingsResource, ItemResource, OPMLParser,
|
||||
OPMLImporter, Publisher) {
|
||||
app.controller('SettingsController', function ($route, $q, SettingsResource, ItemResource, OPMLParser, OPMLImporter,
|
||||
Publisher) {
|
||||
'use strict';
|
||||
this.isOPMLImporting = false;
|
||||
this.isArticlesImporting = false;
|
||||
@ -34,14 +33,14 @@ app.controller('SettingsController',
|
||||
return SettingsResource.get(key);
|
||||
};
|
||||
|
||||
this.importOPML = function (content) {
|
||||
this.importOPML = function (fileContent) {
|
||||
self.opmlImportError = false;
|
||||
self.opmlImportEmptyError = false;
|
||||
self.articleImportError = false;
|
||||
|
||||
try {
|
||||
this.isOPMLImporting = false;
|
||||
var parsedContent = OPMLParser.parse(content);
|
||||
var parsedContent = OPMLParser.parse(fileContent);
|
||||
|
||||
var jobSize = 5;
|
||||
|
||||
@ -49,10 +48,8 @@ app.controller('SettingsController',
|
||||
parsedContent.feeds.length === 0) {
|
||||
self.opmlImportEmptyError = true;
|
||||
} else {
|
||||
OPMLImporter.importFolders(parsedContent)
|
||||
.then(function (feedQueue) {
|
||||
return OPMLImporter.importFeedQueue(feedQueue,
|
||||
jobSize);
|
||||
OPMLImporter.importFolders(parsedContent).then(function (feedQueue) {
|
||||
return OPMLImporter.importFeedQueue(feedQueue, jobSize);
|
||||
}).finally(function () {
|
||||
self.isOPMLImporting = false;
|
||||
});
|
||||
@ -86,5 +83,4 @@ app.controller('SettingsController',
|
||||
this.isArticlesImporting = false;
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -163,8 +163,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) {
|
||||
};
|
||||
|
||||
|
||||
FeedResource.prototype.create = function (url, folderId, title, user,
|
||||
password) {
|
||||
FeedResource.prototype.create = function (url, folderId, title, user, password) {
|
||||
url = url.trim();
|
||||
if (!url.startsWith('http')) {
|
||||
url = 'https://' + url;
|
||||
@ -203,8 +202,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) {
|
||||
};
|
||||
|
||||
|
||||
FeedResource.prototype.reversiblyDelete = function (id, updateCache,
|
||||
isFolder) {
|
||||
FeedResource.prototype.reversiblyDelete = function (id, updateCache, isFolder) {
|
||||
var feed = this.getById(id);
|
||||
|
||||
// if a folder is deleted it does not have to trigger the delete
|
||||
@ -329,7 +327,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) {
|
||||
var feed = this.getById(feedId);
|
||||
|
||||
if (feed) {
|
||||
Object.keys(diff).forEach(function(key) {
|
||||
Object.keys(diff).forEach(function (key) {
|
||||
feed[key] = diff[key];
|
||||
});
|
||||
var url = this.BASE_URL + '/feeds/' + feedId;
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.factory('ItemResource', function (Resource, $http, BASE_URL,
|
||||
ITEM_BATCH_SIZE) {
|
||||
app.factory('ItemResource', function (Resource, $http, BASE_URL, ITEM_BATCH_SIZE) {
|
||||
'use strict';
|
||||
|
||||
var ItemResource = function ($http, BASE_URL, ITEM_BATCH_SIZE) {
|
||||
@ -29,7 +28,6 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
|
||||
|
||||
ItemResource.prototype.receive = function (value, channel) {
|
||||
switch (channel) {
|
||||
|
||||
case 'newestItemId':
|
||||
this.newestItemId = value;
|
||||
break;
|
||||
@ -135,7 +133,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
|
||||
ItemResource.prototype.markItemsRead = function (itemIds) {
|
||||
var self = this;
|
||||
|
||||
itemIds.forEach(function(itemId) {
|
||||
itemIds.forEach(function (itemId) {
|
||||
self.get(itemId).unread = false;
|
||||
});
|
||||
|
||||
@ -183,8 +181,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
|
||||
};
|
||||
|
||||
|
||||
ItemResource.prototype.autoPage = function (type, id, oldestFirst,
|
||||
showAll, search) {
|
||||
ItemResource.prototype.autoPage = function (type, id, oldestFirst, showAll, search) {
|
||||
var offset;
|
||||
|
||||
if (oldestFirst) {
|
||||
@ -216,7 +213,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
|
||||
data: {
|
||||
json: json
|
||||
}
|
||||
}).then(function(response) {
|
||||
}).then(function (response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @author Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
* @copyright Bernhard Posselt 2014
|
||||
*/
|
||||
app.service('OPMLImporter', function (FeedResource, FolderResource, Publisher,
|
||||
$q) {
|
||||
app.service('OPMLImporter', function (FeedResource, FolderResource, Publisher, $q) {
|
||||
'use strict';
|
||||
var startFeedJob = function (queue) {
|
||||
var deferred = $q.defer();
|
||||
|
@ -43,7 +43,6 @@ app.service('OPMLParser', function () {
|
||||
if (entry.type === 'feed') {
|
||||
root.feeds.push(entry);
|
||||
} else {
|
||||
|
||||
// only first level should append folders
|
||||
if (firstLevel) {
|
||||
recursivelyParse(outline.children('outline'), entry, false);
|
||||
@ -57,8 +56,8 @@ app.service('OPMLParser', function () {
|
||||
return root;
|
||||
};
|
||||
|
||||
this.parse = function (xml) {
|
||||
xml = $.parseXML(xml);
|
||||
this.parse = function (fileContent) {
|
||||
var xml = $.parseXML(fileContent);
|
||||
var firstLevel = $(xml).find('body > outline');
|
||||
|
||||
var root = {
|
||||
|
@ -55,7 +55,7 @@ app.factory('Resource', function () {
|
||||
Resource.prototype.delete = function (id) {
|
||||
// find index of object that should be deleted
|
||||
var self = this;
|
||||
var deleteAtIndex = this.values.findIndex(function(element) {
|
||||
var deleteAtIndex = this.values.findIndex(function (element) {
|
||||
return element[self.id] === id;
|
||||
});
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<p><?php p($l->t('Ajax or webcron mode detected! Your feeds will not be updated!')); ?></p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://docs.nextcloud.org/server/9/admin_manual/configuration_server/background_jobs_configuration.html#cron"
|
||||
<a href="https://docs.nextcloud.org/server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron"
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<?php
|
||||
@ -29,7 +29,7 @@
|
||||
<p><?php p($l->t('Non UTF-8 charset for MySQL/MariaDB database detected!')); ?></p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://docs.nextcloud.com/server/13/admin_manual/configuration_database/mysql_4byte_support.html"
|
||||
<a href="https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/mysql_4byte_support.html"
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<?php
|
||||
|
Loading…
Reference in New Issue
Block a user