View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.pages;
20  
21  import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
22  import java.util.ArrayList;
23  import java.util.List;
24  import org.apache.commons.lang3.tuple.Pair;
25  import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
26  import org.apache.syncope.client.console.panels.CommandsPanel;
27  import org.apache.syncope.client.console.panels.MultilevelPanel;
28  import org.apache.syncope.client.console.rest.TaskRestClient;
29  import org.apache.syncope.client.console.tasks.MacroTaskDirectoryPanel;
30  import org.apache.syncope.client.console.tasks.SchedTaskDirectoryPanel;
31  import org.apache.syncope.client.console.tasks.TaskExecutionDetails;
32  import org.apache.syncope.common.lib.to.SchedTaskTO;
33  import org.apache.syncope.common.lib.types.TaskType;
34  import org.apache.wicket.ajax.AjaxRequestTarget;
35  import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
36  import org.apache.wicket.extensions.markup.html.tabs.ITab;
37  import org.apache.wicket.markup.html.WebMarkupContainer;
38  import org.apache.wicket.markup.html.panel.Panel;
39  import org.apache.wicket.model.Model;
40  import org.apache.wicket.model.ResourceModel;
41  import org.apache.wicket.model.StringResourceModel;
42  import org.apache.wicket.request.mapper.parameter.PageParameters;
43  import org.apache.wicket.spring.injection.annot.SpringBean;
44  
45  public class Engagements extends BasePage {
46  
47      private static final long serialVersionUID = -1100228004207271271L;
48  
49      @SpringBean
50      protected TaskRestClient taskRestClient;
51  
52      public Engagements(final PageParameters parameters) {
53          super(parameters);
54  
55          body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
56  
57          WebMarkupContainer content = new WebMarkupContainer("content");
58          content.setOutputMarkupId(true);
59          content.setMarkupId("engagements");
60          content.add(new AjaxBootstrapTabbedPanel<>("tabbedPanel", buildTabList()));
61          body.add(content);
62      }
63  
64      protected List<ITab> buildTabList() {
65          List<ITab> tabs = new ArrayList<>();
66  
67          tabs.add(new AbstractTab(new ResourceModel("schedTasks")) {
68  
69              private static final long serialVersionUID = -6815067322125799251L;
70  
71              @Override
72              public Panel getPanel(final String panelId) {
73                  MultilevelPanel mlp = new MultilevelPanel(panelId);
74                  mlp.setFirstLevel(new SchedTaskDirectoryPanel<>(MultilevelPanel.FIRST_LEVEL_ID, taskRestClient,
75                          null, null, TaskType.SCHEDULED, new SchedTaskTO(), getPageReference(), true) {
76  
77                      private static final long serialVersionUID = -2195387360323687302L;
78  
79                      @Override
80                      protected void viewTaskExecs(final SchedTaskTO taskTO, final AjaxRequestTarget target) {
81                          mlp.next(
82                                  new StringResourceModel(
83                                          "task.view", this, new Model<>(Pair.of(null, taskTO))).getObject(),
84                                  new TaskExecutionDetails<>(taskTO, pageRef),
85                                  target);
86                      }
87                  });
88                  return mlp;
89              }
90          });
91  
92          tabs.add(new AbstractTab(new ResourceModel("commands")) {
93  
94              private static final long serialVersionUID = -6815067322125799251L;
95  
96              @Override
97              public Panel getPanel(final String panelId) {
98                  return new CommandsPanel(panelId, getPageReference());
99              }
100         });
101 
102         tabs.add(new AbstractTab(new ResourceModel("macroTasks")) {
103 
104             private static final long serialVersionUID = 5211692813425391144L;
105 
106             @Override
107             public Panel getPanel(final String panelId) {
108                 MultilevelPanel mlp = new MultilevelPanel(panelId);
109                 mlp.setFirstLevel(new MacroTaskDirectoryPanel(taskRestClient, mlp, getPageReference()));
110                 return mlp;
111             }
112         });
113 
114         return tabs;
115     }
116 }