admin magic box: v0.1
This commit is contained in:
@@ -1405,7 +1405,14 @@ class Databap extends PhpObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ksort($asSelectedOptions);
|
ksort($asSelectedOptions);
|
||||||
return $this->jsonExport($asSelectedOptions);
|
|
||||||
|
//Admin options
|
||||||
|
$asAdminOptions = array();
|
||||||
|
if($this->checkUserClearance(self::CLEARANCE_ADMIN))
|
||||||
|
{
|
||||||
|
$asAdminOptions['companies'] = $this->oMySql->selectList(self::COMP_TABLE);
|
||||||
|
}
|
||||||
|
return $this->jsonExport(array('admin'=>$asAdminOptions, 'options'=>$asSelectedOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOptions($asNewOptions, $bSilentUpdate=true, $iUserId=0)
|
public function setOptions($asNewOptions, $bSilentUpdate=true, $iUserId=0)
|
||||||
|
|||||||
@@ -446,6 +446,17 @@ class MySqlManager extends PhpObject
|
|||||||
return $this->setQuery("TRUNCATE ".$sTableName);
|
return $this->setQuery("TRUNCATE ".$sTableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function selectList($sTableName, $sColumnName='', $asConstraints=array())
|
||||||
|
{
|
||||||
|
$sColumnName = $sColumnName==''?self::getText($sTableName):$sColumnName;
|
||||||
|
$sIdColumnName = self::getId($sTableName);
|
||||||
|
return $this->selectRows( array( 'select' => array($sIdColumnName, $sColumnName),
|
||||||
|
'from' => $sTableName,
|
||||||
|
'constraint'=> $asConstraints),
|
||||||
|
true,
|
||||||
|
$sIdColumnName);
|
||||||
|
}
|
||||||
|
|
||||||
public function selectRows($asInfo, $bStringOnly=true, $sGroupBy='')
|
public function selectRows($asInfo, $bStringOnly=true, $sGroupBy='')
|
||||||
{
|
{
|
||||||
$asAttributes = array('select'=>"SELECT", 'from'=>"FROM", 'join'=>"LEFT JOIN", 'joinOn'=>"LEFT JOIN", 'constraint'=>"WHERE", 'groupBy'=>"GROUP BY", 'orderBy'=>"ORDER BY", 'limit'=>'LIMIT');
|
$asAttributes = array('select'=>"SELECT", 'from'=>"FROM", 'join'=>"LEFT JOIN", 'joinOn'=>"LEFT JOIN", 'constraint'=>"WHERE", 'groupBy'=>"GROUP BY", 'orderBy'=>"ORDER BY", 'limit'=>'LIMIT');
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<div id="logout">
|
<div id="logout"></div>
|
||||||
<p class="round"><i class="fa fa-spin fa-20 fa-inline fa-c-loading"></i>Déconnexion...</p>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
databap.pageInit = function()
|
||||||
|
{
|
||||||
|
self.addBufferIcon();
|
||||||
self.getInfo('log_me_out', function(){document.location='';});
|
self.getInfo('log_me_out', function(){document.location='';});
|
||||||
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -16,6 +16,16 @@
|
|||||||
<input type="hidden" id="new_auth_token" name="new_auth_token" />
|
<input type="hidden" id="new_auth_token" name="new_auth_token" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="options_box round hide" id="admin">
|
||||||
|
<h2><i class="fa fa-c-changelog fa-inline"></i>Boite magique</h2>
|
||||||
|
<div id="add_user" class="magic_box tiny_round">
|
||||||
|
<h3><i class="fa fa-inline fa-c-profile"></i>Ajouter un user</h3>
|
||||||
|
<p><input type="text" class="tiny_round" id="first_name" name="first_name" /></p>
|
||||||
|
<p><input type="text" class="tiny_round" id="last_name" name="last_name" /></p>
|
||||||
|
<p><input type="text" class="tiny_round" id="email" name="email" /></p>
|
||||||
|
<p id="companies"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -32,17 +42,20 @@ databap.pageInit = function()
|
|||||||
databap.getInfo
|
databap.getInfo
|
||||||
(
|
(
|
||||||
'get_options',
|
'get_options',
|
||||||
function(options)
|
function(oData)
|
||||||
{
|
{
|
||||||
//remove default text
|
//remove default text
|
||||||
$('#options_input').find('.loading').hide().remove();
|
$('#options_input').find('.loading').hide().remove();
|
||||||
|
|
||||||
//Display options form
|
//Display options form
|
||||||
$.each(options, addOption);
|
$.each(oData.options, addOption);
|
||||||
|
|
||||||
//Submit button
|
//Submit button
|
||||||
$('#options_form').addButton('ok', 'Valider', validate_options, 'validate_options', 'heavy inverse');
|
$('#options_form').addButton('ok', 'Valider', validate_options, 'validate_options', 'heavy inverse');
|
||||||
|
|
||||||
|
//Admin panel
|
||||||
|
if(!$.isEmptyObject(oData.admin)) initAdminPanel(oData.admin);
|
||||||
|
|
||||||
//Init's end
|
//Init's end
|
||||||
databap.setInitEnd(true);
|
databap.setInitEnd(true);
|
||||||
},
|
},
|
||||||
@@ -58,6 +71,38 @@ databap.onResize = function()
|
|||||||
self.setScrollBarSize('maximize');
|
self.setScrollBarSize('maximize');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function initAdminPanel(asAdmin)
|
||||||
|
{
|
||||||
|
//Add user
|
||||||
|
$('#first_name').addDefaultValue('Prénom');
|
||||||
|
$('#last_name').addDefaultValue('Nom');
|
||||||
|
addSelect($('#companies'), asAdmin.companies);
|
||||||
|
$('#email').addDefaultValue('Email');
|
||||||
|
$('#add_user').addButton('ok', 'Créer', function(){}, 'submit_new_user', 'heavy inverse');
|
||||||
|
|
||||||
|
//Show panel
|
||||||
|
$('#admin').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSelect($Box, asOptions, sSelectedValue, sSelectId, sSelectClass)
|
||||||
|
{
|
||||||
|
sSelectedValue = sSelectedValue || 0;
|
||||||
|
sSelectId = sSelectId || '';
|
||||||
|
sSelectClass = sSelectClass || '';
|
||||||
|
var $Select = $('<select>', {id:sSelectId, name:sSelectId, 'class':sSelectClass}).appendTo($Box);
|
||||||
|
$.each
|
||||||
|
(
|
||||||
|
asOptions,
|
||||||
|
function(selectId, selectName)
|
||||||
|
{
|
||||||
|
$Select
|
||||||
|
.append($('<option>', {value:selectId})
|
||||||
|
.prop('selected', (selectId==sSelectedValue))
|
||||||
|
.text(selectName));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function addOption(iArrayId, optInfo, $Box)
|
function addOption(iArrayId, optInfo, $Box)
|
||||||
{
|
{
|
||||||
var optNameId = optInfo.option_id;
|
var optNameId = optInfo.option_id;
|
||||||
@@ -73,49 +118,27 @@ function addOption(iArrayId, optInfo, $Box)
|
|||||||
$Option.append($('<input>', {type:'password', id:optNameId, name:optNameId, value:optInfo.user_value, 'class':'round'}));
|
$Option.append($('<input>', {type:'password', id:optNameId, name:optNameId, value:optInfo.user_value, 'class':'round'}));
|
||||||
break;
|
break;
|
||||||
case databap.consts.opt_type_checkbox:
|
case databap.consts.opt_type_checkbox:
|
||||||
var $Select = $('<select>', {id:optNameId, name:optNameId, 'class':'hide'}).appendTo($Option);
|
addSelect($Option, optInfo.select, optInfo.user_value_id, optNameId, 'hide');
|
||||||
$.each
|
|
||||||
(
|
|
||||||
optInfo.select,
|
|
||||||
function(selectId, selectName)
|
|
||||||
{
|
|
||||||
$Select
|
|
||||||
.append($('<option>', {value:selectId})
|
|
||||||
.prop('selected', (selectId==optInfo.user_value_id))
|
|
||||||
.text(selectName));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$Option.append(
|
$Option.append(
|
||||||
$('<span>', {'class':'checkbox clickable'})
|
$('<span>', {'class':'checkbox clickable'})
|
||||||
.data('option_id', optNameId)
|
.data('option_id', optNameId)
|
||||||
.data('on', optInfo.user_value)
|
.data('on', optInfo.user_value)
|
||||||
.data('options', optInfo.select_inv)
|
.data('options', optInfo.select_inv)
|
||||||
.append($('<i>', {'class':'fa fa-c-'+(optInfo.user_value=="1"?'on':'off')}))
|
.append($('<i>', {'class':'fa fa-c-'+optInfo.user_value}))
|
||||||
.click(function()
|
.click(function()
|
||||||
{
|
{
|
||||||
$This = $(this);
|
$This = $(this);
|
||||||
var sNewValue = !$This.data('on');
|
var sNewValue = ($This.data('on')=='1')?'0':'1';
|
||||||
$This.data('on', sNewValue);
|
$This.data('on', sNewValue);
|
||||||
$('#'+$This.data('option_id')).val($This.data('options')[sNewValue?1:0]);
|
$('#'+$This.data('option_id')).val($This.data('options')[sNewValue]);
|
||||||
$This.find('.fa')
|
$This.find('.fa')
|
||||||
.removeClass('fa-c-on fa-c-off')
|
.removeClass('fa-c-0 fa-c-1')
|
||||||
.addClass('fa-c-'+(sNewValue?'on':'off'));
|
.addClass('fa-c-'+sNewValue);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case databap.consts.opt_type_select:
|
case databap.consts.opt_type_select:
|
||||||
var $Select = $('<select>', {id:optNameId, name:optNameId, 'class':'round'}).appendTo($Option);
|
addSelect($Option, optInfo.select, optInfo.user_value_id, optNameId, 'round');
|
||||||
$.each
|
|
||||||
(
|
|
||||||
optInfo.select,
|
|
||||||
function(selectId, selectName)
|
|
||||||
{
|
|
||||||
$Select
|
|
||||||
.append($('<option>', {value:selectId})
|
|
||||||
.prop('selected', (selectId==optInfo.user_value_id))
|
|
||||||
.text(selectName));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$Option.appendTo($Box).slideDown('fast');
|
$Option.appendTo($Box).slideDown('fast');
|
||||||
|
|||||||
@@ -312,9 +312,9 @@ vertical-align 0% -5% -10% -15% -20% -25% -30%
|
|||||||
content: "\f03e";
|
content: "\f03e";
|
||||||
}
|
}
|
||||||
|
|
||||||
.fa-c-on:before {
|
.fa-c-on:before, .fa-c-1:before {
|
||||||
content: "\f205";
|
content: "\f205";
|
||||||
}
|
}
|
||||||
.fa-c-off:before {
|
.fa-c-off:before, .fa-c-0:before {
|
||||||
content: "\f204";
|
content: "\f204";
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1059,12 +1059,14 @@
|
|||||||
|
|
||||||
#options .options_box {
|
#options .options_box {
|
||||||
background:$col_main_3;
|
background:$col_main_3;
|
||||||
width:490px;
|
width:calc(50% - 25px);
|
||||||
float:left;
|
float:left;
|
||||||
margin:0 10px 10px 0;
|
margin:0 10px 10px 0;
|
||||||
padding:10px;
|
padding:10px;
|
||||||
}
|
}
|
||||||
|
#options .options_box:nth-child(even) {
|
||||||
|
margin-right:0;
|
||||||
|
}
|
||||||
#options .options_box .loading {
|
#options .options_box .loading {
|
||||||
padding:10px;
|
padding:10px;
|
||||||
}
|
}
|
||||||
@@ -1086,11 +1088,12 @@
|
|||||||
#options .options_box input[type=password],
|
#options .options_box input[type=password],
|
||||||
#options .options_box select,
|
#options .options_box select,
|
||||||
#options .options_box .checkbox {
|
#options .options_box .checkbox {
|
||||||
background:$col_none;
|
background:$col_main_4;
|
||||||
border-width:1px;
|
border-width:1px;
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
padding:5px;
|
padding:5px;
|
||||||
float:right;
|
float:right;
|
||||||
|
width:calc(50% - 10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
#options .options_box .button {
|
#options .options_box .button {
|
||||||
@@ -1103,14 +1106,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#options .options_box .checkbox {
|
#options .options_box .checkbox {
|
||||||
padding:0;
|
text-align:center;
|
||||||
|
padding-top:0;
|
||||||
|
padding-bottom:0;
|
||||||
background:none;
|
background:none;
|
||||||
font-size:1.7em;
|
font-size:1.7em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#options .options_box .option_line p {
|
#options .options_box .option_line p {
|
||||||
float:left;
|
float:left;
|
||||||
width:250px;
|
width:50%;
|
||||||
padding:5px 0;
|
padding:5px 0;
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
}
|
}
|
||||||
@@ -1119,6 +1124,35 @@
|
|||||||
margin-top:5px;
|
margin-top:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#options #admin {
|
||||||
|
clear:both;
|
||||||
|
width:calc(100% - 20px);
|
||||||
|
}
|
||||||
|
|
||||||
|
#options #admin .magic_box {
|
||||||
|
font-size:14px;
|
||||||
|
padding:5px 10px 10px;
|
||||||
|
background:$col_main_4;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#options #admin .magic_box h3 {
|
||||||
|
margin:0;
|
||||||
|
font-style: italic;
|
||||||
|
text-align: center;
|
||||||
|
padding:5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#options #admin .magic_box input, #options #admin .magic_box select {
|
||||||
|
width:calc(100% - 10px);
|
||||||
|
margin:5px 0;
|
||||||
|
float:left;
|
||||||
|
background:white;
|
||||||
|
}
|
||||||
|
#options #admin .magic_box select {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* Procedure */
|
/* Procedure */
|
||||||
|
|
||||||
#procedure #procedure_steps .button {
|
#procedure #procedure_steps .button {
|
||||||
@@ -1354,15 +1388,6 @@
|
|||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Log Out */
|
|
||||||
|
|
||||||
#logout p {
|
|
||||||
font-size:18px;
|
|
||||||
background-color:$col_main_3;
|
|
||||||
margin-top:25px;
|
|
||||||
padding:5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note */
|
/* Note */
|
||||||
|
|
||||||
#note {
|
#note {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user