1 Ext.ns('Gilbert.lib.plugins.auth');
4 Gilbert.lib.plugins.auth.PreferencesWindow = Ext.extend(Ext.Window, {
5 constructor: function (config, application) {
6 Gilbert.lib.plugins.auth.PreferencesWindow.superclass.constructor.call(this, Ext.applyIf(config||{},{
15 Gilbert.lib.plugins.auth.Plugin = Ext.extend(Gilbert.lib.plugins.Plugin, {
17 init: function (application) {
18 Gilbert.lib.plugins.auth.Plugin.superclass.init.call(this, application);
20 var preferences_window = new Gilbert.lib.plugins.auth.PreferencesWindow({}, application);
22 Gilbert.api.plugins.auth.whoami(function (whoami) {
23 application.mainmenu.add({
29 iconCls: 'icon-user-silhouette',
30 text: '<span style="font-weight: bolder;">' + whoami + '</span>',
32 text: 'Preferences...',
33 iconCls: 'icon-switch',
34 handler: function (button, event) {
35 preferences_window.show();
38 xtype: 'menuseparator',
40 text: 'Change password',
41 iconCls: 'icon-key--pencil',
42 handler: function(button, event) {
43 Gilbert.api.plugins.auth.get_passwd_form(function(formspec) {
44 var formspec = formspec;
45 for (var item_index in formspec.items) {
46 var item = formspec.items[item_index];
48 plugins: [ Ext.ux.FieldLabeler ],
51 var change_password_window = application.create_window({
54 title: 'Change password',
55 iconCls: 'icon-key--pencil',
58 items: change_password_form = new Ext.FormPanel(Ext.applyIf({
64 bodyStyle: 'padding: 5px;',
67 text: 'Change password',
68 iconCls: 'icon-key--pencil',
69 handler: function(button, event) {
70 change_password_form.getForm().submit({
71 success: function(form, action) {
72 Ext.MessageBox.alert('Password changed', 'Your password has been changed.');
78 submit: Gilbert.api.plugins.auth.save_passwd_form,
82 change_password_window.doLayout();
83 change_password_window.show(button.el);
89 iconCls: 'icon-door-open-out',
90 handler: function(button, event) {
91 Gilbert.api.plugins.auth.logout(function(success) {
93 window.onbeforeunload = undefined;
94 document.location.reload();
96 Ext.MessageBox.alert('Log out failed', 'You have <strong>not</strong> been logged out. This could mean that your connection with the server has been severed. Please try again.');
102 application.do_layout();
109 Gilbert.on('ready', function (application) {
110 application.register_plugin('auth', new Gilbert.lib.plugins.auth.Plugin());