[enh] Allow update/upgrade for apps & packages.

This commit is contained in:
opi 2014-05-07 18:46:58 +02:00
parent 873f260459
commit abcd9afafa
3 changed files with 98 additions and 0 deletions

View file

@ -916,6 +916,7 @@ app = Sammy('#main', function (sam) {
// Available tools
data = {links: [
{name: "Change administration password", path: '#/tools/adminpw'},
{name: "System update", path: '#/tools/update'},
]};
c.view('tools/tools_list', data);
});
@ -948,6 +949,35 @@ app = Sammy('#main', function (sam) {
}
});
// System update & upgrade
sam.get('#/tools/update', function (c) {
c.api('/update', function(data) {
c.view('tools/tools_update', data);
}, 'PUT');
});
sam.get('#/tools/upgrade/:type', function (c) {
if (c.params['type'] !== 'apps' && c.params['type'] !== 'packages') {
c.flash('fail', 'Error');
store.clear('slide');
c.redirect('#/tools/update');
}
if (confirm('Are you sure you want update every '+c.params['type']+' ?')) {
params = {
'ignore_packages': (c.params['type'] == 'packages') ? false : true,
'ignore_apps': (c.params['type'] == 'apps') ? false : true,
}
c.api('/upgrade', function(data) {
// 'log' is a reserved name, maybe in handlebars
data.logs = data.log;
c.view('tools/tools_upgrade', data);
}, 'PUT', params);
} else {
store.clear('slide');
c.redirect('#/tools/update');
}
});
/**
* Backup

View file

@ -0,0 +1,50 @@
<div class="pull-left">
<a href="#/tools" class="btn btn-default slide back">
<span class="fa-chevron-left"></span> Tools
</a>
</div>
<div class="clearfix"></div>
<h1 class="view-title">System update</h1>
<div class="br"></div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"> Packages</h2>
</div>
<div class="panel-body list-group">
{{#if packages}}
{{#packages}}
<div class="list-group-item">
<h3 class="list-group-item-heading">{{name}} <small>{{fullname}}</small></h3>
<p class="list-group-item-text">{{changelog}}</p>
</div>
{{/packages}}
<div class="br"></div>
<a href="#/tools/upgrade/packages" class="btn btn-default">Upgrade packages</a>
{{else}}
There is no packages to upgrade.
{{/if}}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"> Apps</h2>
</div>
<div class="panel-body list-group">
{{#if apps}}
{{#apps}}
<div class="list-group-item">
<h3 class="list-group-item-heading">{{label}} <small>{{id}}</small></h3>
</div>
{{/apps}}
<div class="br"></div>
<a href="#/tools/upgrade/apps" class="btn btn-success">Upgrade apps</a>
{{else}}
There is no apps to upgrade.
{{/if}}
</div>
</div>

View file

@ -0,0 +1,18 @@
<div class="pull-left">
<a href="#/tools/update" class="btn btn-default slide back">
<span class="fa-chevron-left"></span> System update
</a>
</div>
<div class="clearfix"></div>
<h1 class="view-title">System upgrade</h1>
<div class="br"></div>
{{#if logs}}
<pre class="upgrade-log log">
{{#logs}}
{{.}}
{{/logs}}
</pre>
{{else}}
No log.
{{/if}}