Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dvayanu committed Apr 29, 2024
1 parent 51c546c commit 6deb4b8
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 10 deletions.
Expand Up @@ -30,13 +30,7 @@
import net.anotheria.moskito.webui.journey.action.ShowJourneyCallAction;
import net.anotheria.moskito.webui.journey.action.ShowJourneysAction;
import net.anotheria.moskito.webui.loadfactors.action.ShowLoadFactorsAction;
import net.anotheria.moskito.webui.more.action.AdditionalSectionAction;
import net.anotheria.moskito.webui.more.action.ShowConfigAction;
import net.anotheria.moskito.webui.more.action.ShowKillSwitchAction;
import net.anotheria.moskito.webui.more.action.ShowLibsAction;
import net.anotheria.moskito.webui.more.action.ShowMBeansAction;
import net.anotheria.moskito.webui.more.action.SwitchKillSettingAction;
import net.anotheria.moskito.webui.more.action.UpdateAction;
import net.anotheria.moskito.webui.more.action.*;
import net.anotheria.moskito.webui.nowrunning.action.DeleteNowRunningAction;
import net.anotheria.moskito.webui.nowrunning.action.ShowEntryPointsAction;
import net.anotheria.moskito.webui.plugins.action.RemovePluginAction;
Expand Down Expand Up @@ -298,6 +292,13 @@ public void configureActionMappings(ActionMappings mappings) {
mappings.addMapping("mskSwitchKillSetting", SwitchKillSettingAction.class,
new CommandForward("success", "/net/anotheria/moskito/webui/more/jsp/KillSwitch.jsp")
);
mappings.addMapping("mskShowRemotes", ShowRemotesAction.class,
new CommandForward("success", "/net/anotheria/moskito/webui/more/jsp/Remotes.jsp")
);
mappings.addMapping("mskRemoveRemote", RemoveRemoteAction.class,
new CommandDeepLinkRedirect("redirect", "mskShowRemotes")
);

mappings.addMapping("mskRemovePlugin", RemovePluginAction.class,
new CommandDeepLinkRedirect("redirect", "mskPlugins")
);
Expand Down
@@ -0,0 +1,16 @@
package net.anotheria.moskito.webui.more.action;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.moskito.webui.util.WebUIConfig;

public class RemoveRemoteAction extends ShowRemotesAction{
@Override
public ActionCommand execute(ActionMapping actionMapping, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
String remoteName = httpServletRequest.getParameter("pName");
WebUIConfig.getInstance().removeRemote(remoteName);
return actionMapping.redirect();
}
}
@@ -0,0 +1,44 @@
package net.anotheria.moskito.webui.more.action;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.anotheria.maf.action.ActionCommand;
import net.anotheria.maf.action.ActionMapping;
import net.anotheria.moskito.core.util.MoskitoWebUi;
import net.anotheria.moskito.webui.plugins.action.BasePluginAction;
import net.anotheria.moskito.webui.shared.api.PluginAO;
import net.anotheria.moskito.webui.shared.bean.LabelValueBean;
import net.anotheria.moskito.webui.shared.bean.NaviItem;
import net.anotheria.moskito.webui.util.RemoteInstance;
import net.anotheria.moskito.webui.util.WebUIConfig;

import java.awt.*;
import java.util.LinkedList;
import java.util.List;

public class ShowRemotesAction extends BaseAdditionalAction {
@Override
protected String getLinkToCurrentPage(HttpServletRequest req) {
return "mskRemotes";
}

@Override
public ActionCommand execute(ActionMapping actionMapping, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

RemoteInstance[] remotes = WebUIConfig.getInstance().getRemotes();
List<LabelValueBean> beans = new LinkedList<>();
if (remotes.length>0){
for (RemoteInstance remote : remotes){
beans.add(new LabelValueBean(remote.toString(), remote.getSelectKey()));
}
}
httpServletRequest.setAttribute("remotes", beans);

return actionMapping.success();
}

protected NaviItem getCurrentSubNaviItem() {
return NaviItem.MORE_REMOTES;
}

}
Expand Up @@ -95,6 +95,20 @@
</div>
</div>

<div class="box">
<div class="box-title">
<a class="accordion-toggle tooltip-bottom" title="Close/Open" data-toggle="collapse" href="#collapse-remote"><i class="fa fa-caret-down"></i></a>
<h3 class="pull-left">
Remotes.
</h3>
</div>
<div id="collapse-remote" class="box-content accordion-body collapse in">
<div class="paddner">
<a href="mskShowRemotes">Edit remote moskito-core instances</a>. The 'remote' moskito-core instances are other VMs that are preconfigured via moskito-inspect.json and can be accessed from this UI. This is useful for distributed applications.
</div>
</div>
</div>

</div>
<jsp:include page="../../shared/jsp/Footer.jsp" flush="false"/>
</section>
Expand Down
@@ -0,0 +1,61 @@
<%@ page language="java" contentType="text/html;charset=UTF-8" session="true" %>
<%@ taglib prefix="ano" uri="http://www.anotheria.net/ano-tags" %>
<%@ taglib prefix="mos" uri="http://www.moskito.org/inspect/tags" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<jsp:include page="../../shared/jsp/Header.jsp" flush="false"/>
<section id="main">
<jsp:include page="../../shared/jsp/Alerts.jsp"/>

<div class="content">

<div class="box">
<div class="box-title">
<a class="accordion-toggle tooltip-bottom" title="Close/Open" data-toggle="collapse" href="#collapse1"><i class="fa fa-caret-down"></i></a>
<h3 class="pull-left">
MoSKito Remotes.
</h3>
</div>
<div id="collapse1" class="box-content accordion-body collapse in">
<div class="paddner">
Remotes are preconfigured connections or connections you added via the left bottom connect box. You can remove unwanted remotes here.
Remotes should only work in local mode. Removing remotes only alert the runtime, after a restart the remotes are back.
</div>
</div>
</div>

<div class="box">
<div class="box-title">
<a class="accordion-toggle tooltip-bottom" title="Close/Open" data-toggle="collapse" href="#collapse2"><i class="fa fa-caret-down"></i></a>
<h3 class="pull-left">
Remotes
</h3>
</div>
<div id="collapse2" class="box-content accordion-body collapse in">
<table class="table table-striped">
<thead>
<tr>
<th>Link</th>
<th class="th-actions"></th>
</tr>
</thead>
<tbody>
<ano:iterate name="remotes" type="net.anotheria.moskito.webui.shared.bean.LabelValueBean" id="remote" indexId="index">
<tr>
<td>${remote.label}</td>
<td><mos:deepLink href="mskRemoveRemote?pName=${remote.value}" class="action-icon delete-icon tooltip-bottom" title="Remove"><i class="fa fa-ban"></i></mos:deepLink ></td>
</tr>
</ano:iterate>
</tbody>
</table>
</div>
</div>
</div>

<jsp:include page="../../shared/jsp/Footer.jsp" flush="false"/>

</section>
</body>
</html>


Expand Up @@ -98,7 +98,11 @@ public enum NaviItem {
/**
* Navi item for kill switch.
*/
MORE_KILLSWITCH("Kill Switch");
MORE_KILLSWITCH("Kill Switch"),

MORE_REMOTES("Remotes");



/**
* Caption of the navi item.
Expand Down
Expand Up @@ -261,7 +261,7 @@
<li ${currentSubNaviItem.isSelected("more_loadfactors") ? "class=\"active\"" : ""}><mos:deepLink href="mskLoadFactors" title="Load Factors" class="sidebar-tooltip-right">Load Factors <i class="fa fa-asterisk"></i></mos:deepLink></li>
<li ${currentSubNaviItem.isSelected("more_nowrunning") ? "class=\"active\"" : ""}><mos:deepLink href="mskNowRunning" title="Entry Points" class="sidebar-tooltip-right">Now Running <i class="fa fa-location-arrow"></i></mos:deepLink></li>
<li ${currentSubNaviItem.isSelected("more_killswitch") ? "class=\"active\"" : ""}><mos:deepLink href="mskKillSwitch" title="Kill Switch" class="sidebar-tooltip-right">Kill Switch <i class="fa fa-cog"></i></mos:deepLink></li>
<%--<li ${currentSubNaviItem.isSelected("more_plugins") ? "class=\"active\"" : ""}><a href="mskPlugins" title="Plugins" class="sidebar-tooltip-right">Plugins <i class="fa fa-cloud"></i></a></li>--%>
<li ${currentSubNaviItem.isSelected("more_remotes") ? "class=\"active\"" : ""}><a href="mskShowRemotes" title="Remotes" class="sidebar-tooltip-right">Remotes <i class="fa fa-cloud"></i></a></li>
</ul>
</li>
</ano:equal>
Expand Down
Expand Up @@ -41,7 +41,7 @@ public class WebUIConfig {
private ConcurrentMap<String, Boolean> remotesKeys;

/**
* Synchronized list of remote intances. Created from remote instances configured list.
* Synchronized list of remote instances. Created from remote instances configured list.
*/
@DontConfigure
private List<RemoteInstance> remotesSynced;
Expand Down Expand Up @@ -118,6 +118,16 @@ public void addRemote(RemoteInstance newRemoteInstance) {
remotesSynced.add(newRemoteInstance);
}

public void removeRemote(String key) {
remotesKeys.remove(key);
for (int i=0; i<remotesSynced.size(); i++){
if (remotesSynced.get(i).getSelectKey().equals(key)){
remotesSynced.remove(i);
return;
}
}
}

public AuthConfig getAuthentication() {
return authentication;
}
Expand Down

0 comments on commit 6deb4b8

Please sign in to comment.