src/it/ht/rcs/console/operations/view/evidences/EvidenceExport.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="450" height="100%"
close="closeMe(event)" title="{R.get('EVIDENCE_EXPORT')}"
creationComplete="init()"
xmlns:view="it.ht.rcs.console.utils.*"
xmlns:filters="it.ht.rcs.console.operations.view.evidences.filters.*" xmlns:skin="com.flexpad.skin.*">
<fx:Script>
<![CDATA[
import it.ht.rcs.console.agent.model.Agent;
import it.ht.rcs.console.events.SessionEvent;
import it.ht.rcs.console.evidence.controller.EvidenceManager;
import it.ht.rcs.console.operations.view.evidences.filters.TypeFilterPopup;
import it.ht.rcs.console.target.model.Target;
import it.ht.rcs.console.task.controller.DownloadManager;
import it.ht.rcs.console.utils.AlertPopUp;
import it.ht.rcs.console.utils.Clock;
import it.ht.rcs.console.utils.TimeUtils;
import locale.R;
import mx.core.FlexGlobals;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ArrayUtil;
public var target:Target
public var agent:Agent;
protected function closeMe(event:*):void
{
PopUpManager.removePopUp(this);
}
private function init():void
{
FlexGlobals.topLevelApplication.addEventListener(SessionEvent.LOGOUT, closeMe);
var today:int = new Date().time/1000;
setFromTimestamp(today - 86400);
setToTimestamp(today);
exportname.text = defaultName();
}
private function adjust():void
{
var fromTS:int = getFromTimestamp();
var toTS:int = getToTimestamp();
if (fromTS > toTS)
setToTimestamp(fromTS);
}
private function getFromTimestamp():int
{
from.selectedDate.hours = fromH.value;
from.selectedDate.minutes = fromM.value;
return Clock.instance.toUTCTime(from.selectedDate) / 1000;
}
private function getToTimestamp():int
{
to.selectedDate.hours = toH.value;
to.selectedDate.minutes = toM.value;
return Clock.instance.toUTCTime(to.selectedDate) / 1000;
}
private function setFromTimestamp(ts:int):void
{
var fromDate:Date = Clock.instance.toConsoleDate(new Date(ts * 1000));
from.selectedDate = fromDate;
fromH.value = fromDate.hours;
fromM.value = fromDate.minutes;
}
private function setToTimestamp(ts:int):void
{
var toDate:Date = Clock.instance.toConsoleDate(new Date(ts * 1000));
to.selectedDate = toDate;
toH.value = toDate.hours;
toM.value = toDate.minutes;
}
private function pad(n:Number):String
{
return TimeUtils.zeroPad(n, 2);
}
private function getTags():Array
{
var toReturn:Array = [];
if (none.selected)
toReturn.push(0);
if (low.selected)
toReturn.push(1);
if (medium.selected)
toReturn.push(2);
if (high.selected)
toReturn.push(3);
if (critical.selected)
toReturn.push(4);
return toReturn;
}
protected function export(event:MouseEvent):void
{
var filter:Object = {};
filter.from = getFromTimestamp();
filter.to = getToTimestamp();
filter.rel = getTags();
filter.date = (date_da.selected == true) ? 'da' : 'dr'
if(filtered_rb.selected)
{
filter.type=[]
for(var i:int=0;i<types.checks.length;i++)
{
if(types.checks[i].selected)
filter.type.push(types.checks[i].id);
}
}
else
{
//filter.type=null
}
filter.blo = [blotter.selected];
filter.target = target._id;
if (agent != null) {
filter.agent = agent._id;
}
DownloadManager.instance.createTask(event.currentTarget.label==R.get('EXPORT_CONNECTOR')?"connector":"evidence", exportname.text, {note: note.selected, filter: filter}); //check for license
PopUpManager.removePopUp(this);
}
private function defaultName():String
{
var export_file:String = '';
if (target != null)
export_file += target.name
if (agent != null)
export_file += " - " + agent.name
export_file += " - " + "Evidence Export";
return export_file;
}
private function cancel():void
{
closeMe(null);
}
private function filterTypes():void
{
popup.displayPopUp=true
}
]]>
</fx:Script>
<fx:Declarations>
<s:RadioButtonGroup id="date"/>
<s:RadioButtonGroup id="filter"/>
</fx:Declarations>
<s:VGroup left="15" top="15" horizontalAlign="center" paddingBottom="15">
<s:HGroup>
<s:VGroup>
<s:HGroup verticalAlign="middle">
<s:Label width="40" text="{R.get('FROM')}" fontWeight="bold"/>
<mx:DateField id="from" width="120" change="adjust()" formatString="YYYY-MM-DD" showToday="false" yearNavigationEnabled="true"/>
<s:NumericStepper id="fromH" change="adjust()" maximum="23" minimum="0" value="0" valueFormatFunction="pad"/>
<s:Label text=":"/>
<s:NumericStepper id="fromM" change="adjust()" maximum="59" minimum="0" value="0" valueFormatFunction="pad"/>
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:Label width="40" text="{R.get('TO')}" fontWeight="bold"/>
<mx:DateField id="to" width="120" change="adjust()" formatString="YYYY-MM-DD" showToday="false" yearNavigationEnabled="true"/>
<s:NumericStepper id="toH" change="adjust()" maximum="23" minimum="0" value="23" valueFormatFunction="pad"/>
<s:Label text=":"/>
<s:NumericStepper id="toM" change="adjust()" maximum="59" minimum="0" value="59" valueFormatFunction="pad"/>
</s:HGroup>
</s:VGroup>
<s:Spacer width="10"/>
<s:VGroup verticalAlign="middle">
<s:RadioButton id="date_da" label="{R.get('DATE_ACQUIRED')}" selected="true" group="{date}"/>
<s:RadioButton id="date_dr" label="{R.get('DATE_RECEIVED')}" group="{date}"/>
</s:VGroup>
</s:HGroup>
<s:HGroup paddingTop="10" gap="10" >
<s:VGroup horizontalAlign="left" height="100%">
<s:Label text="{R.get('RELEVANCE')}:" fontWeight="bold"/>
<s:VGroup paddingLeft="0" width="135">
<s:HGroup width="100%">
<s:CheckBox id="critical" label="{R.get('CRITICAL')}" selected="true" width="63"/>
<view:TagImage value="4"/>
</s:HGroup>
<s:HGroup width="100%">
<s:CheckBox id="high" label="{R.get('HIGH')}" selected="true" width="63"/>
<view:TagImage value="3"/>
</s:HGroup>
<s:HGroup width="100%">
<s:CheckBox id="medium" label="{R.get('MEDIUM')}" selected="true" width="63"/>
<view:TagImage value="2"/>
</s:HGroup>
<s:HGroup width="100%">
<s:CheckBox id="low" label="{R.get('LOW')}" selected="true" width="63"/>
<view:TagImage value="1"/>
</s:HGroup>
<s:HGroup width="100%">
<s:CheckBox id="none" label="{R.get('UNTAGGED')}" selected="true" width="80"/>
<view:TagImage value="0"/>
</s:HGroup>
</s:VGroup>
</s:VGroup>
<s:VGroup height="100%">
<s:Label text="{R.get('TYPE')}:" fontWeight="bold"/>
<s:VGroup width="100%" >
<s:RadioButton id="all_rb" label="{R.get('ALL')}" selected="true" group="{filter}"/>
<s:RadioButton id="filtered_rb" label="{R.get('FILTERED')}" group="{filter}" click="filterTypes()"/>
<s:PopUpAnchor id="popup">
<s:BorderContainer backgroundAlpha=".90" backgroundColor="#333333" width="140" height="140" right="10" bottom="10" mouseDownOutside="{popup.displayPopUp=false}">
<s:Scroller width="100%" height="100%">
<filters:ExportTypeFilterPopup height="130" id="types"/>
</s:Scroller>
</s:BorderContainer>
</s:PopUpAnchor>
</s:VGroup>
</s:VGroup>
<s:VGroup height="100%">
<s:Label text="{R.get('REPORT')}:" fontWeight="bold"/>
<s:VGroup paddingLeft="0" width="135" height="100%">
<s:HGroup verticalAlign="top">
<s:CheckBox id="blotter"/>
<s:Label text="{R.get('REPORT_INCLUDED')}" width="100" />
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:CheckBox id="note" selected="true"/>
<s:Label text="{R.get('NOTE_INCLUDED')}" width="100" />
</s:HGroup>
</s:VGroup>
</s:VGroup>
</s:HGroup>
<s:Spacer height="20" />
<s:HGroup horizontalAlign="right" width="100%">
<s:HGroup verticalAlign="middle" width="100%" horizontalAlign="left">
<s:Label text="{R.get('REPORT_NAME')}:" fontWeight="bold"/>
<s:TextInput id="exportname" width="100%"/>
</s:HGroup>
<s:Spacer height="20"/>
</s:HGroup>
<s:HGroup verticalAlign="middle" width="100%" horizontalAlign="center" paddingTop="10">
<s:Button label="{R.get('EXPORT_FILE')}" click="export(event)"/>
<s:Button label="{R.get('EXPORT_CONNECTOR')}" click="export(event)"/>
<s:Button label="{R.get('CANCEL')}" click="cancel()"/>
</s:HGroup>
</s:VGroup>
</s:TitleWindow>