3 Ext.Direct.addProvider({
4 'namespace': 'Gilbert.api',
5 'url': '{% url gilbert:router %}',
7 'actions': {{% for gilbert_class in gilbert.core_api.gilbert_plugin_classes.values %}
8 '{{ gilbert_class.gilbert_class_name }}': [{% for method in gilbert_class.gilbert_class_methods.values %}{
9 'name': '{{ method.gilbert_method_name }}',
10 'len': {{ method.gilbert_method_argc }}
11 },{% endfor %}],{% endfor %}
15 {% if not logged_in %}
17 Ext.onReady(function() {
18 var login_form = new Ext.FormPanel({
20 bodyStyle: 'padding: 5px 5px 0',
23 fieldLabel: 'Username',
28 fieldLabel: 'Password',
31 inputType: 'password',
37 handler: function(sender) {
38 // document.location.reload();
39 var the_form = login_form.getForm().el.dom;
40 var username = the_form[0].value;
41 var password = the_form[1].value;
42 Gilbert.api.auth.login(username, password, function(result) {
44 document.location.reload();
46 Ext.MessageBox.alert('Login failed', 'Unable to authenticate.', function() {
47 login_form.getForm().reset();
55 var login_window = new Ext.Window({
69 Ext.ns('Gilbert', 'Gilbert.ui', 'Gilbert.models', 'Gilbert.plugins');
71 {% for app_label, models in gilbert.model_registry.items %}Ext.Direct.addProvider({
72 'namespace': 'Gilbert.models.{{ app_label }}',
73 'url': '{% url gilbert:models app_label %}',
75 'actions': {{% for model_name, admin in models.items %}
76 '{{ model_name }}': [{% for method in admin.gilbert_class_methods.values %}{
77 'name': '{{ method.gilbert_method_name }}',
78 'len': {{ method.gilbert_method_argc }}
79 },{% endfor %}],{% endfor %}
82 {% for plugin in gilbert.plugin_registry.values %}Ext.Direct.addProvider({
83 'namespace': 'Gilbert.plugins.{{ plugin.gilbert_plugin_name }}',
84 'url': '{% url gilbert:plugins plugin.gilbert_plugin_name %}',
86 'actions': {{% for gilbert_class in plugin.gilbert_plugin_classes %}
87 '{{ gilbert_class.gilbert_class_name }}': [{% for method in gilbert_class.gilbert_class_methods.values %}{}
88 'name': '{{ method.gilbert_method_name }}',
89 'len': {{ method.gilbert_method_argc }}
90 },{% endfor %}],{% endfor %}
94 Gilbert.ui.Application = function(cfg) {
95 Ext.apply(this, cfg, {
96 title: '{{ gilbert.title }}',
100 'beforeunload': true,
102 Ext.onReady(this.initApplication, this);
105 Ext.extend(Gilbert.ui.Application, Ext.util.Observable, {
106 initApplication: function() {
108 Ext.QuickTips.init();
110 this.desktop = new Ext.Panel({
114 bodyStyle: 'background: none;',
116 var desktop = this.desktop;
118 this.toolbar = new Ext.Toolbar({
125 style: 'font-weight: bolder; font-size: larger; text-transform: uppercase;',
128 xtype: 'tbseparator',
132 var toolbar = this.toolbar;
134 this.viewport = new Ext.Viewport({
135 renderTo: Ext.getBody(),
142 var viewport = this.viewport;
144 var windows = new Ext.WindowGroup();
146 this.createWindow = function(config, cls) {
147 var win = new(cls || Ext.Window)(Ext.applyIf(config || {},
149 renderTo: desktop.el,
151 constrainHeader: true,
154 win.render(desktop.el);
157 var createWindow = this.createWindow;
160 for (var pluginNum = 0; pluginNum < this.plugins.length; pluginNum++) {
161 this.plugins[pluginNum].initWithApp(this);
166 var user = this.user;
167 toolbar.add({ xtype: 'tbfill' });
168 toolbar.add({ xtype: 'tbseparator' });
171 text: '<b>' + user + '</b>',
172 style: 'font-weight: bolder !important; font-size: smaller !important; text-transform: uppercase !important;',
175 text: 'Change password',
176 handler: function(button, event) {
177 var edit_window = createWindow({
179 title: 'Change password',
183 items: _change_password_form = new Ext.FormPanel({
185 bodyStyle: 'padding: 5px 5px 0',
188 fieldLabel: 'Current password',
189 name: 'current_password',
191 inputType: 'password',
194 fieldLabel: 'New password',
195 name: 'new_password',
197 inputType: 'password',
200 fieldLabel: 'New password (confirm)',
201 name: 'new_password_confirm',
203 inputType: 'password',
208 text: 'Change password',
209 handler: function(sender) {
210 // document.location.reload();
211 var the_form = _change_password_form.getForm().el.dom;
212 var current_password = the_form[0].value;
213 var new_password = the_form[1].value;
214 var new_password_confirm = the_form[2].value;
215 Gilbert.api.auth.passwd(current_password, new_password, new_password_confirm, function(result) {
217 Ext.MessageBox.alert('Password changed', 'Your password has been changed.');
219 Ext.MessageBox.alert('Password unchanged', 'Unable to change your password.', function() {
220 _change_password_form.getForm().reset();
229 edit_window.show(this);
234 handler: function(button, event) {
235 Gilbert.api.auth.logout(function(result) {
237 Ext.MessageBox.alert('Logout successful', 'You have been logged out.', function() {
238 document.location.reload();
241 Ext.MessageBox.alert('Logout failed', 'A bit odd, you might say.');
255 Ext.BLANK_IMAGE_URL = '{% mediaurl "gilbert/extjs/resources/images/default/s.gif" %}';
257 Ext.onReady(function(){
258 Gilbert.Application = new Gilbert.ui.Application({
259 user: '{% filter force_escape %}{% firstof user.get_full_name user.username %}{% endfilter %}',
260 plugins: [{% for plugin in gilbert.plugin_registry.values %}{% if plugin.gilbert_plugin_javascript %}
261 {{ plugin.gilbert_plugin_javascript|safe }},
262 {% endif %}{% endfor %}],