mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
events file login/logout event and check connected home
This commit is contained in:
parent
d9f4904cc6
commit
ea2bdd41b8
4 changed files with 27 additions and 4 deletions
|
@ -50,6 +50,7 @@ gulp.task('js', function() {
|
|||
'js/yunohost/main.js',
|
||||
'js/yunohost/helpers.js',
|
||||
'js/yunohost/filters.js',
|
||||
'js/yunohost/events.js',
|
||||
'js/yunohost/controllers/*.js',
|
||||
])
|
||||
.pipe(gulpif(isProduction, uglify()))
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
};
|
||||
c.api('/login', function(data) {
|
||||
store.set('connected', true);
|
||||
|
||||
c.trigger('login');
|
||||
$('#masthead .logout-btn').fadeIn();
|
||||
c.flash('success', y18n.t('logged_in'));
|
||||
if (store.get('path')) {
|
||||
|
@ -160,6 +160,7 @@
|
|||
store.clear('url');
|
||||
store.clear('connected');
|
||||
store.set('path', '#/');
|
||||
c.trigger('logout');
|
||||
c.flash('success', y18n.t('logged_out'));
|
||||
c.redirect('#/login');
|
||||
}, 'GET', {}, false);
|
||||
|
|
19
src/js/yunohost/events.js
Normal file
19
src/js/yunohost/events.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
(function() {
|
||||
// Get application context
|
||||
var app = Sammy.apps['#main'];
|
||||
var store = app.store;
|
||||
|
||||
/**
|
||||
* Events
|
||||
*
|
||||
*/
|
||||
app.bind('login', function(e, data) {
|
||||
this.api('/version', function(versions) {
|
||||
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost]));
|
||||
});
|
||||
});
|
||||
|
||||
app.bind('logout', function(e, data) {
|
||||
$('#yunohost-version').empty();
|
||||
});
|
||||
})();
|
|
@ -71,9 +71,11 @@
|
|||
sam.store.set('url', window.location.hostname + '/yunohost/api');
|
||||
|
||||
// Get YunoHost version
|
||||
this.api('/version', function(versions) {
|
||||
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost]));
|
||||
});
|
||||
if (sam.store.get('connected')) {
|
||||
this.api('/version', function(versions) {
|
||||
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost]));
|
||||
});
|
||||
}
|
||||
|
||||
// Flash messages
|
||||
var flashMessage = $('#flashMessage');
|
||||
|
|
Loading…
Reference in a new issue