diff --git a/src/bower.json b/src/bower.json index 98521387..0d0e89f5 100644 --- a/src/bower.json +++ b/src/bower.json @@ -10,6 +10,7 @@ "handlebars": "4.0.11", "sammy": "0.7.6", "js-cookie": "2.1.0", + "isotope-layout": "3.0.6", "source-sans-pro": "git://github.com/adobe-fonts/source-sans-pro.git#2.020R-ro/1.075R-it", "source-code-pro": "git://github.com/adobe-fonts/source-code-pro.git#2.010R-ro/1.030R-it" } diff --git a/src/gulpfile.js b/src/gulpfile.js index add727a7..5875faf9 100644 --- a/src/gulpfile.js +++ b/src/gulpfile.js @@ -47,6 +47,7 @@ gulp.task('js', function() { 'bower_components/sammy/lib/plugins/sammy.json.js', 'bower_components/sammy/lib/plugins/sammy.storage.js', 'bower_components/bootstrap/dist/js/bootstrap.js', + 'bower_components/isotope-layout/dist/isotope.pkgd.js', 'js/yunohost/y18n.js', 'js/yunohost/main.js', 'js/yunohost/helpers.js', diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 76b39f54..c029fe02 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -18,15 +18,41 @@ }); function levelToColor(level) { - if (level > 6) { - return 'success'; - } - else if (level > 2) { - return 'warning'; - } - else { - return 'danger'; - } + if (level > 6) { + return 'success'; + } + else if (level > 2) { + return 'warning'; + } + else if (isNaN(level)) { + return 'default'; + } else { + return 'danger' + } + } + + function stateToColor(state) { + if (state === "working" || state === "validated") { + return 'success'; + } + else if (state === "inprogress") { + return 'warning'; + } + else { + return 'danger'; + } + } + + function combineColors(stateColor, levelColor, installable) { + if (stateColor === "dangers" || levelColor === "danger") { + return 'danger'; + } + if (stateColor === "warnings" || levelColor === "warnings" || levelColor === "default") { + return 'warning'; + } + else { + return 'success'; + } } @@ -51,15 +77,20 @@ c.api('/apps?raw', function (dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8 var apps = [] $.each(data['apps'], function(k, v) { - // Keep only uninstalled apps, or multi-instance apps - if ((!v['installed'] || dataraw[v['id']].manifest.multi_instance) && !v['id'].match(/__[0-9]{1,5}$/)) { + // Keep only on instance of each apps + if (!v['id'].match(/__[0-9]{1,5}$/)) { // Check app source + dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance) dataraw[v['id']]['official'] = (dataraw[v['id']]['repository'] === 'yunohost'); - dataraw[v['id']]['color'] = levelToColor(dataraw[v['id']]['level']); + 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']]['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'); jQuery.extend(dataraw[v['id']], v); apps.push(dataraw[v['id']]); diff --git a/src/views/app/app_list_install.ms b/src/views/app/app_list_install.ms index 479cfc92..da69a3dd 100644 --- a/src/views/app/app_list_install.ms +++ b/src/views/app/app_list_install.ms @@ -21,9 +21,10 @@

{{name}}

- {{level}} + {{levelFormatted}} {{^official}}{{t 'community'}}{{/official}} {{#official}}{{t 'official'}}{{/official}} + {{state}} {{#displayLicense}}{{license}}{{/displayLicense}}
{{description}}
@@ -38,10 +39,10 @@ Code - Doc + Readme - - Install + + Install {{#isSafe}}{{/isSafe}}