login.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. Ext.ns("fpWeb");
  2. fpWeb.LoginForm = Ext.extend (Ext.Window, {
  3. /* Control references */
  4. blogin : null,
  5. eusername : null,
  6. epassword : null,
  7. plock : null,
  8. fform : null,
  9. /* Callbacks */
  10. OnLogin : function (Provider,Response) {
  11. if (!Ext.isEmpty(Response.error)) {
  12. Ext.Msg.show({
  13. title : 'Login failed',
  14. msg : 'An error occurred during login: '+Response.error.message+'. Please try again.',
  15. icon : Ext.Msg.ERROR,
  16. buttons : Ext.Msg.OK
  17. });
  18. } else if (Response.result > 0) {
  19. // here code to switch to data editing
  20. window.location='users.html';
  21. /*
  22. Ext.Msg.show({
  23. title : 'Login OK',
  24. msg : 'Your username/pasword was accepted. We will now proceed to the editing form',
  25. icon : Ext.Msg.ERROR,
  26. buttons : Ext.Msg.OK
  27. });
  28. */
  29. } else {
  30. Ext.Msg.show({
  31. title : 'Login failed',
  32. msg : 'Your username/pasword is incorrect. Please try again.',
  33. icon : Ext.Msg.ERROR,
  34. buttons : Ext.Msg.OK
  35. });
  36. }
  37. },
  38. loginbuttonclick : function (sender) {
  39. SessionManagement.Login(this.eusername.getValue(), this.epassword.getValue(),this.OnLogin.createDelegate(this));
  40. },
  41. focususer : function () {
  42. this.eusername.focus();
  43. },
  44. /* Build the actual form */
  45. constructor : function (config) {
  46. this.eusername = new Ext.form.TextField({
  47. name:"user",
  48. fieldLabel:"Login",
  49. inputType:"text"
  50. });
  51. this.epassword = new Ext.form.TextField({
  52. name:"pass",
  53. fieldLabel:"Password",
  54. inputType:"password"
  55. });
  56. this.blogin = new Ext.Button({
  57. text:"Login",
  58. handler : this.loginbuttonclick,
  59. scope : this
  60. });
  61. this.fform = new Ext.form.FormPanel({
  62. width: 350,
  63. labelWidth:150,
  64. border:false,
  65. xtype: "form",
  66. buttonAlign: "right",
  67. bodyStyle: "padding: 10px 15px",
  68. defaultType: "textfield",
  69. defaults: {width: 150},
  70. items: [this.eusername,this.epassword],
  71. buttons:[this.blogin],
  72. keys: {key: Ext.EventObject.ENTER,
  73. handler: function(){
  74. this.blogin.focus();
  75. },
  76. scope: this
  77. }
  78. });
  79. this.plock = new Ext.Panel({
  80. border:false,
  81. html:"<img src='login.png' width=114 height=128/>",
  82. width:114,
  83. height:128
  84. });
  85. Ext.apply(config, {
  86. title: "Login",
  87. width: 500,
  88. height: 200,
  89. plain: true,
  90. layout: "hbox",
  91. defaultButton: this.eusername,
  92. layoutConfig: {
  93. align : "middle",
  94. pack: "center"
  95. },
  96. closable: false,
  97. listeners: {
  98. 'show' : { fn: this.focususer.createDelegate(this) }
  99. },
  100. items: [ this.fform, this.plock ]
  101. });
  102. fpWeb.LoginForm.superclass.constructor.call(this,config);
  103. } /* constructor*/
  104. });