Check server version

issue11421
review425561003
This commit is contained in:
Hodei Navarro
2022-09-18 12:24:04 +02:00
parent c18b8d40e2
commit b2a71f157b
4 changed files with 71 additions and 16 deletions
+2
View File
@@ -1,3 +1,5 @@
* Check server version
Version 6.4.0 - 2022-05-02
* Bug fixes (see mercurial logs for details)
* Support notification message
+40 -15
View File
@@ -615,15 +615,34 @@ var Sao = {
Sao.login = function() {
Sao.set_title();
Sao.i18n.setlang().always(function() {
Sao.Session.get_credentials()
.then(function(session) {
Sao.Session.current_session = session;
return session.reload_context();
}).then(Sao.get_preferences).then(function(preferences) {
Sao.menu(preferences);
Sao.user_menu(preferences);
Sao.open_url();
Sao.Bus.listen();
Sao.Session.server_version()
.then(function(version) {
if (JSON.stringify(version.split('.').slice(0, 2)) !==
JSON.stringify(Sao.__version__.split('.').slice(0, 2)))
{
Sao.common.warning.run(
Sao.i18n.gettext(
"Incompatible version of the server."),
Sao.i18n.gettext("Version mismatch"));
} else {
Sao.Session.get_credentials()
.then(function(session) {
Sao.Session.current_session = session;
return session.reload_context();
})
.then(Sao.get_preferences)
.then(function(preferences) {
Sao.menu(preferences);
Sao.user_menu(preferences);
Sao.open_url();
Sao.Bus.listen();
});
}
}, function() {
Sao.common.warning.run(
Sao.i18n.gettext(
"Could not connect to the server."),
Sao.i18n.gettext("Connection error"));
});
});
};
@@ -887,7 +906,8 @@ var Sao = {
});
Sao.Dialog = Sao.class_(Object, {
init: function(title, class_, size='sm', keyboard=true) {
init: function(
title, class_, size='sm', keyboard=true, small=null) {
this.modal = jQuery('<div/>', {
'class': class_ + ' modal fade',
'role': 'dialog',
@@ -903,7 +923,7 @@ var Sao = {
'class': 'modal-header'
}).appendTo(this.content);
if (title) {
this.add_title(title);
this.add_title(title, small);
}
this.body = jQuery('<div/>', {
'class': 'modal-body'
@@ -922,11 +942,15 @@ var Sao = {
}
});
},
add_title: function(title) {
this.header.append(jQuery('<h4/>', {
add_title: function(title, small=null) {
var titleElement = jQuery('<h4/>', {
'class': 'modal-title',
'title': title,
}).text(Sao.common.ellipsize(title, 120)));
}).text(Sao.common.ellipsize(title, 120) + (small? ' ' : ''));
if (small) {
titleElement.append(jQuery('<small/>').text(small));
}
this.header.append(titleElement);
}
});
@@ -1161,7 +1185,8 @@ var Sao = {
function help_dialog() {
var dialog = new Sao.Dialog(
Sao.i18n.gettext("Help"), 'help-dialog', 'm');
Sao.i18n.gettext("Help"), 'help-dialog', 'md', true,
Sao.__version__);
jQuery('<button>', {
'class': 'close',
'data-dismiss': 'modal',
+6
View File
@@ -99,6 +99,12 @@ html[theme="default"] {
.modal-header {
background-color: @brand-primary;
color: #fff;
.modal-title {
small {
color: @gray-lighter;
}
}
}
#tablist {
+23 -1
View File
@@ -175,8 +175,30 @@
}
});
Sao.Session.server_version = function() {
var timeoutID = Sao.common.processing.show();
return jQuery.ajax({
'contentType': 'application/json',
'data': JSON.stringify({
'id': 0,
'method': 'common.server.version',
'params': []
}),
'dataType': 'json',
'url': '/',
'type': 'post',
'complete': [function() {
Sao.common.processing.hide(timeoutID);
}]
}).then(function(data) {
return data.result;
});
};
Sao.Session.login_dialog = function() {
var dialog = new Sao.Dialog(Sao.i18n.gettext('Login'), 'lg');
var dialog = new Sao.Dialog(
Sao.i18n.gettext("Login"), 'login-dialog', 'md', true,
Sao.__version__);
dialog.database_select = jQuery('<select/>', {
'class': 'form-control',
'id': 'database',