[icinga-checkins] icinga.org: icinga-web/cdoebler/default: * Finished AJAX login
git at icinga.org
git at icinga.org
Mon Oct 19 16:11:22 CEST 2009
Module: icinga-web
Branch: cdoebler/default
Commit: ef752672fb9c941362bf431b91f7e5c81b95f630
URL: https://git.icinga.org/?p=icinga-web.git;a=commit;h=ef752672fb9c941362bf431b91f7e5c81b95f630
Author: Marius Hein <marius.hein at netways.de>
Date: Thu Oct 8 13:28:43 2009 +0200
* Finished AJAX login
* Application starts with login (all actions are secured)
---
app/modules/AppKit/templates/AjaxLoginSuccess.php | 98 +++++++++++++++----
.../Cronks/templates/System/CronkPortalSuccess.php | 1 +
.../Web/templates/Icinga/PortalViewSuccess.php | 19 +---
lib/appkit/util/AppKitRandomUtil.class.php | 4 +-
pub/styles/Icinga.css | 8 ++
5 files changed, 94 insertions(+), 36 deletions(-)
diff --git a/app/modules/AppKit/templates/AjaxLoginSuccess.php b/app/modules/AppKit/templates/AjaxLoginSuccess.php
index c6914c0..07a505f 100644
--- a/app/modules/AppKit/templates/AjaxLoginSuccess.php
+++ b/app/modules/AppKit/templates/AjaxLoginSuccess.php
@@ -1,7 +1,8 @@
<?php
- $htmlid = AppKitRandomUtil::genSimpleId(10);
+ $htmlid = AppKitRandomUtil::genSimpleId(10, 'login-box-');
+ $containerid = AppKitHtmlHelper::concatHtmlId($htmlid, 'container');
?>
-<div style="width:370px; margin: 150px auto 150px auto;">
+<div style="width:400px; margin: 150px auto 150px auto; padding: 20px;" id="<?php echo $containerid; ?>">
<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
<h3 style="margin-bottom:5px;"><?php echo $tm->_('Login'); ?></h3>
@@ -14,6 +15,7 @@
var bAuthenticated = false;
var sId = '<?php echo $htmlid ?>';
+ var sContainerId = '<?php echo $containerid; ?>';
<?php if ($us->isAuthenticated() == true) { ?>
bAuthenticated = true;
@@ -23,6 +25,17 @@
var pub;
+ var oButton = new Ext.Button({
+ text: '<?php echo $tm->_("Try"); ?>',
+ id: 'login_button',
+ handler: function(b, e) {
+ pub.disableForm();
+ pub.doSubmit();
+ }
+ });
+
+ var oContainer = Ext.get(sContainerId);
+
var oFormPanel = new Ext.form.FormPanel({
labelWidth: 100,
defaultType: 'textfield',
@@ -47,31 +60,25 @@
listeners: {
afterrender: function(p) {
- pub.resetForm();
+ pub.resetForm(true);
}
},
keys: [{
key: Ext.EventObject.ENTER,
scope: pub,
+ stopEvent: true,
fn: function() {
pub.doSubmit()
}
}],
- buttons: [{
- text: '<?php echo $tm->_("Try"); ?>',
- id: 'login_button',
- handler: function(b, e) {
- pub.doSubmit();
- }
- }]
+ buttons: [oButton]
});
var oFormAction = new Ext.form.Action.Submit(oFormPanel.getForm(), {
clientValidation: true,
url: '<?php echo $ro->gen("appkit.login.provider"); ?>',
- waitMsg: '<?php echo $tm->_("Verifying credentials ..."); ?>',
params: {
dologin: 1
@@ -85,20 +92,48 @@
};
AppKit.Ext.notifyMessage('<?php echo $tm->_("Login failed"); ?>', '<?php echo $tm->_("Please verify your input and try again!"); ?>', null, c);
-
- pub.resetForm();
-
}
- f.getEl().highlight("f39a00", {
+ /* oContainer.highlight("cc0000", {
attr: 'background-color',
- easing: 'easeIn',
- duration: 1
- });
+ easing: 'easeOutStrong',
+ duration: 2
+ }); */
+
+ if (oContainer) {
+ var ox = oContainer.getLeft();
+ oContainer.sequenceFx();
+
+ for(var i=0; i<1; i++) {
+ oContainer.shift({x: oContainer.getLeft()-20, duration: .02, easing: 'bounceBoth'})
+ .shift({x: oContainer.getLeft()+40, duration: .02 , easing: 'bounceBoth'})
+ .shift({x: oContainer.getLeft()-20, duration: .02, easing: 'bounceBoth'})
+ .pause(.03);
+ }
+
+ oContainer.shift({ x: ox, duration: .02, easing: 'bounceBoth', callback: pub.enableForm, scope: pub });
+ }
+
+ pub.resetForm();
+
},
success: function(f, a) {
- AppKit.Ext.changeLocation('<?php echo $ro->gen("index_page"); ?>');
+ pub.disableForm(true);
+
+ var p = new Ext.Panel({
+ style: 'margin-top: 20px;',
+ bodyCssClass: 'x-icinga-simplebox-green',
+ html: '<?php echo $tm->_("Successfully logged in. You should be redirected immediately. If not please <a href=\"%s\">click here to change location by hand</a>.", null, null, array($ro->gen("index_page"))); ?>',
+ unstyled: true,
+ layout: 'fit',
+ forceLayout: true
+ });
+
+ oFormPanel.add(p);
+ oFormPanel.doLayout();
+
+ AppKit.Ext.changeLocation.defer(10, null, ['<?php echo $ro->gen("index_page"); ?>']);
}
});
@@ -120,9 +155,30 @@
this.getForm().doAction(this.getAction());
},
- resetForm : function() {
- this.getForm().reset();
+ resetForm : function(full) {
+ if (full != undefined) {
+ this.getForm().reset();
+ }
+ else {
+ this.getForm().findField('password').setValue("");
+ }
+
this.getForm().findField('username').focus('', 10);
+ },
+
+ enableForm : function() {
+ this.getForm().findField('username').enable();
+ this.getForm().findField('password').enable();
+ oButton.enable();
+ },
+
+ disableForm : function(full) {
+ if (full != undefined) {
+ this.getForm().findField('username').disable();
+ this.getForm().findField('password').disable();
+ }
+
+ oButton.disable();
}
};
diff --git a/app/modules/Cronks/templates/System/CronkPortalSuccess.php b/app/modules/Cronks/templates/System/CronkPortalSuccess.php
index af5bc63..67577e1 100644
--- a/app/modules/Cronks/templates/System/CronkPortalSuccess.php
+++ b/app/modules/Cronks/templates/System/CronkPortalSuccess.php
@@ -228,6 +228,7 @@ container.setHeight(Ext.lib.Dom.getViewHeight()-80);
// Render the container
container.render("<?php echo $parentid; ?>");
+
// Adding the first cronk (say hello here)
if (tabPanel) {
var cHello = AppKit.Ext.CronkMgr.create({
diff --git a/app/modules/Web/templates/Icinga/PortalViewSuccess.php b/app/modules/Web/templates/Icinga/PortalViewSuccess.php
index d7502e0..1444562 100644
--- a/app/modules/Web/templates/Icinga/PortalViewSuccess.php
+++ b/app/modules/Web/templates/Icinga/PortalViewSuccess.php
@@ -1,35 +1,28 @@
<script type="text/javascript">
-
/**
* This create the complete view (simply loading a cronk which is doing for us)
*/
-
+(function() {
Ext.onReady(function() {
var sPortalCronk = "crportal";
var sRenderElement = "contentArea";
- if (Ext.get('navigationLeft')) {
- Ext.get('navigationLeft').remove();
- Ext.get('contentArea').setStyle('margin-left', 0);
- }
-
if (Ext.get(sRenderElement)) {
var oCA = Ext.get(sRenderElement);
- var oPvData = {
+ oCA.getUpdater().setDefaultUrl({
url : String.format("<?php echo $ro->gen('icinga.cronks.crloader', array('cronk' => 'crportal')); ?>/{0}", sPortalCronk),
scripts : true,
params : {
'p[parentid]' : oCA.id
}
- };
-
- oCA.getUpdater().setDefaultUrl(oPvData);
+ });
oCA.getUpdater().refresh();
+
}
-});
-
+})
+})();
</script>
\ No newline at end of file
diff --git a/lib/appkit/util/AppKitRandomUtil.class.php b/lib/appkit/util/AppKitRandomUtil.class.php
index 82cd443..85f1d8f 100755
--- a/lib/appkit/util/AppKitRandomUtil.class.php
+++ b/lib/appkit/util/AppKitRandomUtil.class.php
@@ -28,7 +28,7 @@ class AppKitRandomUtil {
return $init;
}
- public static function genSimpleId($length=5) {
+ public static function genSimpleId($length=5, $prefix="") {
static $chars = null;
if ($chars === null) {
@@ -45,7 +45,7 @@ class AppKitRandomUtil {
$o .= (chr( $chars[mt_rand(0, count($chars)-1)] ));
}
- return $o;
+ return $prefix. $o;
}
}
diff --git a/pub/styles/Icinga.css b/pub/styles/Icinga.css
index 51ee2e2..359938d 100644
--- a/pub/styles/Icinga.css
+++ b/pub/styles/Icinga.css
@@ -281,4 +281,12 @@ table.icinga-attribute-table td.val {
text-decoration: underline;
}
+/** Simple box classes **/
+.x-icinga-simplebox-green {
+ padding: 10px;
+ color: #fff;
+ background-color: #00bb00;
+ border: 1px #00cc00 solid;
+}
+
/* EOF */
\ No newline at end of file
More information about the icinga-checkins
mailing list