Skip to content

Commit

Permalink
TileView: Load categories and documentation using newest server update
Browse files Browse the repository at this point in the history
- Load Cat and Documentation at the same time - later items will be filtered on UI sight (reference #56)
  • Loading branch information
piotrzarzycki21 committed Jun 14, 2024
1 parent 65e9e06 commit cc1d1b2
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package Super.Human.Portal_Royale.tasks
{
import Super.Human.Portal_Royale.classes.vo.Constants;
import Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationFormServices.DocumentationFormServices;

import org.apache.royale.net.events.FaultEvent;
import org.apache.royale.utils.async.PromiseTask;
import org.apache.royale.utils.async.SequentialAsyncTask;

import services.CategoriesDelegate;

public class DocumentationLoaderTask extends SequentialAsyncTask
{
public function DocumentationLoaderTask(tasks:Array=null)
{
super(tasks);
}

override public function run(data:Object=null):void
{
var categoriesTask:PromiseTask = new PromiseTask(new Promise(function(resolve:Function, reject:Function){
var categoryDelegate:CategoriesDelegate = new CategoriesDelegate();
categoryDelegate.getCategoriesList(function(event:Event):void{
resolve(event);
}, function onFault(fault:FaultEvent):void{
reject(fault);
})
}));

this.addTask(categoriesTask);

if (Constants.AGENT_BASE_URL)
{
var documentationTask:PromiseTask = new PromiseTask(new Promise(function(resolve:Function, reject:Function){
var documentationDelegate:DocumentationFormServices = new DocumentationFormServices();
documentationDelegate.getDocumentationFormList(function(event:Event):void {
resolve(event);
}, function onFault(fault:FaultEvent):void{
reject(fault);
})
}));
this.addTask(documentationTask);
}

super.run(data);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF
import Super.Human.Portal_Royale.classes.events.ErrorEvent;
import Super.Human.Portal_Royale.classes.utils.Utils;
import Super.Human.Portal_Royale.classes.vo.Constants;
import Super.Human.Portal_Royale.tasks.DocumentationLoaderTask;
import Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationFormServices.DocumentationFormServices;
import Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationFormVO.DocumentationFormVO;

import classes.managers.ParseCentral;

import model.proxy.login.ProxyLogin;
import model.vo.CategoryVO;

import org.apache.royale.events.EventDispatcher;
import org.apache.royale.jewel.Snackbar;
import org.apache.royale.net.events.FaultEvent;
import model.vo.TileViewVO;
import org.apache.royale.utils.async.PromiseTask;

public class DocumentationFormProxy extends EventDispatcher
{
Expand Down Expand Up @@ -77,19 +81,20 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF
{
return _items;
}

public function set items(value:Array):void
{
_items = value;
}

private var _mainItems:Array = new Array(
private var _mainItems:Array = [];/*new Array(
new TileViewVO("usingThisPortal", "Using this Portal", "Run your Notes application in the cloud from any browser. Add bookmarks to key company resources for your employees -- both Domino databases and external URLs to for example your payroll time tracking system.", null, MaterialIconType.HOME, 3),
new TileViewVO("appMarketplace", "Application Marketplace", "Explore free and paid applications you can add to your environment. These range from simple utility apps to complex CRMs.", null, MaterialIconType.STORE, 3),
new TileViewVO("cloudAndMobileEmail", "Cloud Desktops & Mobile e-mail", "Mobile e-mail is just the first step. Your entire set of Windows applications can be run in Cloud Desktops. This gives all of your staff a consistent interface and aids in recovery from ransomware attacks.", null, MaterialIconType.CLOUD, 3),
new TileViewVO("devCenter", "Developer's Corner", "Do you want to build a new app for Domino? Browser based, Mobile first, REST, JSON, native Mac, Windows, Linux, and more? There are more ways than ever to deliver compelling user experiences with Domino.", null, MaterialIconType.CODE, 3),
new TileViewVO("mfaSecurity", "MFA, Security & Compliance", "Multi-Factor Authentication is critical in today's world. Security training for your employees. Assess compliance needs ahead of your annual cyber liability insurance policy renewals.", null, MaterialIconType.SECURITY, 3),
new TileViewVO("verseCalndarAndMeetings", "Verse, Calendaring & Meetings", "Group calendaring helps your team stay organized and connected to vendors and customers. Schedule integration with MS Teams, Zoom, WebEx, GoToMeting, and Sametime directly from Notes and Verse. The Verse e-mail interface groups your key communications automatically.", null, MaterialIconType.PERM_CONTACT_CALENDAR, 3));

*/
[Bindable]
public function get mainItems():Array
{
Expand All @@ -114,10 +119,31 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF

public function requestItems():void
{
if (Constants.AGENT_BASE_URL)
{
this.serviceDelegate.getDocumentationFormList(onDocumentationFormListLoaded, onDocumentationFormListLoadFailed);
}
var documentationTask:DocumentationLoaderTask = new DocumentationLoaderTask();
Utils.setBusy();

documentationTask.done(function(task:PromiseTask):void {
if (documentationTask.failed)
{
Utils.removeBusy();
if (documentationTask.failedTasks.length == 2)
{
onCategoriesListFetchFailed(documentationTask.failedTasks[0].result);
onDocumentationFormListLoadFailed(documentationTask.failedTasks[1].result);
}
else
{
onDocumentationFormListLoadFailed(documentationTask.failedTasks[0]);
}
}
else if (documentationTask.completed)
{
onCategoriesListFetched(documentationTask.completedTasks[0].result);
onDocumentationFormListLoaded(documentationTask.completedTasks[1].result);
}
});

documentationTask.run();
}

private var _breadcrumpItems:Object = {gettingStarted: {
Expand All @@ -141,15 +167,15 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF
var breadcrumpItems:Array = [];

var bItem:Object = null;
for each (var tileItem:TileViewVO in mainItems)
for each (var tileItem:CategoryVO in mainItems)
{
bItem = {
id: tileItem.id,
parent: "gettingStarted",
hash: null,
label: tileItem.title,
label: tileItem.label,
visited: -1,
icon: tileItem.imageIcon,
icon: tileItem.icon,
data: {},
children: []
};
Expand Down Expand Up @@ -258,7 +284,7 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF
items.push(item);
}

this.dispatchEvent(new Event(EVENT_ITEM_UPDATED));
//this.dispatchEvent(new Event(EVENT_ITEM_UPDATED));
}
}
else
Expand All @@ -284,6 +310,46 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF
Snackbar.show("Loading lists of new DocumentationForm failed!\n"+ event.message.toLocaleString(), 8000, null);
}

private function onCategoriesListFetched(event:Event):void
{
Utils.removeBusy();
var fetchedData:String = event.target["data"];
if (fetchedData)
{
var jsonData:Object = JSON.parse(fetchedData);
var errorMessage:String = jsonData["errorMessage"];

if (errorMessage)
{
this.dispatchEvent(
new ErrorEvent(
ErrorEvent.SERVER_ERROR,
errorMessage,
("validationErrors" in jsonData) ? jsonData.validationErrors : null
)
);
}
else
{
mainItems = ParseCentral.parseCategoriesList(jsonData.documents);
}
}
else
{
this.dispatchEvent(
new ErrorEvent(
ErrorEvent.SERVER_ERROR,
"Getting application's categories list failed.")
);
}
}

private function onCategoriesListFetchFailed(event:FaultEvent):void
{
Utils.removeBusy();
Snackbar.show("Getting application's categories list failed: " + event.message.toLocaleString(), 8000, null);
}

private function onDocumentationFormCreated(event:Event):void
{
Utils.removeBusy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
itemRenderer="Super.Human.Portal_Royale.views.renderers.DocumentationTileRenderer"
includeIn="dataGridState"/>
<tileView:TileView localId="tileGettingStarted" className="tileViewJS" direction="vertical" includeIn="startview"
percentWidth="100" baseItemHeight="350" itemMargin="10" itemRenderer="Super.Human.Portal_Royale.views.renderers.CardTileRenderer"
dataProvider="{proxy.mainItems}"/>
percentWidth="100" baseItemHeight="350" baseItemWidth="300" itemMargin="10"
dataProvider="{proxy.mainItems}"
itemRenderer="Super.Human.Portal_Royale.views.renderers.CategoryTileRenderer"/>
</j:VGroup>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</itemRenderers:beads>
<fx:Script>
<![CDATA[
import model.vo.TileViewVO;
import model.vo.CategoryVO;
override public function set data(value:Object):void
{
Expand All @@ -21,24 +21,25 @@
}
[Bindable("dataChange")]
public function get dataVO():TileViewVO
public function get dataVO():CategoryVO
{
return data as TileViewVO;
return data as CategoryVO;
}
]]>
</fx:Script>
<j:Card percentHeight="100" percentWidth="100" className="cardTile">
<j:CardTitle text="{dataVO.title}" className="cardTileTitle" multiline="true" percentWidth="100"/>
<j:CardTitle text="{dataVO.label}" className="cardTileTitle" multiline="true" percentWidth="100"/>
<j:CardPrimaryContent itemsHorizontalAlign="itemsCenter" itemsVerticalAlign="itemsCenter" gap="2">
<j:IconButton visible="{dataVO.imageIcon != null}" className="cardTileButtonIcon">
<j:IconButton visible="{dataVO.icon != null}" className="cardTileButtonIcon">
<j:icon>
<js:MaterialIcon text="{dataVO.imageIcon}" className="cardTileIcon"/>
<js:MaterialIcon text="{dataVO.icon}" className="cardTileIcon"/>
</j:icon>
</j:IconButton>
<j:Label multiline="true" text="{dataVO.description}"/>
</j:CardPrimaryContent>
<!--
<j:CardActions visible="{dataVO.link != null}" className="cardTileActions">
<j:Button text="See More"/>
</j:CardActions>
</j:CardActions>-->
</j:Card>
</itemRenderers:TileViewItemRenderer>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package classes.managers

import utils.UtilsCore;
import model.vo.ServerVO;
import model.vo.CategoryVO;

/**
* ParseCentral
Expand Down Expand Up @@ -332,6 +333,32 @@ package classes.managers

return folders;
}

/**
* Parse genesis application catalog list
*
* @return Array
*/
public static function parseCategoriesList(jsonData:Array):Array
{
var tmpArr:Array = [];

var viewEntryCount:int = jsonData.length;

for (var i:int = 0; i < viewEntryCount; i++)
{
var cat:Object = jsonData[i];
var tmpVO:CategoryVO = new CategoryVO(cat.DominoUniversalID, cat.CategoryID, cat.Description,
Number(cat.Order), cat.Label, cat.Icon);

tmpArr.push(tmpVO);
}

UtilsCore.sortItems(tmpArr, "order", false, true);

return tmpArr;
}

//--------------------------------------------------------------------------
//
// PRIVATE STATIC API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ package classes.managers
return _databaseRead;
}

private var _categoriesRead:String = "/SuperHumanPortal.nsf/CategoryRead?OpenAgent";

public function get categoriesRead():String
{
return _categoriesRead;
}

private var _appVersion:String;

public function setAppVersion(value:String):void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package controller.startup.prepareModel

import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
import model.proxy.ProxyCategories;

public class CommandPrepareModel extends SimpleCommand
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package mediator
public static const NAME:String = 'MediatorViewGettingStarted';

private var proxy:DocumentationFormProxy;

public function MediatorViewGettingStarted(component:Object)
{
super(NAME, component);
Expand All @@ -24,12 +24,15 @@ package mediator
override public function onRegister():void
{
super.onRegister();


proxy = DocumentationFormProxy.getInstance();
proxy.loadConfig();

view.addEventListener("stateChangeComplete", onViewStateChange);
view.tileGettingStarted.addEventListener(TileViewEvent.CLICK_ITEM, onTileViewClickItem);

view.refreshItems();
}

override public function onRemove():void
Expand All @@ -52,6 +55,7 @@ package mediator
override public function listNotificationInterests():Array
{
var interests:Array = super.listNotificationInterests();

return interests;
}

Expand Down Expand Up @@ -84,7 +88,7 @@ package mediator

private function onTileViewClickItem(event:TileViewEvent):void
{
view.refreshItems();
proxy.dispatchEvent(new Event(DocumentationFormProxy.EVENT_ITEM_UPDATED));
}

private function onDgTileDoubleClickItem(event:TileViewEvent):void
Expand Down
Loading

0 comments on commit cc1d1b2

Please sign in to comment.