src/it/ht/rcs/console/alerting/view/AlertingSection.mxml
<?xml version="1.0" encoding="utf-8"?>
<main:Section xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:main="it.ht.rcs.console.main.*"
xmlns:view="it.ht.rcs.console.alerting.view.*"
addedToStage="onAddedToStage()"
creationComplete="init()"
removedFromStage="onRemovedFromStage()">
<main:layout>
<s:VerticalLayout paddingBottom="5"
paddingLeft="5"
paddingRight="5"
paddingTop="5"/>
</main:layout>
<fx:Script>
<![CDATA[
import com.greensock.TweenMax;
import com.hurlant.crypto.symmetric.NullPad;
import it.ht.rcs.console.alert.controller.AlertManager;
import it.ht.rcs.console.alert.model.Alert;
import it.ht.rcs.console.search.controller.SearchManager;
import mx.collections.ArrayCollection;
import mx.collections.ArrayList;
import mx.collections.ListCollectionView;
import spark.collections.Sort;
import spark.collections.SortField;
import spark.events.GridSelectionEvent;
[Bindable]
private var view:ListCollectionView;
private function init():void
{
var defaultSort:Sort=new Sort();
defaultSort.fields=[new SortField('_id', false, false)];
view=AlertManager.instance.getView(defaultSort, searchFilterFunction);
}
private function onAddedToStage():void
{
AlertManager.instance.listenRefresh();
//AlertManager.instance.startAutorefresh();
}
private function onRemovedFromStage():void
{
AlertManager.instance.unlistenRefresh();
//AlertManager.instance.stopAutorefresh();
}
private function searchFilterFunction(item:Object):Boolean
{
if (item.keywords == null && item.path == null && item.type == null && alertBar.searchInput.text.length > 0)
return false;
var path:String="";
var o:*;
if (item.path.length > 0)
{
o=SearchManager.instance.getItem(item.path.getItemAt(0).toString());
if (o != null)
path=o.name;
else
path='***';
}
if (item.path.length > 1)
{
o=SearchManager.instance.getItem(item.path.getItemAt(1).toString());
if (o != null)
path+=" > " + o.name;
else
path+=" > " + '***';
}
if (item.path.length > 2)
{
o=SearchManager.instance.getItem(item.path.getItemAt(2).toString());
if (o != null)
path+=" > " + o.name;
else
path+=" > " + '***';
}
try
{
return item.keywords.toLowerCase().indexOf(alertBar.searchInput.text.toLowerCase()) != -1 || path.toLowerCase().indexOf(alertBar.searchInput.text.toLowerCase()) != -1 || item.type.toLowerCase().indexOf(alertBar.searchInput.text.toLowerCase()) != -1;
}
catch (e:Error)
{
}
return true;
}
private function alertsSelectionChange(event:GridSelectionEvent):void
{
alertBar.selectedObject=alerts.selectedItem ? alerts.selectedItem : null;
logs.dataProvider=alerts.selectedItem ? alerts.selectedItem.logs : null;
logs.selectedItem=null;
logBar.selectedObjects=null;
logBar.selectedIndices=null;
logBar.view=logs.dataProvider as ArrayCollection;
onLogsShow()
}
private function logsSelectionChange(event:GridSelectionEvent):void
{
logBar.selectedObjects=logs.selectedItems ? logs.selectedItems : null;
logBar.selectedIndices=logs.selectedIndices ? logs.selectedIndices : null;
}
private function onLogsShow():void
{
logsBox.percentHeight=1;
TweenMax.to(logsBox,0.4,{percentHeight:100})
}
private function onLogsHide():void
{
return; //TODO
}
]]>
</fx:Script>
<mx:VBox paddingBottom="0"
paddingLeft="0"
paddingTop="0"
paddingRight="0"
id="alertBox"
width="100%"
height="100%">
<view:AlertingActionBar id="alertBar"
view="{view}"
section="{this}"/>
<view:AlertingTable id="alerts"
dataProvider="{view}"
selectionChange="alertsSelectionChange(event)"/>
</mx:VBox>
<mx:VBox paddingBottom="0"
paddingLeft="0"
paddingTop="0"
paddingRight="0"
id="logsBox"
visible="{alerts.selectedItem!=null}"
includeInLayout="{alerts.selectedItem!=null}"
width="100%"
height="100%"
show="onLogsShow()"
hide="onLogsHide()">
<view:LogsActionBar id="logBar"
section="{this}"
view="{logs.dataProvider as ArrayCollection}"
selectedObjects="{logs.selectedItems}"
selectedIndices="{logs.selectedIndices}"/>
<view:LogsTable id="logs"
selectionChange="logsSelectionChange(event)"/>
</mx:VBox>
</main:Section>