Skip to content

Commit

Permalink
Add first restriction based on properites
Browse files Browse the repository at this point in the history
- Restrict Installed Apps to be hidden
- Restrict Bookmarks to be hidden (reference #65)
  • Loading branch information
piotrzarzycki21 committed Nov 13, 2024
1 parent 2141edb commit 2b395ea
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@ package controller
import org.apache.royale.collections.ArrayList;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
import model.proxy.login.ProxyLogin;

public class CommandNavigationRefreshInstalledApps extends SimpleCommand
{
override public function execute(note:INotification):void
{
var apps:Array = note.getBody() as Array;
var mainMediator:MediatorMainContentView = facade.retrieveMediator(MediatorMainContentView.NAME) as MediatorMainContentView;
var genesisAppsProxy:ProxyGenesisApps = facade.retrieveProxy(ProxyGenesisApps.NAME) as ProxyGenesisApps;
var loginProxy:ProxyLogin = facade.retrieveProxy(ProxyLogin.NAME) as ProxyLogin;
if (loginProxy.user.display && !loginProxy.user.display.viewInstalledApps)
{
return;
}

var mainMediator:MediatorMainContentView = facade.retrieveMediator(MediatorMainContentView.NAME) as MediatorMainContentView;
var installedAppNavModel:LeftMenuNavigationModel = mainMediator.view["model"] as LeftMenuNavigationModel;

var apps:Array = note.getBody() as Array;
var genesisAppsProxy:ProxyGenesisApps = facade.retrieveProxy(ProxyGenesisApps.NAME) as ProxyGenesisApps;

var installedApps:ArrayList = new ArrayList();
var appWhiteSpaceRegExp:RegExp = new RegExp(/\s+/gi);
for each (var app:ApplicationVO in apps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ package controller
import org.apache.royale.collections.ArrayList;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
import model.proxy.login.ProxyLogin;

public class CommandRefreshNavigationBookmarks extends SimpleCommand
{
override public function execute(note:INotification):void
{
var loginProxy:ProxyLogin = facade.retrieveProxy(ProxyLogin.NAME) as ProxyLogin;
if (loginProxy.user.display && !loginProxy.user.display.viewBookmarks)
{
return;
}

var bookmarks:Array = note.getBody() as Array;

var mainMediator:MediatorMainContentView = facade.retrieveMediator(MediatorMainContentView.NAME) as MediatorMainContentView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ package controller.roles.executeRoles

var mainContentMediator:MediatorMainContentView = facade.retrieveMediator(MediatorMainContentView.NAME) as MediatorMainContentView;
var mainContentModel:LeftMenuNavigationModel = mainContentMediator.view["model"];
var navItem:NavigationLinkVO = null;

//Remove "Additional directories" - avialable as admin
if (loginProxy.user && !loginProxy.user.hasRole(Roles.ADMINISTRATOR))
{
for (var i:int = mainContentModel.mainNavigation.length - 1; i >= 0; i--)
{
var navItem:NavigationLinkVO = mainContentModel.mainNavigation.getItemAt(i) as NavigationLinkVO;
navItem = mainContentModel.mainNavigation.getItemAt(i) as NavigationLinkVO;
if (navItem.idSelectedItem == MediatorGenesisApps.NAME)
{
if (navItem.subMenu)
Expand All @@ -48,6 +49,33 @@ package controller.roles.executeRoles
}
}
}

if (loginProxy.user && loginProxy.user.display)
{
var k:int = -1;

if (!loginProxy.user.display.viewInstalledApps)
{
for (k = mainContentModel.navigationLinks.length - 1; k >= 0; k--)
{
navItem = mainContentModel.navigationLinks.getItemAt(k) as NavigationLinkVO;
if (navItem.idSelectedItem == "installedApps") {
mainContentModel.navigationLinks.removeItemAt(k);
}
}
}

if (!loginProxy.user.display.viewBookmarks)
{
for (k = mainContentModel.customBookmarks.length - 1; k >= 0; k--)
{
navItem = mainContentModel.customBookmarks.getItemAt(k) as NavigationLinkVO;
if (navItem.idSelectedItem == "bookmarksList") {
mainContentModel.customBookmarks.removeItemAt(k);
}
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ package model
_mainNavigation = value;
}

private var installedApp:NavigationLinkVO = new NavigationLinkVO("Installed Apps", "$collapsible", "mdi mdi-folder mdi-24px", "");
private var installedApp:NavigationLinkVO = new NavigationLinkVO("Installed Apps", "$collapsible", "mdi mdi-folder mdi-24px", "installedApps");

private var _navigationLinks:ArrayList = new ArrayList([
installedApp
Expand All @@ -61,7 +61,7 @@ package model
_installedAppsNavLinks = value;
}

private var customBookmarksList:NavigationLinkVO = new NavigationLinkVO("Bookmarks", "$collapsible", "mdi mdi-folder mdi-24px", "");
private var customBookmarksList:NavigationLinkVO = new NavigationLinkVO("Bookmarks", "$collapsible", "mdi mdi-folder mdi-24px", "bookmarksList");

private var _customBookmarks:ArrayList = new ArrayList([
customBookmarksList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package model.proxy.login
import org.puremvc.as3.multicore.patterns.proxy.Proxy;

import services.login.LoginServiceDelegate;
import model.vo.DisplayVO;

public class ProxyLogin extends Proxy
{
Expand Down Expand Up @@ -228,6 +229,17 @@ package model.proxy.login
}

var user:UserVO = new UserVO(username, serverUserName, commonName, status, roles, loginResult.loginURL);
user.display = new DisplayVO();
if (loginResult.display)
{
user.display.additionalGenesis = loginResult.display.additionalGenesis;
user.display.browseMyServer = loginResult.display.browseMyServer;
user.display.documentation = loginResult.display.documentation;
user.display.installApps = loginResult.display.installApps;
user.display.manageBookmarks = loginResult.display.manageBookmarks;
user.display.viewBookmarks = loginResult.display.viewBookmarks;
user.display.viewInstalledApps = loginResult.display.viewInstalledApps;
}
this.setData(user);

// get all the configuration before
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package model.vo
{
[Bindable]
public dynamic class DisplayVO
{
private var _additionalGenesis:Boolean;

public function get additionalGenesis():Boolean
{
return _additionalGenesis;
}

public function set additionalGenesis(value:Boolean):void
{
_additionalGenesis = value;
}

private var _browseMyServer:Boolean;

public function get browseMyServer():Boolean
{
return _browseMyServer;
}

public function set browseMyServer(value:Boolean):void
{
_browseMyServer = value;
}

private var _documentation:Boolean;

public function get documentation():Boolean
{
return _documentation;
}

public function set documentation(value:Boolean):void
{
_documentation = value;
}

private var _installApps:Boolean;

public function get installApps():Boolean
{
return _installApps;
}

public function set installApps(value:Boolean):void
{
_installApps = value;
}

private var _manageBookmarks:Boolean;

public function get manageBookmarks():Boolean
{
return _manageBookmarks;
}

public function set manageBookmarks(value:Boolean):void
{
_manageBookmarks = value;
}

private var _viewBookmarks:Boolean;

public function get viewBookmarks():Boolean
{
return _viewBookmarks;
}

public function set viewBookmarks(value:Boolean):void
{
_viewBookmarks = value;
}

private var _viewInstalledApps:Boolean;

public function get viewInstalledApps():Boolean
{
return _viewInstalledApps;
}

public function set viewInstalledApps(value:Boolean):void
{
_viewInstalledApps = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ package model.vo
_status = value;
}

private var _display:DisplayVO;

[Bindable]
public function get display():DisplayVO
{
return _display;
}

public function set display(value:DisplayVO):void
{
_display = value;
}

private var _roles:Array;

public function get roles():Array
Expand Down

0 comments on commit 2b395ea

Please sign in to comment.