Clean up the JS and add popup notification support for the existing "flash" notifications.
This commit is contained in:
parent
29dae7dc5a
commit
bde99b045d
|
@ -272,7 +272,7 @@ $di->setShared('user', function() use ($di) {
|
|||
if ($auth->isLoggedIn())
|
||||
return $auth->getLoggedInUser();
|
||||
else
|
||||
return new \App\Auth\AnonymousUser();
|
||||
return NULL;
|
||||
});
|
||||
|
||||
// Initialize cache.
|
||||
|
|
|
@ -42,8 +42,8 @@ class Flash
|
|||
'success' => 'success',
|
||||
'yellow' => 'warning',
|
||||
'warning' => 'warning',
|
||||
'red' => 'error',
|
||||
'error' => 'error',
|
||||
'red' => 'danger',
|
||||
'error' => 'danger',
|
||||
'info' => 'info',
|
||||
'blue' => 'info',
|
||||
'default' => '',
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Register Form
|
||||
*/
|
||||
|
||||
$di = \Phalcon\Di::getDefault();
|
||||
$config = $di->get('config');
|
||||
|
||||
$general_config = $config->general->toArray();
|
||||
|
||||
return array(
|
||||
'method' => 'post',
|
||||
'groups' => array(
|
||||
|
@ -15,11 +6,6 @@ return array(
|
|||
'account' => array(
|
||||
'legend' => 'Account Information',
|
||||
'elements' => array(
|
||||
|
||||
'name' => array('text', array(
|
||||
'label' => 'Your Name',
|
||||
'required' => true,
|
||||
)),
|
||||
|
||||
'email' => array('text', array(
|
||||
'label' => 'E-mail Address',
|
||||
|
@ -28,7 +14,7 @@ return array(
|
|||
'validators' => array('EmailAddress'),
|
||||
)),
|
||||
|
||||
'auth_password' => array('password', array(
|
||||
'password' => array('password', array(
|
||||
'label' => 'Password',
|
||||
'required' => true,
|
||||
)),
|
||||
|
@ -40,7 +26,7 @@ return array(
|
|||
'elements' => array(
|
||||
'submit' => array('submit', array(
|
||||
'type' => 'submit',
|
||||
'label' => 'Create Account and Log In',
|
||||
'label' => 'Create Account',
|
||||
'helper' => 'formButton',
|
||||
'class' => 'ui-button',
|
||||
)),
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
namespace Modules\Frontend\Controllers;
|
||||
|
||||
use Entity\Settings;
|
||||
use Entity\User;
|
||||
|
||||
class SetupController extends BaseController
|
||||
{
|
||||
|
@ -14,21 +13,13 @@ class SetupController extends BaseController
|
|||
return NULL;
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// Check for user accounts.
|
||||
$num_users = $this->em->createQuery('SELECT COUNT(u.id) FROM Entity\User u')
|
||||
->getSingleScalarResult();
|
||||
|
||||
if ($num_users == 0)
|
||||
return $this->redirectFromHere(['action' => 'register']);
|
||||
|
||||
// New station setup form.
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Step 1:
|
||||
* Create Super Administrator Account
|
||||
*/
|
||||
public function registerAction()
|
||||
{
|
||||
// Check for user accounts.
|
||||
$num_users = $this->em->createQuery('SELECT COUNT(u.id) FROM Entity\User u')
|
||||
->getSingleScalarResult();
|
||||
|
||||
|
@ -44,30 +35,53 @@ class SetupController extends BaseController
|
|||
{
|
||||
$data = $form->getValues();
|
||||
|
||||
$existing_user = User::getRepository()->findOneBy(array('email' => $data['email']));
|
||||
// Create actions and roles supporting Super Admninistrator.
|
||||
$action = new \Entity\Action;
|
||||
$action->name = 'administer all';
|
||||
$this->em->persist($action);
|
||||
|
||||
if ($existing_user instanceof User)
|
||||
{
|
||||
$this->alert('A user with that e-mail address already exists!', 'red');
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_user = new User;
|
||||
$new_user->fromArray($data);
|
||||
$new_user->save();
|
||||
$role = new \Entity\Role;
|
||||
$role->name = 'Super Administrator';
|
||||
$role->actions->add($action);
|
||||
$this->em->persist($role);
|
||||
|
||||
$login_credentials = array(
|
||||
'username' => $data['email'],
|
||||
'password' => $data['auth_password'],
|
||||
);
|
||||
$login_success = $this->auth->authenticate($login_credentials);
|
||||
// Create user account.
|
||||
$user = new \Entity\User;
|
||||
$user->email = $data['email'];
|
||||
$user->setAuthPassword($data['password']);
|
||||
$user->roles->add($role);
|
||||
$this->em->persist($user);
|
||||
|
||||
$this->alert('<b>Your account has been successfully created.</b><br>You have been automatically logged in to your new account.', 'green');
|
||||
// Write to DB.
|
||||
$this->em->flush();
|
||||
|
||||
$default_url = \App\Url::route(array('module' => 'default'));
|
||||
$this->redirectToStoredReferrer('login', $default_url);
|
||||
return;
|
||||
}
|
||||
$login_credentials = array(
|
||||
'username' => $data['email'],
|
||||
'password' => $data['auth_password'],
|
||||
);
|
||||
$login_success = $this->auth->authenticate($login_credentials);
|
||||
|
||||
return $this->redirectFromHere(['action' => 'index']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Step 2:
|
||||
* Create Station and Parse Metadata
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
// Check for user accounts.
|
||||
$num_users = $this->em->createQuery('SELECT COUNT(u.id) FROM Entity\User u')
|
||||
->getSingleScalarResult();
|
||||
|
||||
if ($num_users == 0)
|
||||
return $this->redirectFromHere(['action' => 'register']);
|
||||
|
||||
// New station setup form.
|
||||
$this->flash('<b>Test!</b><br>Test');
|
||||
$this->flash('<b>Test!</b><br>This is a longer message. Success message. Thingy success. Yay.', 'green');
|
||||
$this->flash('<b>Test!</b><br>An error has occurred! This is an error message!', 'red');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,21 +8,23 @@ $page_class = 'login-content';
|
|||
<h3 class="text-left">Welcome to <?=$this->config->application->name ?>!</h3>
|
||||
<P class="text-left">Begin setup by creating a Super Administrator account.</p>
|
||||
|
||||
<div class="input-group m-b-20">
|
||||
<span class="input-group-addon"><i class="fa fa-user"></i></span>
|
||||
<div class="fg-line">
|
||||
<input type="text" name="username" class="form-control" placeholder="E-mail Address">
|
||||
<form action="" method="post">
|
||||
<div class="input-group m-b-20">
|
||||
<span class="input-group-addon"><i class="fa fa-user"></i></span>
|
||||
<div class="fg-line">
|
||||
<input type="email" name="email" class="form-control" placeholder="E-mail Address">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group m-b-20">
|
||||
<span class="input-group-addon"><i class="fa fa-asterisk"></i></span>
|
||||
<div class="fg-line">
|
||||
<input type="password" name="password" class="form-control" placeholder="Password">
|
||||
<div class="input-group m-b-20">
|
||||
<span class="input-group-addon"><i class="fa fa-asterisk"></i></span>
|
||||
<div class="fg-line">
|
||||
<input type="password" name="password" class="form-control" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<a href="" class="btn btn-login btn-primary btn-float"><i class="zmdi zmdi-arrow-forward"></i></a>
|
||||
<button type="submit" class="btn btn-login btn-primary btn-float"><i class="zmdi zmdi-arrow-forward"></i></button>
|
||||
</form>
|
||||
</div>
|
|
@ -31,15 +31,19 @@ header("Content-type: text/html; charset=utf-8");
|
|||
$this->assets->outputCss('header_css');
|
||||
|
||||
// Set up JS includes.
|
||||
$this->assets->collection('footer_js')
|
||||
$this->assets->collection('header_js')
|
||||
->addJs('vendors/bower_components/jquery/dist/jquery.min.js')
|
||||
->addJs('vendors/bower_components/bootstrap/dist/js/bootstrap.min.js')
|
||||
->addJs('vendors/bower_components/bootstrap/dist/js/bootstrap.min.js');
|
||||
|
||||
$this->assets->outputJs('header_js');
|
||||
|
||||
$this->assets->collection('footer_js')
|
||||
->addJs('vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js')
|
||||
->addJs('vendors/bower_components/Waves/dist/waves.min.js')
|
||||
->addJs('vendors/bootstrap-growl/bootstrap-growl.min.js')
|
||||
->addJs('vendors/bower_components/bootstrap-sweetalert/lib/sweet-alert.min.js')
|
||||
->addJs('js/functions.js')
|
||||
->addJs('js/demo.js');
|
||||
->addJs('js/app.js');
|
||||
?>
|
||||
<script>
|
||||
var APP_AppEnv = '<?=(defined('APP_APPLICATION_ENV') ? APP_APPLICATION_ENV : '') ?>';
|
||||
|
@ -59,7 +63,7 @@ header("Content-type: text/html; charset=utf-8");
|
|||
</li>
|
||||
|
||||
<li class="logo hidden-xs">
|
||||
<a href="<?=$this->url->get('') ?>"><?=$this->config->application->name ?></a>
|
||||
<a href="<?=$this->url->get('') ?>"><strong><?=$this->config->application->name ?></strong> alpha</a>
|
||||
</li>
|
||||
|
||||
<li class="pull-right">
|
||||
|
@ -1127,21 +1131,13 @@ header("Content-type: text/html; charset=utf-8");
|
|||
|
||||
<footer id="footer">
|
||||
Copyright © <?=date('Y') ?> <?=$this->config->application->name ?>.
|
||||
|
||||
<ul class="f-menu">
|
||||
<li><a href="">Home</a></li>
|
||||
<li><a href="">Dashboard</a></li>
|
||||
<li><a href="">Reports</a></li>
|
||||
<li><a href="">Support</a></li>
|
||||
<li><a href="">Contact</a></li>
|
||||
</ul>
|
||||
</footer>
|
||||
|
||||
<!-- Page Loader -->
|
||||
<div class="page-loader">
|
||||
<div class="preloader pls-blue">
|
||||
<svg class="pl-circular" viewBox="25 25 50 50">
|
||||
<circle class="plc-path" cx="50" cy="50" r="20" />
|
||||
<circle class="plc-path" cx="50" cy="50" r="20"></circle>
|
||||
</svg>
|
||||
|
||||
<p>Please wait...</p>
|
||||
|
@ -1149,7 +1145,17 @@ header("Content-type: text/html; charset=utf-8");
|
|||
</div>
|
||||
|
||||
<?
|
||||
echo $this->assets->outputJs('footer_js');
|
||||
$this->assets->outputJs('footer_js');
|
||||
?>
|
||||
|
||||
<? if ($this->flash->hasMessages()): ?>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
<? foreach($this->flash->getMessages() as $message): ?>
|
||||
notify('<?=$this->escaper->escapeJs($message['text']) ?>', '<?=$message['color'] ?>');
|
||||
<? endforeach; ?>
|
||||
});
|
||||
</script>
|
||||
<? endif; ?>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
function notify(message, type){
|
||||
$.growl({
|
||||
message: message
|
||||
},{
|
||||
type: type,
|
||||
allow_dismiss: true,
|
||||
label: 'Cancel',
|
||||
className: 'btn-xs btn-inverse align-right',
|
||||
placement: {
|
||||
from: 'top',
|
||||
align: 'right'
|
||||
},
|
||||
delay: 10000,
|
||||
animate: {
|
||||
enter: 'animated fadeIn',
|
||||
exit: 'animated fadeOut'
|
||||
},
|
||||
offset: {
|
||||
x: 20,
|
||||
y: 85
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
$(window).load(function(){
|
||||
//Welcome Message (not for login page)
|
||||
function notify(message, type){
|
||||
$.growl({
|
||||
message: message
|
||||
},{
|
||||
type: type,
|
||||
allow_dismiss: false,
|
||||
label: 'Cancel',
|
||||
className: 'btn-xs btn-inverse',
|
||||
placement: {
|
||||
from: 'top',
|
||||
align: 'right'
|
||||
},
|
||||
delay: 2500,
|
||||
animate: {
|
||||
enter: 'animated fadeIn',
|
||||
exit: 'animated fadeOut'
|
||||
},
|
||||
offset: {
|
||||
x: 20,
|
||||
y: 85
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (!$('.login-content')[0]) {
|
||||
notify('Welcome back Mallinda Hollaway', 'inverse');
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue