mirror of
https://github.com/myvesta/vesta
synced 2025-07-15 01:23:23 -07:00
Save active tab in cookie in order to restore after page refresh
This commit is contained in:
parent
0f2c093148
commit
f651c68a6a
9 changed files with 99 additions and 65 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/core/utils/error_logger.php'
|
||||
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/core/utils/error_logger.php';
|
||||
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/app.init.php';
|
||||
|
||||
?>
|
||||
|
|
|
@ -204,6 +204,7 @@
|
|||
|
||||
|
||||
<!-- script type="text/javascript" src="js/lib/jquery-1.4.4.min.js"></script -->
|
||||
<script type="text/javascript" src="js/lib/cookie.js"></script>
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.js"></script>
|
||||
<script type="text/javascript" src="js/date_format.js"></script>
|
||||
<script type="text/javascript" src="js/lib/custom-form-elements.js"></script>
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
$(document).ready(function(){
|
||||
try{
|
||||
App.Utils.detectBrowser();
|
||||
App.Env.world = 'CRON';
|
||||
|
||||
if ('undefined' != typeof App.Tmp.loadTAB) {
|
||||
App.Env.world = App.Tmp.loadTAB;
|
||||
}
|
||||
|
||||
if ('undefined' == typeof App.Tmp.loadTAB && cookieEnabled()) {
|
||||
var tab = getCookie('tab');
|
||||
if (null != tab && $.inArray(tab, App.Constants.TABS)) {
|
||||
App.Env.world = tab;
|
||||
}
|
||||
else {
|
||||
App.Env.world = App.Constants.TABS[0];
|
||||
}
|
||||
}
|
||||
|
||||
App.Pages.init();
|
||||
App.Ref.init();
|
||||
|
||||
|
|
|
@ -78,7 +78,9 @@ var App = {
|
|||
Core: {},
|
||||
Bash: {},
|
||||
Console: {},
|
||||
Constants: {},
|
||||
Constants: {
|
||||
TABS: ['USER','WEB_DOMAIN','MAIL','DB','DNS','IP','CRON']
|
||||
},
|
||||
Actions: {},
|
||||
Helpers: {},
|
||||
Filters: {},
|
||||
|
@ -175,16 +177,7 @@ App.Ajax.request = function(jedi_method, data, callback)
|
|||
{
|
||||
App.Helpers.beforeAjax(jedi_method);
|
||||
$.ajax({
|
||||
url: function() {
|
||||
var url_parts = location.href.replace('#', '').split('/');
|
||||
if (url_parts[url_parts.length -1] == 'index.html') {
|
||||
url_parts[url_parts.length -1] = 'dispatch.php';
|
||||
}
|
||||
else {
|
||||
url_parts.push('dispatch.php');
|
||||
}
|
||||
return url_parts.join('/');
|
||||
}(),
|
||||
url: App.Helpers.getBackendUrl(),
|
||||
global: false,
|
||||
type: data.request_method || "POST",
|
||||
data: $.extend(data, {'jedi_method': jedi_method}),
|
||||
|
|
|
@ -264,3 +264,26 @@ App.Helpers.closeInnerPopup = function(evt)
|
|||
{
|
||||
$('#inner-popup').remove();
|
||||
}
|
||||
|
||||
App.Helpers.getBackendUrl = function()
|
||||
{
|
||||
var url_parts = location.href.split('#');
|
||||
if (url_parts.length > 1) {
|
||||
var tab = url_parts[url_parts.length - 1];
|
||||
if ($.inArray(tab, App.Constants.TABS) != -1) {
|
||||
App.Tmp.loadTAB = tab;
|
||||
}
|
||||
}
|
||||
|
||||
var url_parts = location.href.split('?', 1);
|
||||
var url = url_parts[0];
|
||||
url_parts = url.split('/');
|
||||
if (url_parts[url_parts.length -1] == 'index.html') {
|
||||
url_parts[url_parts.length -1] = 'dispatch.php';
|
||||
}
|
||||
else {
|
||||
url_parts.push('dispatch.php');
|
||||
}
|
||||
|
||||
return url_parts.join('/');
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@ App.Pages.init = function(){
|
|||
|
||||
$('.section.active').removeClass('active');
|
||||
$('#'+App.Env.world).addClass('active');
|
||||
|
||||
if (cookieEnabled()) {
|
||||
setCookie('tab', App.Env.world);
|
||||
}
|
||||
}
|
||||
|
||||
App.Pages.prepareHTML = function()
|
||||
|
|
|
@ -25,6 +25,11 @@ class AjaxHandler {
|
|||
return null == self::$instance ? self::$instance = new self() : self::$instance;
|
||||
}
|
||||
|
||||
public function getLoggedUser()
|
||||
{
|
||||
return VestaSession::getInstance()->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called functions should reply in the following way
|
||||
* return $this->reply($result, $data, $msg, $extra);
|
||||
|
|
|
@ -17,7 +17,7 @@ class USER extends AjaxHandler
|
|||
* @param Request $request
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListExecute($request)
|
||||
public function getListExecute(Request $request)
|
||||
{
|
||||
$reply = array();
|
||||
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
|
||||
|
@ -80,26 +80,19 @@ class USER extends AjaxHandler
|
|||
* @param Request $request
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addExecute($_spell = FALSE)
|
||||
public function addExecute(Request $request)
|
||||
{
|
||||
$r = new Request();
|
||||
if ($_spell) {
|
||||
$_s = $_spell;
|
||||
}
|
||||
else {
|
||||
$_s = $r->getSpell();
|
||||
}
|
||||
|
||||
$_user = 'vesta';
|
||||
$spell = $request->getParameter('spell');
|
||||
$user = $this->getLoggedUser();
|
||||
$params = array(
|
||||
'USER' => $_s['USER'],
|
||||
'PASSWORD' => $_s['PASSWORD'],
|
||||
'EMAIL' => $_s['EMAIL'],
|
||||
'ROLE' => $_s['ROLE'],
|
||||
'OWNER' => $_user,
|
||||
'PACKAGE' => $_s['PACKAGE'],
|
||||
'NS1' => $_s['NS1'],
|
||||
'NS2' => $_s['NS2']
|
||||
'USER' => $spell['USER'],
|
||||
'PASSWORD' => $spell['PASSWORD'],
|
||||
'EMAIL' => $spell['EMAIL'],
|
||||
'ROLE' => $spell['ROLE'],
|
||||
'OWNER' => $user['uid'],
|
||||
'PACKAGE' => $spell['PACKAGE'],
|
||||
'NS1' => $spell['NS1'],
|
||||
'NS2' => $spell['NS2']
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
|
||||
require_once V_ROOT_DIR . 'config/Config.class.php';
|
||||
require_once V_ROOT_DIR . 'core/VestaSession.class.php';
|
||||
require_once V_ROOT_DIR . 'core/Vesta.class.php';
|
||||
require_once V_ROOT_DIR . 'core/exceptions/SystemException.class.php';
|
||||
require_once V_ROOT_DIR . 'core/exceptions/ProtectionException.class.php';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue