Skip to content

Commit

Permalink
Refactored MainViewMediator dataProvider and added administrator emai…
Browse files Browse the repository at this point in the history
…l in config.xml
  • Loading branch information
pedrobmarin committed Nov 13, 2014
1 parent 2aa08a5 commit fd9b8bb
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 44 deletions.
1 change: 1 addition & 0 deletions labs/bbb-client-check/resources/config.xml.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<admMail>[email protected]</admMail>
<downloadFilePath url="test_image.jpg"/>
<ports>
<port>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ package org.bigbluebutton.clientcheck
import org.bigbluebutton.clientcheck.command.RequestRTMPAppsSignal;
import org.bigbluebutton.clientcheck.model.ISystemConfiguration;
import org.bigbluebutton.clientcheck.model.IXMLConfig;
import org.bigbluebutton.clientcheck.model.IDataProvider;
import org.bigbluebutton.clientcheck.model.SystemConfiguration;
import org.bigbluebutton.clientcheck.model.XMLConfig;
import org.bigbluebutton.clientcheck.model.DataProvider;
import org.bigbluebutton.clientcheck.service.DownloadBandwidthService;
import org.bigbluebutton.clientcheck.service.ExternalApiCallbacks;
import org.bigbluebutton.clientcheck.service.ExternalApiCalls;
Expand Down Expand Up @@ -66,6 +68,7 @@ package org.bigbluebutton.clientcheck
{
injector.map(ISystemConfiguration).toSingleton(SystemConfiguration);
injector.map(IXMLConfig).toSingleton(XMLConfig);
injector.map(IDataProvider).toSingleton(DataProvider);
}

private function configureSignalsToCommands():void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.bigbluebutton.clientcheck.model
{
import mx.collections.ArrayCollection;

import spark.collections.Sort;
import spark.collections.SortField;

public class DataProvider implements IDataProvider
{
private var _dataProvider:ArrayCollection = new ArrayCollection;

public function addData(obj:Object):void
{
_dataProvider.addItem(obj);
}

public function getData():ArrayCollection
{
return _dataProvider;
}

private function sortData():void
{
var itemSortField:SortField = new SortField();
var statusSortField:SortField = new SortField();
itemSortField.name = "Item";
statusSortField.name = "Status";
var dataSort:Sort = new Sort();
dataSort.fields = [statusSortField, itemSortField];
_dataProvider.sort = dataSort;
_dataProvider.refresh();
}

public function updateData(obj:Object):void
{
var i:int = 0;

while (i < _dataProvider.length && _dataProvider.getItemAt(i).Item != obj.Item) i++;

if (_dataProvider.getItemAt(i).Item == obj.Item)
{
_dataProvider.removeItemAt(i);
_dataProvider.addItemAt(obj, i);
}
else trace("Something is missing at MainViewMediator's initDataProvider");

sortData();
}

public function getAllDataAsString():String {
var data:String="";

for (var i:int=0; i < _dataProvider.length; i++)
{
data += _dataProvider.getItemAt(i).Item + " : " + _dataProvider.getItemAt(i).Result + " : " + _dataProvider.getItemAt(i).Status + "\n";
}

return data;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.bigbluebutton.clientcheck.model
{
import mx.collections.ArrayCollection;

public interface IDataProvider
{
function addData(obj:Object):void;
function getData():ArrayCollection;
function updateData(obj:Object):void;
function getAllDataAsString():String;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ package org.bigbluebutton.clientcheck.model
function get serverUrl():Object;
function getPorts():XMLList;
function getRTMPApps():XMLList;
function getAdmMail():String;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ package org.bigbluebutton.clientcheck.model
{
return new XMLList(_config.rtmpapps).children();
}

public function getAdmMail():String
{
var admMail:String = _config.admMail;
return admMail;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package org.bigbluebutton.clientcheck.view.mainview
import org.bigbluebutton.clientcheck.command.RequestRTMPAppsSignal;
import org.bigbluebutton.clientcheck.model.ISystemConfiguration;
import org.bigbluebutton.clientcheck.model.IXMLConfig;
import org.bigbluebutton.clientcheck.model.IDataProvider;
import org.bigbluebutton.clientcheck.model.test.BrowserTest;
import org.bigbluebutton.clientcheck.model.test.CookieEnabledTest;
import org.bigbluebutton.clientcheck.model.test.DownloadBandwidthTest;
Expand Down Expand Up @@ -61,10 +62,12 @@ package org.bigbluebutton.clientcheck.view.mainview
[Inject]
public var config:IXMLConfig;

private var dataProvider:ArrayCollection=new ArrayCollection;
[Inject]
public var dp:IDataProvider;

private static var FAILED:String="Fail";
private static var SUCCEED:String="Succeed";
private static var LOADING:String="Loading..."

override public function initialize():void
{
Expand All @@ -81,8 +84,9 @@ package org.bigbluebutton.clientcheck.view.mainview
private function configParsedHandler():void
{
initPropertyListeners();
initDataProvider();

view.dataGrid.dataProvider=dataProvider;
view.dataGrid.dataProvider=dp.getData();

requestBrowserInfoSignal.dispatch();
requestRTMPAppsInfoSignal.dispatch();
Expand Down Expand Up @@ -118,6 +122,42 @@ package org.bigbluebutton.clientcheck.view.mainview
}
}

/**
* Gather all Item names even before it's tested
*/
private function initDataProvider():void
{
dp.addData({Item: BrowserTest.BROWSER, Result: null, Status: LOADING});
dp.addData({Item: CookieEnabledTest.COOKIE_ENABLED, Result: null, Status: LOADING});
dp.addData({Item: DownloadBandwidthTest.DOWNLOAD_SPEED, Result: null, Status: LOADING});
dp.addData({Item: FlashVersionTest.FLASH_VERSION, Result: null, Status: LOADING});
dp.addData({Item: IsPepperFlashTest.PEPPER_FLASH, Result: null, Status: LOADING});
dp.addData({Item: JavaEnabledTest.JAVA_ENABLED, Result: null, Status: LOADING});
dp.addData({Item: LanguageTest.LANGUAGE, Result: null, Status: LOADING});
dp.addData({Item: PingTest.PING, Result: null, Status: LOADING});
dp.addData({Item: ScreenSizeTest.SCREEN_SIZE, Result: null, Status: LOADING});
// The upload is not working right now
// dp.addData({Item: UploadBandwidthTest.UPLOAD_SPEED, Result: "This is supposed to be failing right now", Status: FAILED});
dp.addData({Item: UserAgentTest.USER_AGENT, Result: null, Status: LOADING});
dp.addData({Item: WebRTCEchoTest.WEBRTC_ECHO_TEST, Result: null, Status: LOADING});
dp.addData({Item: WebRTCSocketTest.WEBRTC_SOCKET_TEST, Result: null, Status: LOADING});
dp.addData({Item: WebRTCSupportedTest.WEBRTC_SUPPORTED, Result: null, Status: LOADING});
if (systemConfiguration.rtmpApps)
{
for (var i:int=0; i < systemConfiguration.rtmpApps.length; i++)
{
dp.addData({Item: systemConfiguration.rtmpApps[i].applicationName, Result: null, Status: LOADING});
}
}
if (systemConfiguration.ports)
{
for (var j:int=0; j < systemConfiguration.ports.length; j++)
{
dp.addData({Item: systemConfiguration.ports[j].portName, Result: null, Status: LOADING});
}
}
}

/**
* When RTMPApp item is getting updated we receive notification with 'applicationUri' of updated item
* We need to retrieve this item from the list of the available items and put it inside datagrid
Expand All @@ -132,40 +172,14 @@ package org.bigbluebutton.clientcheck.view.mainview
return null;
}

/**
* Check if item is already in datagrid, if yes update, otherwise add new item
**/
public function updateItemInDataProvider(obj:Object):void
{
var index:int=-1;

for (var i:int=0; i < dataProvider.length; i++)
{
if (dataProvider.getItemAt(i).Item == obj.Item)
{
index=i;
}
}

if (index != -1)
{
dataProvider.removeItemAt(index);
dataProvider.addItemAt(obj, index);
}
else
{
dataProvider.addItem(obj);
}
}

private function rtmpAppConnectionResultSuccessfullChangedHandler(applicationUri:String):void
{
var appObj:RTMPAppTest=getRTMPAppItemByURI(applicationUri);

if (appObj)
{
var obj:Object={Item: appObj.applicationName, Result: appObj.testResult, Status: ((appObj.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}
else
{
Expand All @@ -190,7 +204,7 @@ package org.bigbluebutton.clientcheck.view.mainview
if (portObj)
{
var obj:Object={Item: portObj.portName, Result: portObj.testResult, Status: ((portObj.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}
else
{
Expand All @@ -201,86 +215,86 @@ package org.bigbluebutton.clientcheck.view.mainview
private function pingSpeedTestChangedHandler():void
{
var obj:Object={Item: PingTest.PING, Result: systemConfiguration.pingTest.testResult, Status: ((systemConfiguration.pingTest.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function downloadSpeedTestChangedHandler():void
{
var obj:Object={Item: DownloadBandwidthTest.DOWNLOAD_SPEED, Result: systemConfiguration.downloadBandwidthTest.testResult, Status: ((systemConfiguration.downloadBandwidthTest.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function uploadSpeedTestChangedHandler():void
{
var obj:Object={Item: UploadBandwidthTest.UPLOAD_SPEED, Result: systemConfiguration.uploadBandwidthTest.testResult, Status: ((systemConfiguration.uploadBandwidthTest.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function webRTCSocketTestChangedHandler():void
{
var obj:Object={Item: WebRTCSocketTest.WEBRTC_SOCKET_TEST, Result: systemConfiguration.webRTCSocketTest.testResult, Status: ((systemConfiguration.webRTCSocketTest.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function webRTCEchoTestChangedHandler():void
{
var obj:Object={Item: WebRTCEchoTest.WEBRTC_ECHO_TEST, Result: systemConfiguration.webRTCEchoTest.testResult, Status: ((systemConfiguration.webRTCEchoTest.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function isPepperFlashChangedHandler():void
{
var obj:Object={Item: IsPepperFlashTest.PEPPER_FLASH, Result: systemConfiguration.isPepperFlash.testResult, Status: ((systemConfiguration.isPepperFlash.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function languageChangedHandler():void
{
var obj:Object={Item: LanguageTest.LANGUAGE, Result: systemConfiguration.language.testResult, Status: ((systemConfiguration.language.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function javaEnabledChangedHandler():void
{
var obj:Object={Item: JavaEnabledTest.JAVA_ENABLED, Result: systemConfiguration.javaEnabled.testResult, Status: ((systemConfiguration.javaEnabled.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function isWebRTCSupportedChangedHandler():void
{
var obj:Object={Item: WebRTCSupportedTest.WEBRTC_SUPPORTED, Result: systemConfiguration.isWebRTCSupported.testResult, Status: ((systemConfiguration.isWebRTCSupported.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function cookieEnabledChangedHandler():void
{
var obj:Object={Item: CookieEnabledTest.COOKIE_ENABLED, Result: systemConfiguration.cookieEnabled.testResult, Status: ((systemConfiguration.cookieEnabled.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function screenSizeChangedHandler():void
{
var obj:Object={Item: ScreenSizeTest.SCREEN_SIZE, Result: systemConfiguration.screenSize.testResult, Status: ((systemConfiguration.screenSize.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}


private function browserChangedHandler():void
{
var obj:Object={Item: BrowserTest.BROWSER, Result: systemConfiguration.browser.testResult, Status: ((systemConfiguration.browser.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function userAgentChangedHandler():void
{
var obj:Object={Item: UserAgentTest.USER_AGENT, Result: systemConfiguration.userAgent.testResult, Status: ((systemConfiguration.userAgent.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

private function flashVersionChangedHandler():void
{
var obj:Object={Item: FlashVersionTest.FLASH_VERSION, Result: systemConfiguration.flashVersion.testResult, Status: ((systemConfiguration.flashVersion.testSuccessfull == true) ? SUCCEED : FAILED)};
updateItemInDataProvider(obj);
dp.updateData(obj);
}

override public function destroy():void
Expand Down

0 comments on commit fd9b8bb

Please sign in to comment.