hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/entities/view/EntitySheet.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer 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:components="it.ht.rcs.console.entities.view.components.*"
                                     xmlns:maps="it.ht.rcs.console.maps.*"
                                     height="100%"
                                     width="100%"
                                     borderColor="0xCCCCCC"
                                     backgroundColor="0xFFFFFF"
                                     backgroundAlpha="1"
                                     addedToStage="onAddedToStage()"
                                     removedFromStage="onRemovedFromStage()">
    <fx:Declarations>
        <s:Fade id="fadeIn"
                        alphaFrom="0"
                        alphaTo="1"
                        duration="150"/>
        <s:Fade id="fadeOut"
                        alphaFrom="1"
                        alphaTo="0"
                        duration="150"/>

    </fx:Declarations>
    <fx:Metadata>
    [Event(name="update", type="flash.events.Event")]
    
  </fx:Metadata>
    <fx:Script>
        <![CDATA[
            import it.ht.rcs.console.DB;
            import it.ht.rcs.console.accounting.controller.SessionManager;
            import it.ht.rcs.console.controller.Sort;
            import it.ht.rcs.console.entities.controller.EntityManager;
            import it.ht.rcs.console.entities.model.Contact;
            import it.ht.rcs.console.entities.model.Entity;
            import it.ht.rcs.console.entities.model.Place;
            import it.ht.rcs.console.entities.model.Visit;
            import it.ht.rcs.console.entities.view.map.LastPositionMarker;
            import it.ht.rcs.console.entities.view.map.PlaceMarker;
            import it.ht.rcs.console.events.RefreshEvent;
            import it.ht.rcs.console.events.SectionEvent;
            import it.ht.rcs.console.monitor.controller.LicenseManager;
            import it.ht.rcs.console.push.PushController;
            import it.ht.rcs.console.push.PushEvent;
            import it.ht.rcs.console.search.controller.SearchManager;
            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.collections.ArrayCollection;
            import mx.core.FlexGlobals;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;

            import spark.collections.SortField;
            import spark.events.IndexChangeEvent;

            [Bindable]
            private var accounts:ArrayCollection;

            [Bindable]
            private var contacts:ArrayCollection;

            [Bindable]
            private var locations:ArrayCollection;

            [Bindable]
            private var mostContacted:ArrayCollection;

            [Bindable]
            private var mostVisitedUrls:ArrayCollection;

            [Bindable]
            private var mostVisitedPlaces:ArrayCollection;

            private var placeIndex:int=0;
            private var numPlaces:int=0;





            [Embed(source='/img/stub/fakeprofile.jpg')]
            [Bindable]
            private var FakeProfile:Class;

            [Embed(source="img/stub/map.png")]
            [Bindable]
            public var fakeMap:Class;

            [Embed(source="img/evidence/mapMarker.png")]
            [Bindable]
            public var redMarker:Class;

            [Embed(source="img/evidence/mapMarkerBlu.png")]
            [Bindable]
            public var bluMarker:Class;

            public var fileReference:FileReference;

            private const MILLISECONDS_PER_DAY:int=86400000;
            private const MONTH:int=MILLISECONDS_PER_DAY * 30;

            [Bindable]
            public var section:EntitiesSection;

            [Bindable]
            public var entity:Entity;

            [Bindable]
            private var fromDate:Date;

            [Bindable]
            private var limit:String="5";

            [Bindable]
            private var toDate:Date;

            private function init():void
            {
                this.visible=false;
                FlexGlobals.topLevelApplication.addEventListener(RefreshEvent.REFRESH, onRefresh);

                mostContacted=new ArrayCollection();
                mostVisitedPlaces=new ArrayCollection()
                fromDate=new Date();
                fromDate.time=fromDate.time - (1000 * 60 * 60 * 24 * 30);
                toDate=new Date();
                if (fromDf)
                {
                    fromDf.selectedDate=fromDate;
                }

                EntityManager.instance.show(entity._id, onDetailResult);

                if (loadingBox)
                    loadingBox.visible=loadingBox.includeInLayout=false;
                if (LicenseManager.instance.profiling)
                {
                    if (loadingBox)
                    {
                        loadingBox.visible=loadingBox.includeInLayout=true;
                    }
                    limit="5";
                    if (limitTxt)
                        limitTxt.text="5";

                    EntityManager.instance.mostContacted(entity._id, formatDate(fromDate), formatDate(toDate), limit, onContactResult, onContactFault);
                    EntityManager.instance.mostVisitedUrls(entity._id, formatDate(fromDate), formatDate(toDate), limit, onUrlsResult, onUrlsFault);
                    if (entity.type == "target")
                    {
                        locations=new ArrayCollection()
                        EntityManager.instance.mostVisitedPlaces(entity._id, formatDate(fromDate), formatDate(toDate), limit, onPlacesResult, onPlacesFault);
                    }
                }
                else
                {
                    if (contactsList)
                    {
                        contactsList.enabled=false; //TODO ADD A MESSAGE
                    }

                    if (loadingBox)
                        loadingBox.visible=loadingBox.includeInLayout=false;

                    if (visitedList)
                        visitedList.enabled=false; //TODO ADD A MESSAGE
                    if (loadingBox2)
                        loadingBox2.visible=loadingBox.includeInLayout=false;
                }
                locations=new ArrayCollection()
                callLater(onRefresh, [null])

            }

            private function filter(e:Event):void
            {
                if (e.currentTarget == limitTxt)
                {
                    limit=limitTxt.text;
                }


                if (e.currentTarget == visitLimitTxt)
                {
                    limit=visitLimitTxt.text;
                }
                fromDate=fromDf.selectedDate;
                toDate=toDf.selectedDate;
                loadingBox.visible=loadingBox.includeInLayout=true;
                EntityManager.instance.mostContacted(entity._id, formatDate(fromDate), formatDate(toDate), limit, onContactResult, onContactFault);
                EntityManager.instance.mostVisitedUrls(entity._id, formatDate(fromDate), formatDate(toDate), limit, onUrlsResult, onUrlsFault);
                if (entity.type == "target")
                    locations=new ArrayCollection()
                EntityManager.instance.mostVisitedPlaces(entity._id, formatDate(fromDate), formatDate(toDate), limit, onPlacesResult, onPlacesFault);
            }


            private function getFromTimestamp():int
            {
                fromDf.selectedDate.hours=0;
                fromDf.selectedDate.minutes=0;
                return Clock.instance.toUTCTime(fromDf.selectedDate) / 1000;
            }

            private function getToTimestamp():int
            {
                toDf.selectedDate.hours=23;
                toDf.selectedDate.minutes=59;
                toDf.selectedDate.seconds=59;
                return Clock.instance.toUTCTime(toDf.selectedDate) / 1000;
            }

            private function doubleDigits(n:Number):String
            {
                if (n < 10)
                    return "0" + String(n);
                return String(n);
            }

            private function formatDate(d:Date):String
            {
                return String(d.fullYear) + doubleDigits(d.month + 1) + doubleDigits(d.date);
            }

            private function onMapReady(event:Event):void
            {

            }

            public function onEdit():void
            {
                // mapViewer.getSnapshot();
            }


            public function onPopupClose():void
            {
                //mapViewer.webView.snapShotVisible=false;
            }

            private function onUpdate(e:Event):void
            {
                EntityManager.instance.show(entity._id, onDetailResult)
            }


            protected function onAddedToStage():void
            {
                PushController.instance.addEventListener(PushEvent.ENTITY, onEntityPush)
                init()
            }

            protected function onRemovedFromStage():void
            {

                PushController.instance.removeEventListener(PushEvent.ENTITY, onEntityPush)
                //photoViewer.currentPhoto="";
                //entity=null;
                lastPosCh.selected=true;
                mostVisitedCh.selected=true;
                FlexGlobals.topLevelApplication.removeEventListener(RefreshEvent.REFRESH, onRefresh);

            }

            private function onEntityPush(e:PushEvent):void
            {
                trace("entity push")

                if (e.data.action == PushEvent.MODIFY && entity._id == e.data.id)
                {
                    for (var property:String in e.data.changes)
                    {
                        entity[property]=e.data.changes[property];
                    }
                }

            }

            private function onContactResult(e:ResultEvent):void
            {
                if (contactsList)
                    contactsList.addEventListener("entityAdd", addContactAsEntity)
                mostContacted=new ArrayCollection();
                var temp:ArrayCollection=e.result as ArrayCollection;
                for (var i:int=0; i < temp.length; i++)
                {
                    var arr:Array=temp.getItemAt(i) as Array;
                    for (var k:int=0; k < arr.length; k++)
                    {
                        var item:Contact=arr[k] as Contact;
                        mostContacted.addItem(item);
                    }

                }
                if (loadingBox)
                    loadingBox.visible=loadingBox.includeInLayout=false;
                if (contactsList)
                    contactsList.dataProvider=mostContacted;
            }

            private function onContactFault(e:FaultEvent):void
            {
                trace("fault callback most contacted call");
                loadingBox.visible=loadingBox.includeInLayout=false;
            }

            private function onUrlsResult(e:ResultEvent):void
            {


                mostVisitedUrls=e.result as ArrayCollection;

                if (loadingBox2)
                    loadingBox2.visible=loadingBox2.includeInLayout=false;
                if (visitedList)
                {
                    visitedList.dataProvider=mostVisitedUrls;
                    visitedList.addEventListener("entityAdd", addURLAsEntity);
                }
            }

            private function onPlacesResult(e:ResultEvent):void
            {
                trace("most visited places result") // e.result as ArrayCollection;
                mostVisitedPlaces=new ArrayCollection()
                for (var i:int=0; i < e.result.length; i++)
                {
                    mostVisitedPlaces.addItem({place: e.result.getItemAt(i)})
                }
                placeIndex=0;
                numPlaces=mostVisitedPlaces.length;

                if (numPlaces > 0)
                {
                    mapViewer.codeLatLng(mostVisitedPlaces.getItemAt(0).place.position.getItemAt(1), mostVisitedPlaces.getItemAt(0).place.position.getItemAt(0))
                }
                else
                {
                    drawPosition()
                }

            }

            public function drawPosition():void
            {
                if (!mapViewer)
                    return;
                if (LicenseManager.instance.profiling)
                {
                    mapViewer.positions=new Vector.<Object>();
                    if (entity && entity.position)
                    {

                        if (entity.position.latitude && entity.position.longitude && lastPosCh.selected)
                        {
                            mapViewer.positions.push(entity);
                            //text
                            if (entity.type == 'target')
                                lastPositionTxt.text=R.get('LAST_KNOWN_POSITION') + " (" + TimeUtils.timestampFormatter(entity.position_attr.time * 1000) + "): \n- " + R.get('LATITUDE') + ": " + entity.position.latitude + " - " + R.get('LONGITUDE') + ": " + entity.position.longitude + " - " + R.get('ACCURACY') + ": " + entity.position_attr.accuracy + " mt";
                            else if (entity.type == 'position')
                                lastPositionTxt.text=R.get('LATITUDE') + ": " + entity.position.latitude + " - " + R.get('LONGITUDE') + ": " + entity.position.longitude + " - " + R.get('ACCURACY') + ": " + entity.position_attr.accuracy + " mt";
                            else
                                lastPositionTxt.text="";
                        }

                        else
                        {
                            if (entity && entity.type == 'target')
                                lastPositionTxt.text="";
                                //map.setZoom(1);
                        }
                    }
                    else
                    {
                        if (entity && entity.type == 'target')
                            lastPositionTxt.text=R.get('LAST_POSITION_UNKNOWN');
                        else
                            lastPositionTxt.text="";
                            //map.setZoom(1)
                    }

                    //draw visited places
                    if (mostVisitedPlaces && mostVisitedPlaces.length > 0 && mostVisitedCh.selected)
                    {
                        for (var p:int=0; p < mostVisitedPlaces.length; p++)
                        {
                            var place:Object=mostVisitedPlaces.getItemAt(p);
                            mapViewer.positions.push(place.place)
                        }
                    }
                }

                else
                {
                    lastPositionTxt.text=R.get('LAST_KNOWN_POSITION') + "\n(Feature not included in current License)"
                }

                mapViewer.update()

            }

            private function onUrlsFault(e:FaultEvent):void
            {
                trace("fault callback most visited call")
                loadingBox2.visible=loadingBox2.includeInLayout=false;
            }

            private function onPlacesFault(e:FaultEvent):void
            {
                trace("fault callback most visited places call")
            }

            private function onDetailFault(e:FaultEvent):void
            {
                trace("fault callback entity show call")
            }

            private function onRefresh(e:Event=null):void
            {
                if (entity)
                {
                    //  TODO REDUNDANT
                    mostContacted=new ArrayCollection();
                    mostVisitedUrls=new ArrayCollection()


                    EntityManager.instance.show(entity._id, onDetailResult);
                    if (loadingBox)
                        loadingBox.visible=loadingBox.includeInLayout=false;
                    if (LicenseManager.instance.profiling && entity.type == 'target')
                    {
                        if (loadingBox)
                            loadingBox.visible=loadingBox.includeInLayout=true;
                        if (loadingBox2)
                            loadingBox2.visible=loadingBox.includeInLayout=true;
                        EntityManager.instance.mostContacted(entity._id, formatDate(fromDate), formatDate(toDate), limit, onContactResult, onContactFault);
                        EntityManager.instance.mostVisitedUrls(entity._id, formatDate(fromDate), formatDate(toDate), limit, onUrlsResult, onUrlsFault);
                    }
                    else
                    {
                        contactsList.enabled=false;
                        visitedList.enabled=false;
                    }
                }
            }


            private function onDetailResult(e:ResultEvent):void
            {

                entity=e.result as Entity;
                if (nameTxt)
                    nameTxt.text=entity.name;
                if (descTxt)
                    descTxt.text=entity.desc;
                if (photoViewer)
                    photoViewer.currentIndex=0;

                if (entity.photos)
                {
                    if (entity.photos.length > 0)
                    {
                        if (photoViewer)
                            photoViewer.currentPhoto=entity.photos[photoViewer.currentIndex];
                    }
                    else
                    {
                        if (photoViewer)
                            photoViewer.currentPhoto="";
                    }
                }
                else
                {
                    if (photoViewer)
                        photoViewer.currentPhoto="";
                }
                if (handlesList)
                {
                    //sort
                    var dataSortField:SortField=new SortField();
                    dataSortField.name="type";

                    var sort:Sort=new Sort();
                    sort.fields=[dataSortField];
                    if (entity.handles)
                    {
                        entity.handles.sort=sort;
                        entity.handles.refresh();
                    }
                    handlesList.dataProvider=entity.handles;
                }


                //if (mapReady)
                drawPosition();

                this.visible=true;
                //dispatchEvent(new Event("update"));
            }

            private function addHandle():void
            {
                var popup:HandleForm=PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, HandleForm, true) as HandleForm;
                popup.entity=entity;
                popup.addEventListener("update", onUpdate);
                PopUpManager.centerPopUp(popup);
            }

            private function onRemoveHandle():void
            {
                AlertPopUp.show(entity.type == 'virtual' ? R.get('CONFIRM_URL_DELETION') : R.get('CONFIRM_HANDLE_DELETION'), R.get('CONFIRM'), AlertPopUp.YES | AlertPopUp.NO, null, function(e:CloseEvent):void
                {
                    if (e.detail == AlertPopUp.YES)
                        EntityManager.instance.deleteHandle(entity._id, handlesList.selectedItem._id, onUpdate)
                }, null, AlertPopUp.NO);
            }

            private function jumpToEvidence(e:Event):void
            {
                if (contactsList.selectedItem)
                {
                    var item:Contact=contactsList.selectedItem as Contact;

                    var event:SectionEvent=new SectionEvent(SectionEvent.CHANGE_SECTION);
                    event.section=SectionEvent.OPERATIONS;
                    event.subsection='evidence';

                    var targetId:String=entity.path[entity.path.length - 1];
                    event.item=SearchManager.instance.getItem(targetId);
                    event.evidenceTypes=["call", "chat", "message"];
                    event.info=[item.peer + " " + item.type];
                    event.from=getFromTimestamp();
                    event.to=getToTimestamp();
                    FlexGlobals.topLevelApplication.dispatchEvent(event);
                }

            }

            private function onEntityAdded(e:Event):void
            {
                var popup:EntityForm=e.currentTarget as EntityForm;
                var entity:Entity=popup.entity;
                var visit:Visit=visitedList.selectedItem as Visit;
                EntityManager.instance.addHandle(entity._id, visit.host, visit.host, "url");
            }

            private function addContactAsEntity(e:Event):void
            {
                var popup:EntityForm=PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, EntityForm, true) as EntityForm;
                popup.operation=section.stateManager.selectedOperation;
                popup.entity=new Entity(Entity.defaultEntity());
                popup.addEventListener(EntityForm.CLOSE, onEntityAdded)
                if (contactsList.selectedItem.peer_name != null)
                    popup.entity.name=contactsList.selectedItem.peer_name;
                popup.type.enabled=false;
                popup.currentState=EntityForm.CREATE;
                PopUpManager.centerPopUp(popup);
            }

            private function addURLAsEntity(e:Event):void
            {
                var popup:EntityForm=PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, EntityForm, true) as EntityForm;
                popup.operation=section.stateManager.selectedOperation;
                popup.entity=new Entity(Entity.defaultEntity());
                popup.addEventListener(EntityForm.CLOSE, onEntityAdded)
                if (visitedList.selectedItem.host != null)
                    popup.entity.name=visitedList.selectedItem.host;
                popup.type.enabled=false;
                popup.type.selectedIndex=2;
                popup.currentState=EntityForm.CREATE;
                PopUpManager.centerPopUp(popup);
            }

            public function update():void
            {
                onUpdate(null)
            }

            protected function onGeoCodeResult(event:ResultEvent):void
            {
                trace("Address: " + event.result[0].formatted_address);


                mostVisitedPlaces.getItemAt(placeIndex).address=event.result[0].formatted_address
                locations.addItem({name: event.result[0].formatted_address, index: placeIndex})
                if (placeIndex < numPlaces - 1)
                {
                    placeIndex++

                    mapViewer.codeLatLng(mostVisitedPlaces.getItemAt(placeIndex).place.position.getItemAt(1), mostVisitedPlaces.getItemAt(placeIndex).place.position.getItemAt(0))

                }
                else
                {
                    ///("no more places to solve")
                    drawPosition()
                }

                mostVisitedList.dataProvider=locations;

            }

            protected function onPlaceSelection():void
            {
                trace(mostVisitedList.selectedItem.index)
                mapViewer.selectByIndex(mostVisitedList.selectedItem.index)

            }

            private function onMapChange():void
            {
                trace(mapViewer.selectedIndex);
                mostVisitedList.selectedIndex=mapViewer.selectedIndex;
                mostVisitedList.ensureIndexIsVisible(mostVisitedList.selectedIndex)

            }
        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout paddingBottom="10"
                                            paddingLeft="10"
                                            paddingRight="10"
                                            paddingTop="10"
                                            gap="6"/>
    </s:layout>
    <s:VGroup width="100%">
        <s:HGroup width="100%">
            <s:RichText fontFamily="Myriad"
                                    fontSize="20"
                                    fontWeight="bold"
                                    paddingTop="2"
                                    text="{entity.name}"
                                    id="nameTxt"/>

            <s:Spacer width="100%"/>
            <s:HGroup verticalAlign="middle"
                                horizontalAlign="right"
                                width="100%"
                                visible="{entity.type=='target'}">
                <s:Label text="{R.get('FILTER_DATA')} "
                                 fontWeight="bold"
                                 alpha="{LicenseManager.instance.profiling? 1:0.5}"/>
                <s:Label text="{R.get('FROM')}:"
                                 fontWeight="bold"
                                 alpha="{LicenseManager.instance.profiling? 1:0.5}"/>
                <mx:DateField id="fromDf"
                                            selectedDate="{fromDate}"
                                            change="filter(event)"
                                            formatString="YYYY-MM-DD"
                                            enabled="{LicenseManager.instance.profiling}"/>
                <s:Label text="{R.get('TO')}:"
                                 fontWeight="bold"
                                 alpha="{LicenseManager.instance.profiling? 1:0.5}"/>
                <mx:DateField id="toDf"
                                            selectedDate="{toDate}"
                                            change="filter(event)"
                                            formatString="YYYY-MM-DD"
                                            enabled="{LicenseManager.instance.profiling}"/>
            </s:HGroup>
        </s:HGroup>

        <s:Line width="100%">
            <s:stroke>
                <s:SolidColorStroke color="0xCCCCCC"/>
            </s:stroke>
        </s:Line>
    </s:VGroup>
    <s:HGroup width="100%"
                        height="100%">
        <s:VGroup height="100%">
            <s:VGroup width="100%"
                                visible="{entity.desc!='' &amp;&amp; entity.desc!=null}"
                                includeInLayout="{entity.desc!='' &amp;&amp; entity.desc!=null}">

                <s:RichText id="descTxt"
                                        text="{entity.desc}"
                                        width="100%"/>
                <s:Line width="100%">
                    <s:stroke>
                        <s:SolidColorStroke color="0xCCCCCC"
                                                                alpha="0"/>
                    </s:stroke>
                </s:Line>
            </s:VGroup>
            <s:HGroup width="100%"
                                height="50%">
                <components:PhotoViewer id="photoViewer"
                                                                entity="{entity}"
                                                                update="onUpdate(event)"/>
                <s:VGroup gap="0"
                                    width="100%"
                                    height="100%"
                                    visible="{entity.type!='position'}"
                                    includeInLayout="{entity.type!='position'}"
                                    paddingBottom="0">
                    <!-- <s:Label text="Accounts:"
                                        fontWeight="bold"/>-->
                    <s:List width="380"
                                    height="100%"
                                    itemRenderer="it.ht.rcs.console.entities.view.renderers.HandleListRenderer"
                                    dataProvider="{entity.handles}"
                                    id="handlesList"/>
                    <s:HGroup gap="-1"
                                        horizontalAlign="right"
                                        width="100%">

                        <s:Button width="30"
                                            label="-"
                                            cornerRadius="0"
                                            enabled="{handlesList.selectedItem!=null  &amp;&amp; Console.currentSession.user.is_view_profiles()}"
                                            visible="{entity.handles!=null &amp;&amp; entity.handles.length>0}"
                                            toolTip="{R.get('REMOVE_HANDLE')}"
                                            click="onRemoveHandle()"/>
                        <s:Button width="30"
                                            label="+"
                                            cornerRadius="0"
                                            toolTip="{R.get('ADD_HANDLE')}"
                                            enabled="{Console.currentSession.user.is_view_profiles()}"
                                            click="addHandle()"/>
                    </s:HGroup>

                </s:VGroup>
            </s:HGroup>
            <s:Spacer height="20"/>
            <!-- -->
            <s:VGroup gap="-1"
                                paddingBottom="0"
                                paddingTop="0"
                                paddingLeft="0"
                                paddingRight="0"
                                width="100%"
                                height="100%"
                                visible="{entity.type=='target'}"
                                includeInLayout="{entity.type=='target'}">

                <s:HGroup horizontalAlign="right"
                                    width="100%"
                                    paddingBottom="0"
                                    depth="1">
                    <s:TabBar id="tabs"
                                        dataProvider="{vs}"
                                        fontWeight="bold"/>
                </s:HGroup>

                <mx:ViewStack width="100%"
                                            height="100%"
                                            id="vs"
                                            creationPolicy="all">


                    <s:NavigatorContent width="100%"
                                                            height="100%"
                                                            label="{R.get('MOST_CONTACTED')}"
                                                            creationPolicy="all">

                        <s:BorderContainer width="100%"
                                                             height="100%">
                            <s:layout>
                                <s:VerticalLayout paddingBottom="6"
                                                                    paddingLeft="6"
                                                                    paddingRight="6"
                                                                    paddingTop="6"/>
                            </s:layout>
                            <s:HGroup width="100%"
                                                verticalAlign="middle"
                                                visible="{entity.type=='target'}"
                                                includeInLayout="{entity.type=='target'}">
                                <s:TextInput id="limitTxt"
                                                         text="{limit}"
                                                         restrict="[0-9]"
                                                         width="24"
                                                         enter="filter(event)"
                                                         borderAlpha="0"
                                                         fontWeight="bold"
                                                         enabled="{LicenseManager.instance.profiling}"/>

                                <s:Label text="{R.get('MOST_CONTACTED')}"
                                                 fontWeight="bold"
                                                 alpha="{LicenseManager.instance.profiling? 1:0.5}"/>
                                <s:Label text=" (Feature not included in current License)"
                                                 visible="{!LicenseManager.instance.profiling}"
                                                 includeInLayout="{!LicenseManager.instance.profiling}"
                                                 fontWeight="bold"
                                                 alpha="0.5"/>
                                <s:Spacer width="100%"/>
                                <s:HGroup verticalAlign="middle"
                                                    id="loadingBox"
                                                    visible="{LicenseManager.instance.profiling}"
                                                    includeInLayout="{LicenseManager.instance.profiling}">

                                    <s:SWFLoader source="@Embed('/img/evidence/spinner16.swf')"/>
                                    <s:Label text="Retrieving data..."
                                                     fontWeight="bold"/>
                                </s:HGroup>

                            </s:HGroup>
                            <s:List width="100%"
                                            height="100%"
                                            id="contactsList"
                                            enabled="{LicenseManager.instance.profiling &amp;&amp; entity.type=='target'}"
                                            itemRenderer="it.ht.rcs.console.entities.view.renderers.ContactListRenderer"
                                            dataProvider="{mostContacted}"
                                            doubleClickEnabled="true"
                                            doubleClick="jumpToEvidence(event)"
                                            visible="{entity.type=='target'}"
                                            includeInLayout="{entity.type=='target'}"
                                            borderAlpha="0.3"/>
                        </s:BorderContainer>
                    </s:NavigatorContent>
                    <s:NavigatorContent width="100%"
                                                            height="100%"
                                                            label="{R.get('MOST_VISITED')}"
                                                            creationPolicy="all">
                        <s:BorderContainer width="100%"
                                                             height="100%">
                            <s:layout>
                                <s:VerticalLayout paddingBottom="6"
                                                                    paddingLeft="6"
                                                                    paddingRight="6"
                                                                    paddingTop="6"/>
                            </s:layout>
                            <s:HGroup width="100%"
                                                verticalAlign="middle"
                                                visible="{entity.type=='target'}"
                                                includeInLayout="{entity.type=='target'}">
                                <s:TextInput id="visitLimitTxt"
                                                         text="{limit}"
                                                         restrict="[0-9]"
                                                         width="24"
                                                         enter="filter(event)"
                                                         borderAlpha="0"
                                                         fontWeight="bold"
                                                         enabled="{LicenseManager.instance.profiling}"/>

                                <s:Label text="{R.get('MOST_VISITED')}"
                                                 fontWeight="bold"
                                                 alpha="{LicenseManager.instance.profiling? 1:0.5}"/>
                                <s:Label text=" (Feature not included in current License)"
                                                 visible="{!LicenseManager.instance.profiling}"
                                                 includeInLayout="{!LicenseManager.instance.profiling}"
                                                 fontWeight="bold"
                                                 alpha="0.5"/>
                                <s:Spacer width="100%"/>
                                <s:HGroup verticalAlign="middle"
                                                    id="loadingBox2"
                                                    visible="{LicenseManager.instance.profiling}"
                                                    includeInLayout="{LicenseManager.instance.profiling}">

                                    <s:SWFLoader source="@Embed('/img/evidence/spinner16.swf')"/>
                                    <s:Label text="Retrieving data..."
                                                     fontWeight="bold"/>
                                </s:HGroup>
                                <!--  <s:Button label="{R.get('ENTITY_ADD_AS')}"
                                visible="{mostVisited!=null &amp;&amp; mostVisited.length>0}"
                                includeInLayout="{mostVisited!=null &amp;&amp; mostVisited.length>0}"
                                enabled="{visitedList.selectedItem!=null}"/>-->
                            </s:HGroup>
                            <s:List width="100%"
                                            height="100%"
                                            id="visitedList"
                                            enabled="{LicenseManager.instance.profiling &amp;&amp; entity.type=='target'}"
                                            itemRenderer="it.ht.rcs.console.entities.view.renderers.VisitedListRenderer"
                                            dataProvider="{mostVisitedUrls}"
                                            visible="{entity.type=='target'}"
                                            includeInLayout="{entity.type=='target'}"
                                            borderAlpha="0.3"/>
                        </s:BorderContainer>
                    </s:NavigatorContent>
                </mx:ViewStack>

            </s:VGroup>
        </s:VGroup>
        <s:Spacer width="6"/>
        <s:VGroup width="100%"
                            horizontalAlign="center"
                            height="100%">

            <s:BorderContainer width="100%"
                                                 height="100%"
                                                 borderAlpha="1"
                                                 borderColor="0x666666"
                                                 backgroundColor="0xCCCCCC"
                                                 backgroundAlpha="0.3">
                <s:layout>
                    <s:VerticalLayout paddingBottom="10"
                                                        paddingLeft="10"
                                                        paddingRight="10"
                                                        paddingTop="10"
                                                        gap="6"/>
                </s:layout>
                <s:HGroup width="100%"
                                    horizontalAlign="left">
                    <s:Label id="lastPositionTxt"
                                     alpha="{LicenseManager.instance.profiling? 1:0.5}"
                                     fontWeight="bold"
                                     width="100%"/>
                    <!--    <s:CheckBox label="Last Positions"/>
                        <s:Spacer width="10"/>
                        <s:CheckBox label="Addresses"/>
                        <s:Spacer width="10"/>
                        <s:CheckBox label="Visited Places"/>-->
                </s:HGroup>
                <s:VGroup paddingBottom="0"
                                    paddingTop="0"
                                    gap="0"
                                    width="100%"
                                    height="100%">

                    <s:BorderContainer width="100%"
                                                         height="100%"
                                                         borderAlpha="1"
                                                         borderColor="0x666666"
                                                         backgroundColor="0xCCCCCC"
                                                         backgroundAlpha="0.3">


                        <maps:MapViewer id="mapViewer"
                                                        change="onMapChange()"
                                                        geocodeResult="onGeoCodeResult(event)"
                                                        width="100%"
                                                        height="100%"/>
                        <!-- trick to disbale map -->
                        <s:BorderContainer width="100%"
                                                             height="100%"
                                                             borderAlpha="0"
                                                             backgroundColor="0xFFFFFF"
                                                             backgroundAlpha="0.5"
                                                             visible="{!LicenseManager.instance.profiling}"
                                                             includeInLayout="{!LicenseManager.instance.profiling}"/>
                        <s:BitmapImage source="{fakeMap}"
                                                     width="100%"
                                                     height="100%"
                                                     visible="{!SessionManager.instance.hasConnection &amp;&amp; DB.instance.demo}"
                                                     includeInLayout="{!SessionManager.instance.hasConnection &amp;&amp; DB.instance.demo}"/>
                    </s:BorderContainer>

                    <s:Spacer height="6"/>
                    <s:List width="100%"
                                    id="mostVisitedList"
                                    visible="{mostVisitedCh.selected &amp;&amp; entity.type=='target' &amp;&amp; locations.length>0}"
                                    includeInLayout="{mostVisitedCh.selected &amp;&amp; entity.type=='target' &amp;&amp; locations.length>0}"
                                    height="30%"
                                    dataProvider="{locations}"
                                    itemRenderer="it.ht.rcs.console.entities.view.renderers.AddressListRenderer"
                                    change="onPlaceSelection()"/>
                    <s:Spacer height="6"/>
                    <s:HGroup width="100%"
                                        verticalAlign="middle"
                                        visible="{entity.type=='target'}"
                                        includeInLayout="{entity.type=='target'}">

                        <s:Image source="{bluMarker}"/>
                        <s:CheckBox label="{R.get('LAST_KNOWN_POSITION')}"
                                                id="lastPosCh"
                                                selected="true"
                                                change="drawPosition()"
                                                enabled="{LicenseManager.instance.profiling}"/>
                        <s:Spacer width="50"/>
                        <s:Image source="{redMarker}"/>
                        <s:CheckBox label="{R.get('MOST_VISITED_PLACES')}"
                                                id="mostVisitedCh"
                                                selected="true"
                                                enabled="{LicenseManager.instance.profiling}"
                                                change="drawPosition()"/>
                    </s:HGroup>


                </s:VGroup>
            </s:BorderContainer>

        </s:VGroup>
    </s:HGroup>
</s:BorderContainer>