Commit 7d97aba5 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Providing enact button on console interface

parent 1a9b1cb5
......@@ -31,6 +31,7 @@ public class ChoreographyActionsPanel extends Panel {
setOutputMarkupId(true);
super.add(new Fragment("detailsPanel", "emptyFragment", this));
super.add(new Fragment("enactPanel", "emptyFragment", this));
super.add(new Fragment("startPanel", "emptyFragment", this));
super.add(new Fragment("pausePanel", "emptyFragment", this));
super.add(new Fragment("stopPanel", "emptyFragment", this));
......@@ -53,6 +54,11 @@ public class ChoreographyActionsPanel extends Panel {
fragment.addOrReplace(link.setVisible(true));
break;
case ENACT:
fragment = new Fragment("enactPanel", "enactFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case START:
fragment = new Fragment("startPanel", "startFragment", this);
fragment.addOrReplace(link.setVisible(true));
......@@ -111,6 +117,7 @@ public class ChoreographyActionsPanel extends Panel {
public enum ChoreographyActionType {
SHOW,
ENACT,
START,
PAUSE,
STOP,
......
......@@ -119,6 +119,7 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
public void populateItem(
final Item<ICellPopulator<GroupTO>> item, final String componentId, final IModel<GroupTO> model) {
String chorStatus = model.getObject().getPlainAttrMap().get("status").getValues().iterator().next();
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
......@@ -134,23 +135,48 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
}
}, ChoreographyActionsPanel.ChoreographyActionType.SHOW);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
if (chorStatus.equals("PENDING CREATE") || chorStatus.equals("PENDING UPDATE")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 5283601360187316340L;
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
utilityModal.setContent(new ResizeModalPanel(
utilityModal,
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
pageRef)
);
utilityModal.show(true);
target.add(utilityModal);
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
@Override
public void onClick(final AjaxRequestTarget target) {
try {
choreographyRestClient.enactChoreography(model.getObject().getName());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While enacting choreography {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.ENACT);
}
if (!chorStatus.equals("PENDING CREATE")
&& !chorStatus.equals("PENDING UPDATE")
&& !chorStatus.equals("PENDING ENACTMENT")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
utilityModal.setContent(new ResizeModalPanel(
utilityModal,
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
pageRef)
);
utilityModal.show(true);
target.add(utilityModal);
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
}
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("STARTED")) {
if (chorStatus.equals("STARTED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
......@@ -191,7 +217,7 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
}, ChoreographyActionsPanel.ChoreographyActionType.FREEZE);
}
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("STOPPED")) {
if (chorStatus.equals("STOPPED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
......@@ -213,7 +239,7 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
}, ChoreographyActionsPanel.ChoreographyActionType.START);
}
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("FROZEN")) {
if (chorStatus.equals("FROZEN")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
......@@ -235,8 +261,7 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
}, ChoreographyActionsPanel.ChoreographyActionType.UNFREEZE);
}
if (!model.getObject().getPlainAttrMap().get("status").getValues().iterator().next()
.equals("PENDING DELETE")) {
if (!chorStatus.equals("PENDING DELETE")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
......
......@@ -66,7 +66,7 @@ public class ChoreographyEEResourcesPanel extends Panel {
ChoreographyTO choreography = restClient.getChoreography(choreographyId);
this.enactmentEngine = restClient.getChoreographyEE(choreography.getId());
this.enactmentEngine = restClient.getChoreographyEE(choreography.getGroupKey());
this.content = new WebMarkupContainer("eeDetails");
content.add(buildResorucesOverviewPanel());
......
......@@ -99,6 +99,10 @@ public class ChoreographyRestClient extends BaseRestClient {
getService(MonitorInterfaceService.class).deleteInstance(choreographyInstancePK);
}
public void enactChoreography(final String choregographyName) {
getService(ChoreographyService.class).enact(choregographyName);
}
public void startChoreography(final String choreographyId) {
getService(ChoreographyService.class)
.onChoreography(choreographyId, ChoreographyAction.START, null);
......
......@@ -18,6 +18,7 @@ limitations under the License.
<wicket:panel>
<span wicket:id="detailsPanel"></span>
<span wicket:id="startPanel"></span>
<span wicket:id="enactPanel"></span>
<span wicket:id="pausePanel"></span>
<span wicket:id="stopPanel"></span>
<span wicket:id="freezePanel"></span>
......@@ -35,6 +36,10 @@ limitations under the License.
<a href="#" wicket:id="link" class="btn"><i class="fa fa-play" alt="start" title="Start"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="enactFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-cogs" alt="enact" title="Enact"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="pauseFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="pause" title="Pause"></i></a>
</wicket:fragment>
......@@ -48,7 +53,7 @@ limitations under the License.
</wicket:fragment>
<wicket:fragment wicket:id="unfreezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-bolt" alt="unfreeze icon" title="Unfreeze"></i></a>
<a href="#" wicket:id="link" class="btn"><i class="fa fa-play" alt="unfreeze icon" title="Unfreeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="resizeFragment">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment