mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Propagate API changes + improve semantics before actually working on app categories implementation
This commit is contained in:
parent
95f8503e6d
commit
749aba93fe
5 changed files with 86 additions and 89 deletions
|
@ -10,7 +10,7 @@
|
|||
|
||||
// List installed apps
|
||||
app.get('#/apps', function (c) {
|
||||
c.api('GET', '/apps?installed', {}, function(data) {
|
||||
c.api('GET', '/apps?full', {}, function(data) {
|
||||
var apps = data['apps'];
|
||||
c.arraySortById(apps);
|
||||
c.view('app/app_list', {apps: apps});
|
||||
|
@ -107,101 +107,98 @@
|
|||
}
|
||||
}
|
||||
|
||||
// List available apps
|
||||
app.get('#/apps/install', function (c) {
|
||||
c.api('GET', '/apps', {}, function (data) {
|
||||
c.api('GET', '/apps?raw', {}, function (dataraw) {
|
||||
var apps = []
|
||||
$.each(data['apps'], function(k, v) {
|
||||
app = dataraw[v['id']];
|
||||
app.level = parseInt(app.level);
|
||||
// Display app catalog
|
||||
app.get('#/apps/catalog', function (c) {
|
||||
c.api('GET', '/appscatalog?full&with_categories', {}, function (data) {
|
||||
var apps = []
|
||||
$.each(data['apps'], function(name, app) {
|
||||
|
||||
if (app.high_quality && app.level > 7)
|
||||
{
|
||||
app.state = "high-quality";
|
||||
}
|
||||
if ( app.maintained === false )
|
||||
{
|
||||
app.maintained = "orphaned";
|
||||
}
|
||||
else if ( app.maintained === true )
|
||||
{
|
||||
app.maintained = "maintained";
|
||||
}
|
||||
// Ignore not working apps
|
||||
if (app.state === 'notworking') { return; }
|
||||
|
||||
app.manifest.maintainer = extractMaintainer(app.manifest);
|
||||
var isWorking = (app.state === 'working' || app.state === "high-quality") && app.level > 0;
|
||||
app.id = app.manifest.id;
|
||||
app.level = parseInt(app.level);
|
||||
|
||||
// Keep only the first instance of each app and remove not working apps
|
||||
if (!v['id'].match(/__[0-9]{1,5}$/) && (app.state !== 'notworking')) {
|
||||
if (app.high_quality && app.level > 7)
|
||||
{
|
||||
app.state = "high-quality";
|
||||
}
|
||||
if ( app.maintained === false )
|
||||
{
|
||||
app.maintained = "orphaned";
|
||||
}
|
||||
else if ( app.maintained === true )
|
||||
{
|
||||
app.maintained = "maintained";
|
||||
}
|
||||
|
||||
app.installable = (!v.installed || app.manifest.multi_instance)
|
||||
app.levelFormatted = isNaN(app.level) ? '?' : app.level;
|
||||
app.manifest.maintainer = extractMaintainer(app.manifest);
|
||||
var isWorking = (app.state === 'working' || app.state === "high-quality") && app.level > 0;
|
||||
|
||||
app.levelColor = levelToColor(app.level);
|
||||
app.stateColor = stateToColor(app.state);
|
||||
app.maintainedColor = maintainedStateToColor(app.maintained);
|
||||
app.installColor = combineColors(app.stateColor, app.levelColor);
|
||||
app.installable = (!app.installed || app.manifest.supports_multi_instance)
|
||||
app.levelFormatted = isNaN(app.level) ? '?' : app.level;
|
||||
|
||||
app.updateDate = app.lastUpdate * 1000 || 0;
|
||||
app.isSafe = (app.installColor !== 'danger');
|
||||
app.isWorking = isWorking ? "isworking" : "notFullyWorking";
|
||||
app.isHighQuality = (app.state === "high-quality") ? "isHighQuality" : "";
|
||||
app.decentQuality = (app.level > 4)?"decentQuality":"badQuality";
|
||||
app.levelColor = levelToColor(app.level);
|
||||
app.stateColor = stateToColor(app.state);
|
||||
app.maintainedColor = maintainedStateToColor(app.maintained);
|
||||
app.installColor = combineColors(app.stateColor, app.levelColor);
|
||||
|
||||
jQuery.extend(app, v);
|
||||
apps.push(app);
|
||||
}
|
||||
app.updateDate = app.lastUpdate * 1000 || 0;
|
||||
app.isSafe = (app.installColor !== 'danger');
|
||||
app.isWorking = isWorking ? "isworking" : "notFullyWorking";
|
||||
app.isHighQuality = (app.state === "high-quality") ? "isHighQuality" : "";
|
||||
app.decentQuality = (app.level > 4)?"decentQuality":"badQuality";
|
||||
|
||||
apps.push(app);
|
||||
});
|
||||
|
||||
// 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)
|
||||
var cardGrid = jQuery('.grid').isotope({
|
||||
itemSelector: '.app-card',
|
||||
layoutMode: 'fitRows',
|
||||
transitionDuration: 200
|
||||
});
|
||||
|
||||
// Sort app list
|
||||
c.arraySortById(apps);
|
||||
filterByClassAndName = function () {
|
||||
var input = jQuery("#filter-app-cards").val().toLowerCase();
|
||||
var inputMatch = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1);
|
||||
|
||||
// setup filtering of apps once the view is loaded
|
||||
function setupFilterEvents () {
|
||||
// Uses plugin isotope to filter apps (we could had ordering to)
|
||||
var cardGrid = jQuery('.grid').isotope({
|
||||
itemSelector: '.app-card',
|
||||
layoutMode: 'fitRows',
|
||||
transitionDuration: 200
|
||||
});
|
||||
var filterClass = jQuery("#dropdownFilter").attr("data-filter");
|
||||
var classMatch = (filterClass === '*') ? true : jQuery(this).hasClass(filterClass);
|
||||
return inputMatch && classMatch;
|
||||
},
|
||||
|
||||
filterByClassAndName = function () {
|
||||
var input = jQuery("#filter-app-cards").val().toLowerCase();
|
||||
var inputMatch = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1);
|
||||
// Default filter is 'decent quality apps'
|
||||
cardGrid.isotope({ filter: '.decentQuality' });
|
||||
|
||||
var filterClass = jQuery("#dropdownFilter").attr("data-filter");
|
||||
var classMatch = (filterClass === '*') ? true : jQuery(this).hasClass(filterClass);
|
||||
return inputMatch && classMatch;
|
||||
},
|
||||
jQuery('.dropdownFilter').on('click', function() {
|
||||
// change dropdown label
|
||||
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 });
|
||||
});
|
||||
|
||||
// Default filter is 'decent quality apps'
|
||||
cardGrid.isotope({ filter: '.decentQuality' });
|
||||
jQuery("#filter-app-cards").on("keyup", function() {
|
||||
cardGrid.isotope({ filter: filterByClassAndName });
|
||||
});
|
||||
};
|
||||
|
||||
jQuery('.dropdownFilter').on('click', function() {
|
||||
// change dropdown label
|
||||
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 });
|
||||
});
|
||||
// render
|
||||
c.view('app/app_catalog', {apps: apps}, setupFilterEvents);
|
||||
|
||||
jQuery("#filter-app-cards").on("keyup", function() {
|
||||
cardGrid.isotope({ filter: filterByClassAndName });
|
||||
});
|
||||
};
|
||||
|
||||
// render
|
||||
c.view('app/app_list_install', {apps: apps}, setupFilterEvents);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Get app information
|
||||
app.get('#/apps/:app', function (c) {
|
||||
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(data) {
|
||||
c.api('GET', '/apps/'+c.params['app']+'?full', {}, function(data) {
|
||||
c.api('GET', '/users/permissions', {}, function(data_permissions) {
|
||||
|
||||
// Permissions
|
||||
|
@ -506,9 +503,9 @@
|
|||
|
||||
// App installation form
|
||||
app.get('#/apps/install/:app', function (c) {
|
||||
c.api('GET', '/apps?raw', {}, function(data) {
|
||||
c.api('GET', '/appscatalog?full', {}, function(data) {
|
||||
var app_name = c.params["app"];
|
||||
var app_infos = data[app_name];
|
||||
var app_infos = data["apps"][app_name];
|
||||
if (app_infos['state'] === "validated")
|
||||
{
|
||||
app_infos['state'] = "official";
|
||||
|
@ -535,7 +532,7 @@
|
|||
{
|
||||
c.appInstallForm(
|
||||
c.params['app'],
|
||||
data[c.params['app']].manifest,
|
||||
app_infos.manifest,
|
||||
c.params
|
||||
);
|
||||
}
|
||||
|
@ -622,7 +619,7 @@
|
|||
|
||||
// Get app change label page
|
||||
app.get('#/apps/:app/changelabel', function (c) {
|
||||
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(app_data) {
|
||||
c.api('GET', '/apps/'+c.params['app']+'?full', {}, function(app_data) {
|
||||
data = {
|
||||
id: c.params['app'],
|
||||
label: app_data.settings.label,
|
||||
|
@ -641,7 +638,7 @@
|
|||
|
||||
// Get app change URL page
|
||||
app.get('#/apps/:app/changeurl', function (c) {
|
||||
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(app_data) {
|
||||
c.api('GET', '/apps/'+c.params['app']+'?full', {}, function(app_data) {
|
||||
c.api('GET', '/domains', {}, function(domain_data) {
|
||||
|
||||
// Display a list of available domains
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
{{#apps}}
|
||||
<div class="app-card panel panel-default {{status}} {{state}} {{isWorking}} {{isHighQuality}} {{decentQuality}} {{level}}-level">
|
||||
<div class="panel-body">
|
||||
<h2 class="app-title">{{name}}</h2>
|
||||
<h2 class="app-title">{{manifest.name}}</h2>
|
||||
<div class="category">
|
||||
<span class="label label-{{stateColor}} label-as-badge app-state" title="{{t (concat 'app_state_' state '_explanation') }}">{{t (concat 'app_state_' state) }}</span>
|
||||
<a target="_BLANK" href="https://yunohost.org/#/packaging_apps_levels"><span class="label label-{{levelColor}} label-as-badge app-level" title="{{t 'app_level'}}">{{t 'level'}} {{levelFormatted}}</span></a>
|
||||
<span class="label label-{{maintainedColor}} label-as-badge maintained-status" title="{{t (concat maintained '_details') }}"> {{t maintained}}</span>
|
||||
</div>
|
||||
<div class="app-card-desc">{{description}}</div>
|
||||
<div class="app-card-desc">{{manifest.description}}</div>
|
||||
</div>
|
||||
<div class="app-card-date-maintainer">
|
||||
<i class="fa-refresh"></i> {{formatDate updateDate day="numeric" month="long" year="numeric"}} -
|
||||
|
@ -48,7 +48,7 @@
|
|||
<i class="fa-book"></i> Readme
|
||||
</a>
|
||||
{{#installable}}
|
||||
<a href="#/apps/install/{{id}}" type="button" role="button" class="btn btn-{{installColor}} col-xs-4 active">
|
||||
<a href="#/apps/install/{{manifest.id}}" type="button" role="button" class="btn btn-{{installColor}} col-xs-4 active">
|
||||
<i class="fa-plus"></i> {{t 'install'}}{{^isSafe}} <i class="fa-warning"></i>{{/isSafe}}
|
||||
</a>
|
||||
{{/installable}}
|
|
@ -22,7 +22,7 @@
|
|||
<dt>{{t 'version'}}</dt>
|
||||
<dd>{{version}}</dd>
|
||||
<dt>{{t 'multi_instance'}}</dt>
|
||||
<dd>{{manifest.multi_instance}}</dd>
|
||||
<dd>{{supports_multi_instance}}</dd>
|
||||
<dt>{{t 'install_time'}}</dt>
|
||||
<dd>{{formatTime install_time day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>
|
||||
{{#if settings.domain}}
|
||||
|
@ -64,7 +64,7 @@
|
|||
<hr>
|
||||
<div class="container">
|
||||
<p>{{t 'app_info_changeurl_desc' settings.domain}}</p>
|
||||
{{#if change_url}}
|
||||
{{#if supports_change_url}}
|
||||
<a href="#/apps/{{settings.id}}/changeurl" role="button" class="btn btn-info slide">
|
||||
<span class="fa-exchange"></span> {{t 'app_change_url'}}
|
||||
</a>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<dt>{{t 'id'}}</dt>
|
||||
<dd>{{id}}</dd>
|
||||
<dt>{{t 'description'}}</dt>
|
||||
<dd>{{description}}</dd>
|
||||
<dd>{{manifest.description}}</dd>
|
||||
{{#displayLicense}}
|
||||
<dt>{{t 'license'}}</dt>
|
||||
<dd>{{manifest.license}}</dd>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
</div>
|
||||
|
||||
<div class="actions-group">
|
||||
<a role="button" href="#/apps/install" class="btn btn-success slide">
|
||||
<a role="button" href="#/apps/catalog" class="btn btn-success slide">
|
||||
<span class="fa-plus"></span> {{t 'install'}}
|
||||
</a>
|
||||
</div>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<a href="#/apps/{{id}}" class="list-group-item slide" title="{{t 'infos'}}">
|
||||
<span class="fa-chevron-right pull-right"></span>
|
||||
<h2 class="list-group-item-heading">
|
||||
{{label}} <small>{{name}}</small>
|
||||
{{settings.label}} <small>{{name}}</small>
|
||||
</h2>
|
||||
<p class="list-group-item-text">{{description}}</p>
|
||||
</a>
|
||||
|
|
Loading…
Reference in a new issue