From 30ae03b03456aa78242eba17fce7decf0f490efc Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 22 Aug 2023 11:35:48 +0200 Subject: [PATCH] Private Dir: Add Create/Update and get all directories using newest API update - UI Improvement (reference #35) --- .../classes/managers/ParseCentral.as | 2 +- .../classes/managers/UrlProvider.as | 27 +++++- .../interfaces/IGenesisEditDirView.as | 8 +- .../applications/MediatorGenesisDirs.as | 2 +- .../applications/MediatorGenesisEditDir.as | 25 +++-- .../applicationsCatalog/ProxyGenesisDirs.as | 92 ++++++++++++++++++- .../model/vo/GenesisDirVO.as | 7 +- .../services/GenesisDirsDelegate.as | 52 ++++++++++- .../applications/ConfigurationAppDetails.mxml | 6 +- .../view/applications/GenesisAppsList.mxml | 2 +- .../view/applications/GenesisEditDirView.mxml | 47 +++++++--- .../view/bookmarks/EditBookmarkView.mxml | 14 +-- .../view/controls/HGroupForm.as | 15 +++ .../src/resources/app-styles.css | 21 ++++- 14 files changed, 269 insertions(+), 51 deletions(-) create mode 100644 Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/controls/HGroupForm.as diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/ParseCentral.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/ParseCentral.as index 8db1c99..bcc2733 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/ParseCentral.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/ParseCentral.as @@ -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); } diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/UrlProvider.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/UrlProvider.as index 7c8b788..b0889f5 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/UrlProvider.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/classes/managers/UrlProvider.as @@ -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"; diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/interfaces/IGenesisEditDirView.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/interfaces/IGenesisEditDirView.as index 34a9d55..a91b651 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/interfaces/IGenesisEditDirView.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/interfaces/IGenesisEditDirView.as @@ -4,7 +4,7 @@ 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; @@ -12,9 +12,13 @@ package interfaces 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 } } \ No newline at end of file diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisDirs.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisDirs.as index 8b45d19..b2d56bd 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisDirs.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisDirs.as @@ -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); } diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisEditDir.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisEditDir.as index 72cb0da..1dab795 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisEditDir.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisEditDir.as @@ -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 { @@ -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(); } @@ -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: @@ -89,16 +88,19 @@ 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 @@ -106,6 +108,11 @@ package mediator.applications 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"; diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/proxy/applicationsCatalog/ProxyGenesisDirs.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/proxy/applicationsCatalog/ProxyGenesisDirs.as index a010cfc..08d8907 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/proxy/applicationsCatalog/ProxyGenesisDirs.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/proxy/applicationsCatalog/ProxyGenesisDirs.as @@ -1,5 +1,7 @@ package model.proxy.applicationsCatalog { + import classes.managers.ParseCentral; + import interfaces.IDisposable; import model.proxy.ProxySessionCheck; @@ -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"]; @@ -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); } @@ -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()); + } } } \ No newline at end of file diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/vo/GenesisDirVO.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/vo/GenesisDirVO.as index 3f46964..521ca2a 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/vo/GenesisDirVO.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/vo/GenesisDirVO.as @@ -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; @@ -17,6 +21,7 @@ package model.vo public function toRequestObject():Object { return { + DominoUniversalID: this.dominoUniversalID, label: this.label, url: this.url, password: this.password diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/services/GenesisDirsDelegate.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/services/GenesisDirsDelegate.as index c798d77..111eb6c 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/services/GenesisDirsDelegate.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/services/GenesisDirsDelegate.as @@ -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) { @@ -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); diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/ConfigurationAppDetails.mxml b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/ConfigurationAppDetails.mxml index ce07d03..e58881d 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/ConfigurationAppDetails.mxml +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/ConfigurationAppDetails.mxml @@ -47,7 +47,7 @@ - @@ -55,7 +55,7 @@ - @@ -63,7 +63,7 @@ - diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisAppsList.mxml b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisAppsList.mxml index 8d0d92b..da98f75 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisAppsList.mxml +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisAppsList.mxml @@ -81,7 +81,7 @@ - + diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisEditDirView.mxml b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisEditDirView.mxml index a1baff2..a8a8042 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisEditDirView.mxml +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/applications/GenesisEditDirView.mxml @@ -70,6 +70,23 @@ return this.passwordTextInput.text; } + public function get isPasswordDisabled():Boolean + { + if (!this.passwordDisabled) return false; + + return this.passwordDisabled.disabled; + } + + public function togglePasswordChange():void + { + this.passwordDisabled.disabled = !this.passwordDisabled.disabled; + } + + public function get passwordChange():IEventDispatcher + { + return this.changePassword; + } + public function installationResult(message:String):void { Snackbar.show(message, 4000, null); @@ -106,14 +123,14 @@ - - @@ -122,15 +139,19 @@ - - - - - - + + + + + + + + + + diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/bookmarks/EditBookmarkView.mxml b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/bookmarks/EditBookmarkView.mxml index f5e476a..4c67a01 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/bookmarks/EditBookmarkView.mxml +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/view/bookmarks/EditBookmarkView.mxml @@ -213,13 +213,13 @@ - - - - - - -