Rework the appstore view

This commit is contained in:
Johannes Zellner
2020-06-12 15:02:41 +02:00
parent ec71b622fc
commit a31617fcb0
3 changed files with 128 additions and 62 deletions
+37 -8
View File
@@ -39,6 +39,36 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
$('.modal').modal('hide');
};
$scope.categories = [
{ id: 'analytics', icon: 'fa fa-chart-line', label: 'Analytics'},
{ id: 'blog', icon: 'fa fa-font', label: 'Blog'},
{ id: 'chat', icon: 'fa fa-comments', label: 'Chat'},
{ id: 'git', icon: 'fa fa-code-branch', label: 'Code Hosting'},
{ id: 'crm', icon: 'fab fa-connectdevelop', label: 'CRM'},
{ id: 'document', icon: 'fa fa-file-word', label: 'Documents'},
{ id: 'email', icon: 'fa fa-envelope', label: 'Email'},
{ id: 'sync', icon: 'fa fa-sync-alt', label: 'File Sync'},
{ id: 'finance', icon: 'fa fa-hand-holding-usd', label: 'Finance'},
{ id: 'forum', icon: 'fa fa-users', label: 'Forum'},
{ id: 'gallery', icon: 'fa fa-images', label: 'Gallery'},
{ id: 'game', icon: 'fa fa-gamepad', label: 'Games'},
{ id: 'notes', icon: 'fa fa-sticky-note', label: 'Notes'},
{ id: 'project', icon: 'fas fa-project-diagram', label: 'Project Management'},
{ id: 'vpn', icon: 'fa fa-user-secret', label: 'VPN'},
{ id: 'hosting', icon: 'fa fa-server', label: 'Web Hosting'},
{ id: 'wiki', icon: 'fab fa-wikipedia-w', label: 'Wiki'},
];
$scope.categoryLabel = function (category) {
if (category === 'new') return 'New Apps';
if (category === 'recent') return 'Recently Updated';
var tmp = $scope.categories.find(function (c) { return c.id === category; });
if (tmp) return tmp.label;
return '';
};
$scope.appInstall = {
busy: false,
state: 'appInfo',
@@ -338,8 +368,8 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
Client.getAppstoreApps(function (error) {
if (error) return callback(error);
// start with featured apps listing. this also sets $scope.apps accordingly
$scope.showCategory(null, 'featured');
// start with all apps listing. this also sets $scope.apps accordingly
$scope.showCategory('');
// do this in background
fetchUsers();
@@ -385,7 +415,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
};
function filterForNewApps(apps) {
var minApps = apps.length < 5 ? apps.length : 5; // prevent endless loop
var minApps = apps.length < 10 ? apps.length : 10; // prevent endless loop
var tmp = [];
var i = 0;
@@ -398,7 +428,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
}
function filterForRecentlyUpdatedApps(apps) {
var minApps = apps.length < 5 ? apps.length : 5; // prevent endless loop
var minApps = apps.length < 10 ? apps.length : 10; // prevent endless loop
var tmp = [];
var i = 0;
@@ -410,14 +440,13 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
return tmp;
}
$scope.showCategory = function (event, category) {
if (!event) $scope.category = category;
else $scope.category = event.target.getAttribute('category');
$scope.showCategory = function (category) {
$scope.category = category;
$scope.cachedCategory = $scope.category;
Client.getAppstoreAppsFast(function (error, apps) {
if (error) return $timeout($scope.showCategory.bind(null, event), 1000);
if (error) return $timeout($scope.showCategory.bind(null, category), 1000);
if (!$scope.category) {
$scope.apps = apps;