[imp] lot of improvements to header & about page

bzr revid: nicolas.vanhoren@openerp.com-20110906095054-qjlpmyd83spjm79b
This commit is contained in:
niv-openerp 2011-09-06 11:50:54 +02:00
commit f7544bb989
9 changed files with 142 additions and 38 deletions

View File

@ -11,6 +11,7 @@ import simplejson
import textwrap import textwrap
import xmlrpclib import xmlrpclib
import time import time
import webrelease
from xml.etree import ElementTree from xml.etree import ElementTree
from cStringIO import StringIO from cStringIO import StringIO
@ -100,9 +101,6 @@ home_template = textwrap.dedent("""<!DOCTYPE html>
<title>OpenERP</title> <title>OpenERP</title>
<link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/> <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
%(css)s %(css)s
<!--[if lte IE 7]>
<link rel="stylesheet" href="/web/static/src/css/web-ie7.css" type="text/css"/>
<![endif]-->
%(javascript)s %(javascript)s
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
@ -196,6 +194,12 @@ class WebClient(openerpweb.Controller):
return {"modules": transs, return {"modules": transs,
"lang_parameters": lang_obj} "lang_parameters": lang_obj}
@openerpweb.jsonrequest
def version_info(self, req):
return {
"version": webrelease.version
}
class Database(openerpweb.Controller): class Database(openerpweb.Controller):
_cp_path = "/web/database" _cp_path = "/web/database"
@ -703,6 +707,12 @@ class DataSet(openerpweb.Controller):
args[domain_id] = d args[domain_id] = d
if context_id and len(args) - 1 >= context_id: if context_id and len(args) - 1 >= context_id:
args[context_id] = c args[context_id] = c
for i in xrange(len(args)):
if isinstance(args[i], web.common.nonliterals.BaseContext):
args[i] = req.session.eval_context(args[i])
if isinstance(args[i], web.common.nonliterals.BaseDomain):
args[i] = req.session.eval_domain(args[i])
return getattr(req.session.model(model), method)(*args) return getattr(req.session.model(model), method)(*args)

View File

@ -1,4 +0,0 @@
.openerp .menu span {
min-width: 0;
}

View File

@ -409,7 +409,7 @@ label.error {
float: left; float: left;
font-size: 100%; font-size: 100%;
margin: 0; margin: 0;
padding: 4px 0; padding: 4px 10px;
text-shadow: 0 1px 0 #111111; text-shadow: 0 1px 0 #111111;
} }
.openerp .header_title small { .openerp .header_title small {
@ -1244,7 +1244,7 @@ label.error {
position: absolute; position: absolute;
margin: 0; margin: 0;
padding: 6px 5px; padding: 6px 15px;
top: 37px; top: 37px;
left: 197px; left: 197px;
right: 0; right: 0;

View File

@ -438,9 +438,9 @@ openerp.web.Login = openerp.web.Widget.extend({
if (this.has_local_storage && this.remember_creditentials) { if (this.has_local_storage && this.remember_creditentials) {
this.selected_db = localStorage.getItem('last_db_login_success'); this.selected_db = localStorage.getItem('last_db_login_success');
this.selected_login = localStorage.getItem('last_login_login_success'); this.selected_login = localStorage.getItem('last_login_login_success');
} if (jQuery.deparam(jQuery.param.querystring()).debug != undefined) {
if (jQuery.deparam(jQuery.param.querystring()).debug != undefined) { this.selected_password = localStorage.getItem('last_password_login_success');
this.selected_password = this.selected_password || "a"; }
} }
}, },
start: function() { start: function() {
@ -454,7 +454,7 @@ openerp.web.Login = openerp.web.Widget.extend({
}, },
display: function() { display: function() {
var self = this; var self = this;
this.$element.html(QWeb.render("Login", this)); this.$element.html(QWeb.render("Login", this));
this.database = new openerp.web.Database( this.database = new openerp.web.Database(
this, "oe_database", "oe_db_options"); this, "oe_database", "oe_db_options");
@ -495,9 +495,13 @@ openerp.web.Login = openerp.web.Widget.extend({
if(self.remember_creditentials) { if(self.remember_creditentials) {
localStorage.setItem('last_db_login_success', db); localStorage.setItem('last_db_login_success', db);
localStorage.setItem('last_login_login_success', login); localStorage.setItem('last_login_login_success', login);
if (jQuery.deparam(jQuery.param.querystring()).debug != undefined) {
localStorage.setItem('last_password_login_success', password);
}
} else { } else {
localStorage.setItem('last_db_login_success', ''); localStorage.setItem('last_db_login_success', '');
localStorage.setItem('last_login_login_success', ''); localStorage.setItem('last_login_login_success', '');
localStorage.setItem('last_password_login_success', '');
} }
} }
self.on_login_valid(); self.on_login_valid();
@ -514,7 +518,7 @@ openerp.web.Login = openerp.web.Widget.extend({
this.on_login_valid.add({ this.on_login_valid.add({
position: "last", position: "last",
unique: true, unique: true,
callback: continuation callback: continuation || function() {}
}); });
}, },
on_logout: function() { on_logout: function() {
@ -534,11 +538,24 @@ openerp.web.Header = openerp.web.Widget.extend({
this._super(); this._super();
}, },
do_update: function () { do_update: function () {
this.$content = $(QWeb.render("Header-content", {widget: this})); var self = this;
this.$content.appendTo(this.$element); var func = new openerp.web.Model(self.session, "res.users").get_func("read");
this.$element.find(".logout").click(this.on_logout); func(self.session.uid, ["name", "company_id"]).then(function(res) {
this.$element.find("a.preferences").click(this.on_preferences); self.$content = $(QWeb.render("Header-content", {widget: self, user: res}));
return this.shortcut_load(); self.$content.appendTo(self.$element);
self.$element.find(".logout").click(self.on_logout);
self.$element.find("a.preferences").click(self.on_preferences);
self.$element.find(".about").click(self.on_about);
self.shortcut_load();
});
},
on_about: function() {
var self = this;
self.rpc("/web/webclient/version_info", {}).then(function(res) {
var $help = $(QWeb.render("About-Page", {version_info: res}));
$help.dialog({autoOpen: true,
modal: true, width: 960, title: "About"});
});
}, },
do_reset: function() { do_reset: function() {
this.$content.remove(); this.$content.remove();
@ -676,7 +693,7 @@ openerp.web.Header = openerp.web.Widget.extend({
}); });
} }
}); });
}, },
display_error: function (error) { display_error: function (error) {
return $('<div>').dialog({ return $('<div>').dialog({
modal: true, modal: true,

View File

@ -346,7 +346,6 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web
this.context = {}; this.context = {};
this.shortcuts = []; this.shortcuts = [];
this.active_id = null; this.active_id = null;
this.session = this;
}, },
start: function() { start: function() {
this.session_restore(); this.session_restore();
@ -471,9 +470,8 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web
self.user_context = result.context; self.user_context = result.context;
self.session_save(); self.session_save();
self.on_session_valid(); self.on_session_valid();
if (success_callback) return true;
success_callback(); }).then(success_callback);
});
}, },
session_logout: function() { session_logout: function() {
this.uid = false; this.uid = false;
@ -489,7 +487,10 @@ openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web
this.user_context = this.get_cookie("user_context"); this.user_context = this.get_cookie("user_context");
// we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login // we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login
// then call on_session_valid // then call on_session_valid
this.on_session_valid(); if (this.uid)
this.on_session_valid();
else
this.on_session_invalid();
}, },
/** /**
* Saves the session id and uid locally * Saves the session id and uid locally

View File

@ -737,6 +737,50 @@ openerp.web.ReadOnlyDataSetSearch = openerp.web.DataSetSearch.extend({
on_unlink: function(ids) {} on_unlink: function(ids) {}
}); });
openerp.web.Model = openerp.web.SessionAware.extend({
init: function(session, model_name) {
this._super(session);
this.model_name = model_name;
},
get_func: function(method_name) {
var self = this;
return function() {
if (method_name == "search_read")
return self._search_read.apply(self, arguments);
return self._call(method_name, _.toArray(arguments));
};
},
_call: function (method, args) {
return this.rpc('/web/dataset/call', {
model: this.model_name,
method: method,
args: args
}).pipe(function(result) {
if (method == "read" && result instanceof Array && result.length > 0 && result[0]["id"]) {
var index = {};
_.each(_.range(result.length), function(i) {
index[result[i]["id"]] = result[i];
})
result = _.map(args[0], function(x) {return index[x];});
}
return result;
});
},
_search_read: function(domain, fields, offset, limit, order, context) {
return this.rpc('/web/dataset/search_read', {
model: this.model_name,
fields: fields,
offset: offset,
limit: limit,
domain: domain,
sort: order,
context: context
}).pipe(function(result) {
return result.records;
});;
}
});
openerp.web.CompoundContext = openerp.web.Class.extend({ openerp.web.CompoundContext = openerp.web.Class.extend({
init: function () { init: function () {
this.__ref = "compound_context"; this.__ref = "compound_context";

View File

@ -334,26 +334,30 @@
</t> </t>
<t t-name="Header-content"> <t t-name="Header-content">
<h1 class="header_title"> <h1 class="header_title">
<span class="database"><t t-esc="widget.session.db"/></span> - <t t-esc="widget.session.login"/> <br/> <t t-esc="user.company_id[1]"/> (<t t-esc="widget.session.db"/>)<br/>
<small class="username">rpc_session_id: <t t-esc="widget.session.session_id"/></small> <small class="username"><t t-esc="user.name"/></small>
</h1> </h1>
<div class="header_corner"> <div class="header_corner">
<ul class="block"> <ul class="block">
<li> <li>
<a href="#home" title="Home" class="home"><img src="/web/static/src/img/header-home.png" width="16" height="16" border="0"/></a> <a t-att-href="'/' + widget.qs" title="Home" class="home"><img src="/web/static/src/img/header-home.png" width="16" height="16" border="0"/></a>
</li> </li>
<!--
<li> <li>
<a href="#requests" title="Requests" class="requests"><img src="/web/static/src/img/header-requests.png" width="16" height="16" border="0"/><small>1</small></a> <a href="#requests" title="Requests" class="requests"><img src="/web/static/src/img/header-requests.png" width="16" height="16" border="0"/><small>1</small></a>
</li> </li>
-->
<li class="preferences"> <li class="preferences">
<a href="#preferences" title="Preferences" class="preferences"><img src="/web/static/src/img/header-preferences.png" width="16" height="16" border="0"/></a> <a href="#preferences" title="Preferences" class="preferences"><img src="/web/static/src/img/header-preferences.png" width="16" height="16" border="0"/></a>
</li> </li>
<li> <li>
<a href="#about" title="About" class="about"><img src="/web/static/src/img/header-about.png" width="16" height="16" border="0"/></a> <a href="#about" title="About" class="about"><img src="/web/static/src/img/header-about.png" width="16" height="16" border="0"/></a>
</li> </li>
<!--
<li> <li>
<a href="http://doc.openerp.com/v6.0/book?version=$version" title="Help" target="_blank" class="help"><img src="/web/static/src/img/header-help.png" width="16" height="16" border="0"/></a> <a href="http://doc.openerp.com/v6.0/book?version=$version" title="Help" target="_blank" class="help"><img src="/web/static/src/img/header-help.png" width="16" height="16" border="0"/></a>
</li> </li>
-->
</ul> </ul>
<div class="block"> <div class="block">
<a href="#logout" class="logout">LOGOUT</a> <a href="#logout" class="logout">LOGOUT</a>
@ -1354,4 +1358,34 @@
</table> </table>
</form> </form>
</t> </t>
<t t-name="About-Page">
<div>
<h1>OpenERP Web</h1>
<h3 style="padding:0 5px 5px">Version <t t-esc="version_info.version"/></h3>
<p>
Copyright © 2011-TODAY OpenERP SA. All Rights Reserved.<br />
OpenERP is a trademark of the <a target="_blank" href="http://openerp.com/" style="text-decoration: underline;">OpenERP SA Company</a>.
</p>
<p>
Licenced under the terms of <a target="_blank" href="http://www.gnu.org/licenses/agpl.html" style="text-decoration: underline;">GNU Affero General Public License</a>
</p>
<br />
<h1>About OpenERP</h1>
<p>
<a target="_blank" href="http://openerp.com/" style="text-decoration: underline;">OpenERP</a> is a free enterprise-scale software system that is designed to boost
productivity and profit through data integration. It connects, improves and
manages business processes in areas such as sales, finance, supply chain,
project management, production, services, CRM, etc...
</p>
<p>
The system is platform-independent, and can be installed on Windows, Mac OS X,
and various Linux and other Unix-based distributions. Its architecture enables
new functionality to be rapidly created, modifications to be made to a
production system and migration to a new version to be straightforward.
</p>
<p>
Depending on your needs, OpenERP is available through a web or application client.
</p>
</div>
</t>
</templates> </templates>

View File

@ -4,16 +4,7 @@ import re
import sys import sys
from setuptools import setup from setuptools import setup
name = 'openerp-web-proto' execfile('webrelease.py')
version = '6.0.1'
description = "Web Client of OpenERP, the Enterprise Management Software"
long_description = "OpenERP Web is the web client of the OpenERP, a free enterprise management software"
author = "OpenERP S.A."
author_email = "info@openerp.com"
support_email = 'support@openerp.com'
url = "http://www.openerp.com/"
download_url = ''
license = "OEPL"
version_dash_incompatible = False version_dash_incompatible = False
if 'bdist_rpm' in sys.argv: if 'bdist_rpm' in sys.argv:

11
webrelease.py Normal file
View File

@ -0,0 +1,11 @@
name = 'openerp-web-proto'
version = '6.1.0 alpha'
description = "Web Client of OpenERP, the Enterprise Management Software"
long_description = "OpenERP Web is the web client of the OpenERP, a free enterprise management software"
author = "OpenERP S.A."
author_email = "info@openerp.com"
support_email = 'support@openerp.com'
url = "http://www.openerp.com/"
download_url = ''
license = "OEPL"