Skip to content

Commit

Permalink
Private Dir: Add Create/Update and get all directories using newest A…
Browse files Browse the repository at this point in the history
…PI update

- UI Improvement (reference #35)
  • Loading branch information
piotrzarzycki21 committed Aug 22, 2023
1 parent 8500acd commit 30ae03b
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ package classes.managers
for (var i:int = 0; i < viewEntryCount; i++)
{
var privateDir:Object = jsonData[i];
var tmpVO:GenesisDirVO = new GenesisDirVO(privateDir.label, privateDir.url);
var tmpVO:GenesisDirVO = new GenesisDirVO(privateDir.DominoUniversalID, privateDir["private"], privateDir.label, privateDir.url);

tmpArr.push(tmpVO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,32 @@ package classes.managers
return _genesisCatalogGetAll;
}

private var _genesisGenesisDirsGetAll:String = "/SuperHumanPortal.nsf/GenesisRead?OpenAgent";
private var _genesisDirsGetAll:String = "/SuperHumanPortal.nsf/GenesisDirectoryRead?OpenAgent";

public function get genesisGenesisDirsGetAll():String
public function get genesisDirsGetAll():String
{
return _genesisGenesisDirsGetAll;
return _genesisDirsGetAll;
}

private var _genesisDirCreate:String = "/SuperHumanPortal.nsf/GenesisDirectoryCreate?OpenAgent";

public function get genesisDirCreate():String
{
return _genesisDirCreate;
}

private var _genesisDirUpdate:String = "/SuperHumanPortal.nsf/GenesisDirectoryUpdate?OpenAgent";

public function get genesisDirUpdate():String
{
return _genesisDirUpdate;
}

private var _genesisDirDelete:String = "/SuperHumanPortal.nsf/GenesisDirectoryUpdate?OpenAgent";

public function get genesisDirDelete():String
{
return _genesisDirDelete;
}

private var _genesisCatalogInstall:String = "/SuperHumanPortal.nsf/GenesisInstall?OpenAgent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ package interfaces

import org.apache.royale.events.IEventDispatcher;

public interface IGenesisEditDirView extends IEventDispatcher, IResetView
public interface IGenesisEditDirView extends IResetView
{
function get genesisDir():GenesisDirVO;
function set genesisDir(value:GenesisDirVO):void;
function get genesisDirForm():IEventDispatcher;
function get cancelGenesisEdit():IEventDispatcher;
function get titleGenesisDir():String;
function set titleGenesisDir(value:String):void;

function get isPasswordDisabled():Boolean;
function get passwordChange():IEventDispatcher;

function get labelText():String;
function get urlText():String;
function get passwordText():String;

function togglePasswordChange():void
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ package mediator.applications

private function onNewDirClick(event:MouseEvent):void
{
this.genesisDirsProxy.selectedDir = new GenesisDirVO("", "");
this.genesisDirsProxy.selectedDir = new GenesisDirVO();

sendNotification(ApplicationConstants.NOTE_OPEN_ADD_EDIT_GENESIS_DIR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ package mediator.applications
import org.puremvc.as3.multicore.interfaces.IMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;

import view.bookmarks.event.BookmarkEvent;

public class MediatorGenesisEditDir extends Mediator implements IMediator
{
Expand All @@ -36,6 +34,7 @@ package mediator.applications

this.view.genesisDirForm.addEventListener("valid", onGenesisDirFormValid);
this.view.cancelGenesisEdit.addEventListener(MouseEvent.CLICK, onCancelEditGenesisDir);
this.view.passwordChange.addEventListener(MouseEvent.CLICK, onPasswordChangeClick);

updateView();
}
Expand Down Expand Up @@ -68,10 +67,10 @@ package mediator.applications
switch (note.getName())
{
case ProxyGenesisDirs.NOTE_GENESIS_DIR_CREATE_SUCCESS:

sendNotification(ApplicationConstants.NOTE_OPEN_GENESIS_DIRS_VIEW);
break;
case ProxyGenesisDirs.NOTE_GENESIS_DIR_UPDATE_SUCCESS:

sendNotification(ApplicationConstants.NOTE_OPEN_GENESIS_DIRS_VIEW);
break;
case ProxyGenesisDirs.NOTE_GENESIS_DIR_CREATE_FAILED:
case ProxyGenesisDirs.NOTE_GENESIS_DIR_UPDATE_FAILED:
Expand All @@ -89,23 +88,31 @@ package mediator.applications
{
genesisDirsProxy.selectedDir.label = view.labelText;
genesisDirsProxy.selectedDir.url = view.urlText;
genesisDirsProxy.selectedDir.password = view.passwordText;
if (!view.isPasswordDisabled)
{
genesisDirsProxy.selectedDir.password = view.passwordText;
}

/*if (genesisDirsProxy.selectedDir.dominoUniversalID)
if (genesisDirsProxy.selectedDir.dominoUniversalID)
{
//genesisDirsProxy.updateBookmark();
genesisDirsProxy.updateDir();
}
else
{
//genesisDirsProxy.createBookmark();
}*/
genesisDirsProxy.createDir();
}
}

private function onCancelEditGenesisDir(event:MouseEvent):void
{
sendNotification(ApplicationConstants.NOTE_OPEN_GENESIS_DIRS_VIEW);
}

private function onPasswordChangeClick(event:MouseEvent):void
{
view.togglePasswordChange();
}

private function updateView():void
{
this.view.titleGenesisDir = genesisDirsProxy.selectedDir.label ? "Edit Directory" : "Add Directory";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package model.proxy.applicationsCatalog
{
import classes.managers.ParseCentral;

import interfaces.IDisposable;

import model.proxy.ProxySessionCheck;
Expand Down Expand Up @@ -67,7 +69,23 @@ package model.proxy.applicationsCatalog

genesisPrivteDirDelegate.getGenesisDirsList(successCallback, failureCallback);
}

public function createDir():void
{
var successCallback:Function = this.busyManagerProxy.wrapSuccessFunction(onCreateDirSuccess);
var failureCallback:Function = this.busyManagerProxy.wrapFailureFunction(onCreateDirFailed);

genesisPrivteDirDelegate.createDir(this.selectedDir.toRequestObject(), successCallback, failureCallback);
}

public function updateDir():void
{
var successCallback:Function = this.busyManagerProxy.wrapSuccessFunction(onUpdateDirSuccess);
var failureCallback:Function = this.busyManagerProxy.wrapFailureFunction(onUpdateDirFailed);

genesisPrivteDirDelegate.updateGenesisDir(this.selectedDir.dominoUniversalID, this.selectedDir.toRequestObject(), successCallback, failureCallback);
}

private function onGenesisDirsListFetched(event:Event):void
{
var fetchedData:String = event.target["data"];
Expand All @@ -87,11 +105,7 @@ package model.proxy.applicationsCatalog
}
else
{
var dirs:Array = [
new GenesisDirVO("Local", ""),
new GenesisDirVO("Private Remote", "https://soundcloud.com/discover")
]
//ParseCentral.parseGenesisPrivDirsList(jsonData.dirs);
var dirs:Array = ParseCentral.parseGenesisPrivDirsList(jsonData.documents);
setData(dirs);
sendNotification(NOTE_GENESIS_DIRS_LIST_FETCHED, dirs);
}
Expand All @@ -106,5 +120,73 @@ package model.proxy.applicationsCatalog
{
sendNotification(NOTE_GENESIS_DIRS_LIST_FETCH_FAILED, "Getting Genesis directories list failed: " + event.message.toLocaleString());
}

private function onCreateDirSuccess(event:Event):void
{
var fetchedData:String = event.target["data"];
if (fetchedData)
{
var jsonData:Object = JSON.parse(fetchedData);
if (!sessionCheckProxy.checkUserSession(jsonData))
{
return;
}

var errorMessage:String = jsonData["errorMessage"];

if (errorMessage)
{
sendNotification(NOTE_GENESIS_DIR_CREATE_FAILED, "Creating Genesis directory failed: " + errorMessage);
}
else
{
sendNotification(NOTE_GENESIS_DIR_CREATE_SUCCESS);
}
}
else
{
sendNotification(NOTE_GENESIS_DIR_CREATE_FAILED, "Creating Genesis directory failed");
}
}

private function onCreateDirFailed(event:FaultEvent):void
{
sendNotification(NOTE_GENESIS_DIR_CREATE_FAILED, "Creating Genesis directory failed: " + event.message.toLocaleString());
}

private function onUpdateDirSuccess(event:Event):void
{
var fetchedData:String = event.target["data"];
if (fetchedData)
{
var jsonData:Object = JSON.parse(fetchedData);
if (!sessionCheckProxy.checkUserSession(jsonData))
{
return;
}


var errorMessage:String = jsonData["errorMessage"];

if (errorMessage)
{
sendNotification(NOTE_GENESIS_DIR_UPDATE_FAILED, "Updating Genesis directory failed: " + errorMessage);
}
else
{
var updatedGenesisDir:Object = jsonData.document;
sendNotification(NOTE_GENESIS_DIR_UPDATE_SUCCESS);
}
}
else
{
sendNotification(NOTE_GENESIS_DIR_UPDATE_FAILED, "Updating Genesis directory failed");
}
}

private function onUpdateDirFailed(event:FaultEvent):void
{
sendNotification(NOTE_GENESIS_DIR_UPDATE_FAILED, "Updating Genesis directory failed: " + event.message.toLocaleString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package model.vo
[Bindable]
public class GenesisDirVO
{
public var dominoUniversalID:String;
public var isPrivate:Boolean;
public var label:String;
public var url:String;
public var password:String;

public function GenesisDirVO(label:String, url:String, password:String = "")
public function GenesisDirVO(dominoUniversalID:String = "", isPrivate:Boolean = false, label:String = "", url:String = "", password:String = "")
{
this.dominoUniversalID = dominoUniversalID;
this.isPrivate = isPrivate;
this.label = label;
this.url = url;
this.password = password;
Expand All @@ -17,6 +21,7 @@ package model.vo
public function toRequestObject():Object
{
return {
DominoUniversalID: this.dominoUniversalID,
label: this.label,
url: this.url,
password: this.password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,60 @@ package services

var service:HTTPService = new HTTPService();
service.addBead(new CORSCredentialsBead(true));
service.url = UrlProvider.getInstance().genesisGenesisDirsGetAll;
service.url = UrlProvider.getInstance().genesisDirsGetAll;
service.method = "GET";
service.addEventListener("complete", resultCallback);
service.addEventListener("ioError", faultCallback);
service.send();
}

public function getGenesisCatalogInstall(appId:String, resultCallback:Function, faultCallback:Function=null):void
public function createDir(directory:Object, resultCallback:Function, faultCallback:Function=null):void
{
if (faultCallback == null)
{
faultCallback = onFault;
}

var urlParams:URLSearchParams = new URLSearchParams();
for (var property:String in directory)
{
urlParams.set(property, directory[property]);
}

var service:HTTPService = new HTTPService();
service.addBead(new CORSCredentialsBead(true));
service.url = UrlProvider.getInstance().genesisDirCreate;
service.method = "POST";
service.contentData = urlParams;
service.addEventListener("complete", resultCallback);
service.addEventListener("ioError", faultCallback);
service.send();
}

public function updateGenesisDir(dominoUniversalID:String, directory:Object, resultCallback:Function, faultCallback:Function=null):void
{
if (faultCallback == null)
{
faultCallback = onFault;
}

var urlParams:URLSearchParams = new URLSearchParams();
for (var property:String in directory)
{
urlParams.set(property, directory[property]);
}

var service:HTTPService = new HTTPService();
service.addBead(new CORSCredentialsBead(true));
service.url = UrlProvider.getInstance().genesisDirUpdate + "&DominoUniversalID=" + dominoUniversalID;
service.method = "POST";
service.contentData = urlParams;
service.addEventListener("complete", resultCallback);
service.addEventListener("ioError", faultCallback);
service.send();
}

public function deleteDir(dominoUniversalID:String, resultCallback:Function, faultCallback:Function=null):void
{
if (faultCallback == null)
{
Expand All @@ -38,7 +84,7 @@ package services

var service:HTTPService = new HTTPService();
service.addBead(new CORSCredentialsBead(true));
service.url = UrlProvider.getInstance().genesisCatalogInstall +"&AppID="+ appId;
service.url = UrlProvider.getInstance().genesisDirDelete + "&DominoUniversalID=" + dominoUniversalID;
service.method = "GET";
service.addEventListener("complete", resultCallback);
service.addEventListener("ioError", faultCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@
</j:CardHeader>
<j:CardPrimaryContent>
<j:Form>
<controls:CustomFormItem className="horizontalContentNonExpandFormItem"
<controls:CustomFormItem className="horizontalContentCenterExpandFormItem"
labelClass="formItemAppDetailsLabel"
label="Server:" visible="{server != null}">
<j:Label html="{server}" />
<j:HGroup itemsHorizontalAlign="itemsRight">
<j:Button text="Copy to Clipboard" width="135" click="onCopyToClipboardServerClick(event)"/>
</j:HGroup>
</controls:CustomFormItem>
<controls:CustomFormItem className="horizontalContentNonExpandFormItem"
<controls:CustomFormItem className="horizontalContentCenterExpandFormItem"
labelClass="formItemAppDetailsLabel"
label="Database:" visible="{database != null}">
<j:Label html="{database}" />
<j:HGroup itemsHorizontalAlign="itemsRight">
<j:Button text="Copy to Clipboard" width="135" click="onCopyToClipboardDatabaseClick(event)"/>
</j:HGroup>
</controls:CustomFormItem>
<controls:CustomFormItem className="horizontalContentNonExpandFormItem"
<controls:CustomFormItem className="horizontalContentCenterExpandFormItem"
labelClass="formItemAppDetailsLabel"
label="View:" visible="{viewName != null}">
<j:Label localId="viewTextInput" text="{viewName}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<j:Card percentWidth="100" className="minHeaderHeight">
<j:Form className="bodyPadding">
<controls:CustomFormItem labelClass="formItemPersonalInfo" className="horizontalContentFormItem">
<controls:CustomFormItem labelClass="formItemPersonalInfo" className="horizontalContentExpandFormItem">
<j:HGroup itemsVerticalAlign="itemsCenter">
<html:H4 localId="selectedAppH" text="Select an application from the list below"/>
</j:HGroup>
Expand Down
Loading

0 comments on commit 30ae03b

Please sign in to comment.