Skip to content

Commit

Permalink
Improve opening new Nomad tab if ServiceWorker is failing
Browse files Browse the repository at this point in the history
- Improve displayed message (reference #53)
  • Loading branch information
piotrzarzycki21 committed Apr 25, 2024
1 parent 20d9150 commit 0b4dba6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ package constants
public static const NOTE_OPEN_ADD_EDIT_BOOKMARK:String = NAME + SEPARATOR + "NoteOpenAddEditBookmark";
public static const NOTE_OPEN_SELECTED_BOOKMARK_GROUP:String = NAME + SEPARATOR + "NoteOpenSelectedBookmarkGroup";

public static const NOTE_FAILED_OPEN_NOMAD_LINK:String = NAME + SEPARATOR + "NoteFailedOpenNomadLink";

//----------------------------------
// Commands
//----------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ package controller

public class CommandLaunchNomadLink extends SimpleCommand
{
private var link:String;

override public function execute(note:INotification):void
{
var loginProxy:ProxyLogin = facade.retrieveProxy(ProxyLogin.NAME) as ProxyLogin;
var nomadHelperUrl:String = loginProxy.config.config.nomad_helper_url;
var link:String = note.getBody().link;
link = note.getBody().link;
window["onmessage"] = null;

if (nomadHelperUrl)
Expand All @@ -31,16 +33,20 @@ package controller
nomadHelper.src = nomadHelperUrl + "?link=" + encodedLink;

var appName:String = note.getBody().name;
Snackbar.show("Opening application " + appName + " in HCL Nomad Web in progress...", 4000, null);
Snackbar.show("Application " + appName + " has been opened in browser tab with HCL Nomad Web.", 6000, null);
}
else
{
navigateToURL(new URLRequest(link));
}

link = null;
}

private function onWindowMessage(event:Event):void
{
if (!link) return;

var loginProxy:ProxyLogin = facade.retrieveProxy(ProxyLogin.NAME) as ProxyLogin;
var nomadHelperUrl:String = loginProxy.config.config.nomad_helper_url;

Expand All @@ -53,8 +59,10 @@ package controller
if (hasErrorIndex > -1 && hasOriginIndex > -1)
{
winMessage = winMessage.substr(errorPrefix.length, winMessage.length);
sendNotification(ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK, winMessage);
navigateToURL(new URLRequest(link));
}

link = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ package mediator.applications

private var genesisAppsProxy:ProxyGenesisApps;
private var urlParamsProxy:ProxyUrlParameters;
private var currentNomadURL:String;


public function MediatorInstalledApps(mediatorName:String, component:IInstalledAppView)
{
super(mediatorName, component);
Expand Down Expand Up @@ -58,7 +57,6 @@ package mediator.applications
override public function listNotificationInterests():Array
{
var interests:Array = super.listNotificationInterests();
interests.push(ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK);

return interests;
}
Expand All @@ -67,10 +65,7 @@ package mediator.applications
{
switch (note.getName())
{
case ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK:
navigateToURL(new URLRequest(currentNomadURL));
currentNomadURL = null;
break;

}
}

Expand Down Expand Up @@ -232,7 +227,6 @@ package mediator.applications
private function onOpenInNomadLink(event:Event):void
{
var link:LinkWithDescriptionAppButton = event.currentTarget as LinkWithDescriptionAppButton;
currentNomadURL = link.nomadURL;

sendNotification(ApplicationConstants.COMMAND_LAUNCH_NOMAD_LINK, {name: link.appName, link: link.nomadURL});
}
Expand All @@ -243,7 +237,6 @@ package mediator.applications

var confView:ConfigurationAppDetails = event["nativeEvent"].currentTarget.royale_wrapper.parent.parent.parent as ConfigurationAppDetails;
var selectedApp:Object = confView.data;
currentNomadURL = selectedApp.nomadURL;

sendNotification(ApplicationConstants.COMMAND_LAUNCH_NOMAD_LINK, {name: selectedApp.database, link: selectedApp.nomadURL});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ package mediator.bookmarks
private var bookmarksProxy:ProxyBookmarks;
private var urlParamsProxy:ProxyUrlParameters;

private var currentNomadURL:String;

public function MediatorBookmarks(mediatorName:String, component:IBookmarksView)
{
super(mediatorName, component);
Expand Down Expand Up @@ -78,7 +76,6 @@ package mediator.bookmarks

cleanUpBookmarksList();
this.bookmarksProxy = null;
this.currentNomadURL = null;
}


Expand All @@ -88,7 +85,6 @@ package mediator.bookmarks
interests.push(ApplicationConstants.NOTE_OK_POPUP + MediatorPopup.NAME + this.getMediatorName());
interests.push(ApplicationConstants.NOTE_CANCEL_POPUP + MediatorPopup.NAME + this.getMediatorName());
interests.push(ProxyBookmarks.NOTE_BOOKMARK_DELETE_SUCCESS);
interests.push(ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK);

return interests;
}
Expand All @@ -111,10 +107,6 @@ package mediator.bookmarks
case ProxyBookmarks.NOTE_BOOKMARK_DELETE_FAILED:
sendNotification(ApplicationConstants.COMMAND_SHOW_POPUP, new PopupVO(PopupType.ERROR, this.getMediatorName(), String(note.getBody())));
break;
case ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK:
navigateToURL(new URLRequest(currentNomadURL));
currentNomadURL = null;
break;
}
}

Expand Down Expand Up @@ -212,7 +204,6 @@ package mediator.bookmarks

var confView:ConfigurationAppDetails = event["nativeEvent"].currentTarget.royale_wrapper.parent.parent.parent as ConfigurationAppDetails;
var selectedApp:Object = confView.data;
this.currentNomadURL = selectedApp.nomadURL;
sendNotification(ApplicationConstants.COMMAND_LAUNCH_NOMAD_LINK, {name: selectedApp.database, link: selectedApp.nomadURL});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ package mediator.bookmarks
var interests:Array = super.listNotificationInterests();
interests.push(ProxyBrowseMyServer.NOTE_SERVERS_LIST_FETCHED);
interests.push(ProxyBrowseMyServer.NOTE_SERVERS_LIST_FETCH_FAILED);
interests.push(ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK);

return interests;
}
Expand All @@ -98,9 +97,6 @@ package mediator.bookmarks
case ProxyBrowseMyServer.NOTE_SERVERS_LIST_FETCH_FAILED:
sendNotification(ApplicationConstants.COMMAND_SHOW_POPUP, new PopupVO(PopupType.ERROR, this.getMediatorName(), String(note.getBody())));
break;
case ApplicationConstants.NOTE_FAILED_OPEN_NOMAD_LINK:
navigateToURL(new URLRequest(view.selectedItem.nomadURL));
break;
}
}

Expand Down

0 comments on commit 0b4dba6

Please sign in to comment.