From 440f18dea38fdd7d186e99336b87f970b9299b5d Mon Sep 17 00:00:00 2001 From: e-lie Date: Sun, 2 Sep 2018 12:28:55 +0000 Subject: [PATCH] last improvements l10n+roles+filtering --- src/js/yunohost/controllers/apps.js | 23 ++++++++++++----------- src/locales/en.json | 8 ++++++++ src/views/app/app_list_install.ms | 28 ++++++++++++++-------------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 01caa518..2619361f 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -77,20 +77,23 @@ c.api('/apps?raw', function (dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8 var apps = [] $.each(data['apps'], function(k, v) { + var state = dataraw[v['id']]['state']; + var isWorking = (state === 'working' || state === 'validated'); // Keep only the first instance of each app and remove community not working apps - if (!v['id'].match(/__[0-9]{1,5}$/) && (dataraw[v['id']]['repository'] === 'yunohost' || dataraw[v['id']]['state'] !== 'notworking')) { - // Check app source + if (!v['id'].match(/__[0-9]{1,5}$/) && (dataraw[v['id']]['repository'] === 'yunohost' || state !== 'notworking')) { + dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance) dataraw[v['id']]['status'] = (dataraw[v['id']]['repository'] === 'yunohost') ? 'official' : 'community'; levelFormatted = parseInt(dataraw[v['id']]['level']); dataraw[v['id']]['levelFormatted'] = isNaN(levelFormatted) ? '?' : levelFormatted; dataraw[v['id']]['levelColor'] = levelToColor(levelFormatted); - dataraw[v['id']]['stateColor'] = stateToColor(dataraw[v['id']]['state']); + dataraw[v['id']]['stateColor'] = stateToColor(state); dataraw[v['id']]['installColor'] = combineColors(dataraw[v['id']]['stateColor'], dataraw[v['id']]['levelColor']); dataraw[v['id']]['displayLicense'] = (dataraw[v['id']]['manifest']['license'] !== undefined && dataraw[v['id']]['manifest']['license'] !== 'free'); dataraw[v['id']]['updateDate'] = timeConverter(dataraw[v['id']]['lastUpdate']); - dataraw[v['id']]['isSafe'] = (dataraw[v['id']]['installColor'] === 'danger'); + dataraw[v['id']]['isSafe'] = (dataraw[v['id']]['installColor'] !== 'danger'); + dataraw[v['id']]['isWorking'] = isWorking ? "isworking" : "notFullyWorking"; jQuery.extend(dataraw[v['id']], v); apps.push(dataraw[v['id']]); @@ -100,7 +103,6 @@ // Sort app list c.arraySortById(apps); - // setup filtering of apps once the view is loaded function setupFilterEvents () { // Uses plugin isotope to filter apps (we could had ordering to) @@ -110,16 +112,16 @@ transitionDuration: 200 }); - filterByClassAndName = function() { + filterByClassAndName = function () { var input = jQuery("#filter-app-cards").val().toLowerCase(); - var stringMatch = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1); + var inputMatch = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1); var filterClass = jQuery("#dropdownFilter").attr("data-filter"); var classMatch = (filterClass === '*') ? true : jQuery(this).hasClass(filterClass); - return stringMatch && classMatch; + return inputMatch && classMatch; }, - // Keep only official apps at render + // Keep only official apps at first render cardGrid.isotope({ filter: '.official' }); jQuery('.dropdownFilter').on('click', function() { @@ -127,7 +129,7 @@ jQuery('#app-cards-list-filter-text').text(jQuery(this).find('.menu-item').text()); // change filter attribute jQuery('#dropdownFilter').attr("data-filter", jQuery(this).attr("data-filter")); - + // filter ! cardGrid.isotope({ filter: filterByClassAndName }); }); @@ -136,7 +138,6 @@ }); }; - // render c.view('app/app_list_install', {apps: apps}, setupFilterEvents); diff --git a/src/locales/en.json b/src/locales/en.json index 857c211d..131527cf 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -5,6 +5,7 @@ "remove": "Remove", "administration_password": "Administration password", "allowed_users": "Allowed users", + "all_apps": "All apps", "api_not_responding": "API is not responding", "app_access": "Access", "app_access_addall_btn": "Enable access to all", @@ -28,6 +29,8 @@ "app_install_cancel": "Installation cancelled.", "app_install_custom_no_manifest": "No manifest.json file", "app_list": "App list", + "app_license": "License of the app", + "app_level": "App level", "app_make_default": "Make default", "app_no_actions": "This application doesn't have any actions", "app_repository": "Application origin: ", @@ -95,6 +98,7 @@ "cpu_load": "CPU Load", "created_at": "Created at", "cumulative_usage": "Cumulative usage", + "current_maintainer_title": "Current maintainer of this package", "custom_app_install": "Install custom app", "custom_app_url_only_github": "Currently only from GitHub", "default": "Default", @@ -215,6 +219,8 @@ "no_user_to_add": "No more users to add.", "non_compatible_api": "Non-compatible API", "ok": "OK", + "only_official_apps": "Only official apps", + "only_working_apps": "Only working apps", "open": "Open", "operations": "Operations", "os": "OS", @@ -270,6 +276,7 @@ "run": "Run", "running": "Running", "save": "Save", + "search_for_apps": "Search for apps...", "select_user": "Select user", "service_description": "Description:", "service_log": "%s log", @@ -330,6 +337,7 @@ "uninstall": "Uninstall", "unknown_action": "Unknown action %s", "unknown_argument": "Unknown argument : %s", + "unmaintained": "Unmaintained", "upload": "Upload", "upload_archive": "Archive upload", "upnp": "UPnP", diff --git a/src/views/app/app_list_install.ms b/src/views/app/app_list_install.ms index bdc9f2a3..973e03eb 100644 --- a/src/views/app/app_list_install.ms +++ b/src/views/app/app_list_install.ms @@ -17,15 +17,15 @@
- +
@@ -34,36 +34,36 @@
{{#apps}} -
+

{{name}}

{{levelFormatted}} {{t status}} {{t state}} - {{#displayLicense}}{{license}}{{/displayLicense}} + {{#displayLicense}}{{license}}{{/displayLicense}}
{{description}}
{{updateDate}} - - {{#maintained}} {{manifest.maintainer.name}}{{/maintained}} - {{^maintained}} {{t 'Unmaintained'}}{{/maintained}} + {{#maintained}} {{manifest.maintainer.name}}{{/maintained}} + {{^maintained}} {{t 'unmaintained'}}{{/maintained}}
- + Code - + Readme {{#installable}} - - Install {{#isSafe}}{{/isSafe}} + + {{t 'install'}}{{^isSafe}} {{/isSafe}} {{/installable}} {{^installable}} - Installed + {{t 'installed'}} {{/installable}}