mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Dashboards edition final touch...
SVN:trunk[2059]
This commit is contained in:
@@ -216,6 +216,7 @@ abstract class Dashboard
|
||||
$('#row_attr_dashboard_title').property_field('option', {'do_apply': function() {
|
||||
var sTitle = $('#attr_dashboard_title').val();
|
||||
$(':itop-dashboard').dashboard('option', {title: sTitle});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
EOF
|
||||
|
||||
@@ -296,7 +296,12 @@ class DashletObjectList extends Dashlet
|
||||
$sQuery = $this->aProperties['query'];
|
||||
$sShowMenu = $this->aProperties['menu'] ? '1' : '0';
|
||||
|
||||
$oPage->add('<div style="text-align:center" class="dashlet-content">');
|
||||
$oPage->add('<div class="dashlet-content">');
|
||||
$sHtmlTitle = htmlentities(Dict::S($sTitle), ENT_QUOTES, 'UTF-8'); // done in the itop block
|
||||
if ($sHtmlTitle != '')
|
||||
{
|
||||
$oPage->add('<h1>'.$sHtmlTitle.'</h1>');
|
||||
}
|
||||
$oFilter = DBObjectSearch::FromOQL($sQuery);
|
||||
$oBlock = new DisplayBlock($oFilter, 'list');
|
||||
$aExtraParams = array(
|
||||
@@ -752,8 +757,16 @@ class DashletHeaderStatic extends Dashlet
|
||||
{
|
||||
$oField = new DesignerTextField('title', 'Title', $this->aProperties['title']);
|
||||
$oForm->AddField($oField);
|
||||
|
||||
$oField = new DesignerTextField('icon', 'Icon', $this->aProperties['icon']);
|
||||
|
||||
$oField = new DesignerIconSelectionField('icon', 'Icon', $this->aProperties['icon']);
|
||||
$aAllIcons = self::FindIcons(APPROOT.'env-'.utils::GetCurrentEnvironment());
|
||||
ksort($aAllIcons);
|
||||
$aValues = array();
|
||||
foreach($aAllIcons as $sFilePath)
|
||||
{
|
||||
$aValues[] = array('value' => $sFilePath, 'label' => basename($sFilePath), 'icon' => utils::GetAbsoluteUrlModulesRoot().$sFilePath);
|
||||
}
|
||||
$oField->SetAllowedValues($aValues);
|
||||
$oForm->AddField($oField);
|
||||
}
|
||||
|
||||
@@ -765,6 +778,30 @@ class DashletHeaderStatic extends Dashlet
|
||||
'description' => 'Header with stats (grouped by...)',
|
||||
);
|
||||
}
|
||||
|
||||
static public function FindIcons($sBaseDir, $sDir = '')
|
||||
{
|
||||
$aResult = array();
|
||||
// Populate automatically the list of icon files
|
||||
if ($hDir = @opendir($sBaseDir.'/'.$sDir))
|
||||
{
|
||||
while (($sFile = readdir($hDir)) !== false)
|
||||
{
|
||||
$aMatches = array();
|
||||
if (($sFile != '.') && ($sFile != '..') && is_dir($sBaseDir.'/'.$sDir.'/'.$sFile))
|
||||
{
|
||||
$sDirSubPath = ($sDir == '') ? $sFile : $sDir.'/'.$sFile;
|
||||
$aResult = array_merge($aResult, self::FindIcons($sBaseDir, $sDirSubPath));
|
||||
}
|
||||
if (preg_match("/\.(png|jpg|jpeg|gif)$/i", $sFile, $aMatches)) // png, jp(e)g and gif are considered valid
|
||||
{
|
||||
$aResult[$sFile.'_'.$sDir] = $sDir.'/'.$sFile;
|
||||
}
|
||||
}
|
||||
closedir($hDir);
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -854,7 +891,15 @@ class DashletHeaderDynamic extends Dashlet
|
||||
$oField = new DesignerTextField('title', 'Title', $this->aProperties['title']);
|
||||
$oForm->AddField($oField);
|
||||
|
||||
$oField = new DesignerTextField('icon', 'Icon', $this->aProperties['icon']);
|
||||
$oField = new DesignerIconSelectionField('icon', 'Icon', $this->aProperties['icon']);
|
||||
$aAllIcons = DashletHeaderStatic::FindIcons(APPROOT.'env-'.utils::GetCurrentEnvironment());
|
||||
ksort($aAllIcons);
|
||||
$aValues = array();
|
||||
foreach($aAllIcons as $sFilePath)
|
||||
{
|
||||
$aValues[] = array('value' => $sFilePath, 'label' => basename($sFilePath), 'icon' => utils::GetAbsoluteUrlModulesRoot().$sFilePath);
|
||||
}
|
||||
$oField->SetAllowedValues($aValues);
|
||||
$oForm->AddField($oField);
|
||||
|
||||
$oField = new DesignerTextField('subtitle', 'Subtitle', $this->aProperties['subtitle']);
|
||||
@@ -923,11 +968,52 @@ class DashletBadge extends Dashlet
|
||||
$oBlock->Display($oPage, $sBlockId, $aExtraParams);
|
||||
|
||||
$oPage->add('</div>');
|
||||
if ($bEditMode)
|
||||
{
|
||||
// Since the container div is not rendered the same way in edit mode, add the 'inline' style to it
|
||||
$oPage->add_ready_script("$('#dashlet_".$this->sId."').addClass('dashlet-inline');");
|
||||
}
|
||||
}
|
||||
|
||||
public function GetPropertiesFields(DesignerForm $oForm)
|
||||
{
|
||||
$oField = new DesignerTextField('class', 'Class', $this->aProperties['class']);
|
||||
|
||||
$oClassesSet = new ValueSetEnumClasses('bizmodel', array());
|
||||
$aClasses = $oClassesSet->GetValues(array());
|
||||
|
||||
$aLinkClasses = array();
|
||||
|
||||
foreach(MetaModel::GetClasses('bizmodel') as $sClass)
|
||||
{
|
||||
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
||||
{
|
||||
if ($oAttDef instanceof AttributeLinkedSetIndirect)
|
||||
{
|
||||
$aLinkClasses[$oAttDef->GetLinkedClass()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oField = new DesignerIconSelectionField('class', 'Class', $this->aProperties['class']);
|
||||
ksort($aClasses);
|
||||
$aValues = array();
|
||||
foreach($aClasses as $sClass => $sClass)
|
||||
{
|
||||
if (!array_key_exists($sClass, $aLinkClasses))
|
||||
{
|
||||
$sIconUrl = MetaModel::GetClassIcon($sClass, false);
|
||||
$sIconFilePath = str_replace(utils::GetAbsoluteUrlAppRoot(), APPROOT, $sIconUrl);
|
||||
if (($sIconUrl == '') || !file_exists($sIconFilePath))
|
||||
{
|
||||
// The icon does not exist, leet's use a transparent one of the same size.
|
||||
$sIconUrl = utils::GetAbsoluteUrlAppRoot().'images/transparent_32_32.png';
|
||||
}
|
||||
$aValues[] = array('value' => $sClass, 'label' => $sClass, 'icon' => $sIconUrl);
|
||||
}
|
||||
}
|
||||
$oField->SetAllowedValues($aValues);
|
||||
|
||||
$oForm->AddField($oField);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ class iTopWebPage extends NiceWebPage
|
||||
$this->add_header("Cache-control: no-cache");
|
||||
$this->add_linked_stylesheet("../css/jquery.treeview.css");
|
||||
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
|
||||
$this->add_linked_stylesheet("../css/fg.menu.css");
|
||||
$this->add_linked_script('../js/jquery.layout.min.js');
|
||||
$this->add_linked_script('../js/jquery.ba-bbq.min.js');
|
||||
$this->add_linked_script("../js/jquery.treeview.js");
|
||||
@@ -69,6 +70,8 @@ class iTopWebPage extends NiceWebPage
|
||||
$this->add_linked_script("../js/ckeditor/adapters/jquery.js");
|
||||
$this->add_linked_script("../js/jquery.qtip-1.0.min.js");
|
||||
$this->add_linked_script('../js/property_field.js');
|
||||
$this->add_linked_script('../js/fg.menu.js');
|
||||
$this->add_linked_script('../js/icon_select.js');
|
||||
$this->add_linked_script('../js/raphael-min.js');
|
||||
$this->add_linked_script('../js/g.raphael.js');
|
||||
$this->add_linked_script('../js/g.pie.js');
|
||||
|
||||
Reference in New Issue
Block a user