You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/06/01 15:29:13 UTC
[3/6] syncope git commit: Replace the (apparently now unsupported)
wicket-chartjs
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/widgets/CompletenessWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/CompletenessWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/CompletenessWidget.java
index aee979f..5f26ffd 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/CompletenessWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/CompletenessWidget.java
@@ -18,12 +18,13 @@
*/
package org.apache.syncope.client.console.widgets;
-import com.pingunaut.wicket.chartjs.chart.impl.Doughnut;
-import com.pingunaut.wicket.chartjs.core.panel.DoughnutChartPanel;
import java.util.Map;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
+import org.apache.syncope.client.console.chartjs.ChartJSPanel;
+import org.apache.syncope.client.console.chartjs.Doughnut;
+import org.apache.syncope.client.console.chartjs.DoughnutChartData;
import org.apache.syncope.client.console.pages.Notifications;
import org.apache.syncope.client.console.pages.Policies;
import org.apache.syncope.client.console.pages.Security;
@@ -43,7 +44,7 @@ public class CompletenessWidget extends BaseWidget {
private Map<String, Boolean> confCompleteness;
- private final DoughnutChartPanel chart;
+ private final ChartJSPanel chart;
private final WebMarkupContainer actions;
@@ -66,7 +67,7 @@ public class CompletenessWidget extends BaseWidget {
Pair<Doughnut, Integer> built = build(confCompleteness);
- chart = new DoughnutChartPanel("chart", Model.of(built.getLeft()));
+ chart = new ChartJSPanel("chart", Model.of(built.getLeft()));
add(chart);
actions = new WebMarkupContainer("actions");
@@ -136,9 +137,9 @@ public class CompletenessWidget extends BaseWidget {
}
doughnut.getData().add(
- new LabeledDoughnutChartData(done, "blue", getString("done")));
+ new DoughnutChartData(done, "blue", getString("done")));
doughnut.getData().add(
- new LabeledDoughnutChartData(100 - done, "red", getString("todo") + ": " + todo));
+ new DoughnutChartData(100 - done, "red", getString("todo") + ": " + todo));
return Pair.of(doughnut, todo);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledBarDataSet.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledBarDataSet.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledBarDataSet.java
deleted file mode 100644
index a1bf3c9..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledBarDataSet.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.widgets;
-
-import com.pingunaut.wicket.chartjs.data.sets.BarDataSet;
-import java.util.List;
-
-public class LabeledBarDataSet extends BarDataSet {
-
- private static final long serialVersionUID = -6571823370630502272L;
-
- private String label;
-
- public LabeledBarDataSet(final List<? extends Number> values) {
- super(values);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(final String label) {
- this.label = label;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledDoughnutChartData.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledDoughnutChartData.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledDoughnutChartData.java
deleted file mode 100644
index 52ece37..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LabeledDoughnutChartData.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.widgets;
-
-import com.pingunaut.wicket.chartjs.data.DoughnutChartData;
-
-public class LabeledDoughnutChartData extends DoughnutChartData {
-
- private static final long serialVersionUID = -660949108690472467L;
-
- private String label;
-
- public LabeledDoughnutChartData(final Integer value, final String color) {
- super(value, color);
- }
-
- public LabeledDoughnutChartData(final Integer value, final String color, final String label) {
- super(value, color);
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(final String label) {
- this.label = label;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
index 5a42f24..a06f589 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
@@ -18,12 +18,12 @@
*/
package org.apache.syncope.client.console.widgets;
-import com.pingunaut.wicket.chartjs.chart.impl.Line;
-import com.pingunaut.wicket.chartjs.core.panel.LineChartPanel;
-import com.pingunaut.wicket.chartjs.data.sets.LineDataSet;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.syncope.client.console.chartjs.ChartJSPanel;
+import org.apache.syncope.client.console.chartjs.Line;
+import org.apache.syncope.client.console.chartjs.LineDataSet;
import org.apache.syncope.common.lib.info.SystemInfo;
import org.apache.wicket.model.Model;
@@ -31,30 +31,20 @@ public class LoadWidget extends BaseWidget {
private static final long serialVersionUID = -816175678514035085L;
- private final LineChartPanel chart;
+ private final ChartJSPanel chart;
public LoadWidget(final String id, final SystemInfo systeminfo) {
super(id);
setOutputMarkupId(true);
- chart = new LineChartPanel("chart", Model.of(build(systeminfo)));
+ chart = new ChartJSPanel("chart", Model.of(build(systeminfo)));
add(chart);
}
private Line build(final SystemInfo systeminfo) {
- List<String> labels = new ArrayList<>();
-
List<Double> cpuValues = new ArrayList<>();
List<Long> memValues = new ArrayList<>();
- for (SystemInfo.LoadInstant instant : systeminfo.getLoad()) {
- labels.add(DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.
- format(systeminfo.getStartTime() + instant.getUptime()));
-
- cpuValues.add(instant.getSystemLoadAverage() * 1000);
- memValues.add(instant.getTotalMemory());
- }
-
Line line = new Line();
line.getOptions().setPointDot(false);
line.getOptions().setDatasetFill(false);
@@ -63,21 +53,25 @@ public class LoadWidget extends BaseWidget {
line.getOptions().setShowScale(false);
line.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>");
- line.getData().setLabels(labels);
+ for (SystemInfo.LoadInstant instant : systeminfo.getLoad()) {
+ line.getData().getLabels().add(DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT.
+ format(systeminfo.getStartTime() + instant.getUptime()));
+
+ cpuValues.add(instant.getSystemLoadAverage() * 1000);
+ memValues.add(instant.getTotalMemory());
+ }
- List<LineDataSet> datasets = new ArrayList<>();
LineDataSet cpuDataSet = new LineDataSet(cpuValues);
cpuDataSet.setLabel("CPU");
cpuDataSet.setPointColor("purple");
cpuDataSet.setStrokeColor("purple");
- datasets.add(cpuDataSet);
+ line.getData().getDatasets().add(cpuDataSet);
LineDataSet memDataSet = new LineDataSet(memValues);
memDataSet.setLabel("MEM");
memDataSet.setPointColor("grey");
memDataSet.setStrokeColor("grey");
- datasets.add(memDataSet);
- line.getData().setDatasets(datasets);
+ line.getData().getDatasets().add(memDataSet);
return line;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
index e11b5db..c84a640 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
@@ -18,9 +18,10 @@
*/
package org.apache.syncope.client.console.widgets;
-import com.pingunaut.wicket.chartjs.chart.impl.Doughnut;
-import com.pingunaut.wicket.chartjs.core.panel.DoughnutChartPanel;
import java.util.Map;
+import org.apache.syncope.client.console.chartjs.ChartJSPanel;
+import org.apache.syncope.client.console.chartjs.Doughnut;
+import org.apache.syncope.client.console.chartjs.DoughnutChartData;
import org.apache.wicket.model.Model;
public class UsersByStatusWidget extends BaseWidget {
@@ -31,14 +32,14 @@ public class UsersByStatusWidget extends BaseWidget {
private Map<String, Integer> usersByStatus;
- private final DoughnutChartPanel chart;
+ private final ChartJSPanel chart;
public UsersByStatusWidget(final String id, final Map<String, Integer> usersByStatus) {
super(id);
this.usersByStatus = usersByStatus;
setOutputMarkupId(true);
- chart = new DoughnutChartPanel("chart", Model.of(build(usersByStatus)));
+ chart = new ChartJSPanel("chart", Model.of(build(usersByStatus)));
add(chart);
}
@@ -49,7 +50,7 @@ public class UsersByStatusWidget extends BaseWidget {
int i = 0;
for (Map.Entry<String, Integer> entry : usersByStatus.entrySet()) {
- doughnut.getData().add(new LabeledDoughnutChartData(entry.getValue(), COLORS[i % 5], entry.getKey()));
+ doughnut.getData().add(new DoughnutChartData(entry.getValue(), COLORS[i % 5], entry.getKey()));
i++;
}
@@ -64,5 +65,4 @@ public class UsersByStatusWidget extends BaseWidget {
}
return false;
}
-
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/resources/org/apache/syncope/client/console/chartjs/ChartJSPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/chartjs/ChartJSPanel.html b/client/console/src/main/resources/org/apache/syncope/client/console/chartjs/ChartJSPanel.html
new file mode 100644
index 0000000..25b2973
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/chartjs/ChartJSPanel.html
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:panel>
+ <canvas wicket:id="chart"></canvas>
+ </wicket:panel>
+</html>
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/client/console/src/main/resources/org/apache/syncope/client/console/pages/Dashboard.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Dashboard.html b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Dashboard.html
index 3c47012..a324d8a 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Dashboard.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Dashboard.html
@@ -17,6 +17,17 @@ specific language governing permissions and limitations
under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+ <wicket:head>
+ <script type="text/javascript" src="webjars/chart.js/${chartjs.version}/Chart.min.js"></script>
+ <script type="text/javascript">
+ var WicketCharts = {};
+ // Get context with jQuery - using jQuery's .get() method.
+ function buildChart(markupId) {
+ var ctx = $('#' + markupId).get(0).getContext('2d');
+ return new Chart(ctx);
+ }
+ </script>
+ </wicket:head>
<wicket:extend>
<section class="content" wicket:id="content">
<div class="box">
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
index d5c4679..7a98f90 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
@@ -228,20 +228,20 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
doHandle(any);
return true;
} catch (IgnoreProvisionException e) {
- ProvisioningReport result = profile.getResults().stream()
- .filter(r -> anyKey.equalsIgnoreCase(r.getKey()))
- .findFirst()
- .orElse(null);
-
+ ProvisioningReport result = profile.getResults().stream().
+ filter(report -> anyKey.equalsIgnoreCase(report.getKey())).
+ findFirst().
+ orElse(null);
if (result == null) {
result = new ProvisioningReport();
+ result.setKey(anyKey);
+ result.setAnyType(any == null ? null : any.getType().getKey());
+
profile.getResults().add(result);
}
result.setOperation(ResourceOperation.NONE);
- result.setAnyType(any == null ? null : any.getType().getKey());
result.setStatus(ProvisioningReport.Status.IGNORE);
- result.setKey(anyKey);
LOG.warn("Ignoring during push", e);
return true;
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/widgets/CamelMetricsWidget.java
----------------------------------------------------------------------
diff --git a/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/widgets/CamelMetricsWidget.java b/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/widgets/CamelMetricsWidget.java
index ce1e461..1ccc74d 100644
--- a/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/widgets/CamelMetricsWidget.java
+++ b/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/widgets/CamelMetricsWidget.java
@@ -18,14 +18,13 @@
*/
package org.apache.syncope.client.console.widgets;
-import com.pingunaut.wicket.chartjs.chart.impl.Bar;
-import com.pingunaut.wicket.chartjs.core.panel.BarChartPanel;
-import com.pingunaut.wicket.chartjs.data.sets.BarDataSet;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.syncope.client.console.annotations.ExtWidget;
+import org.apache.syncope.client.console.chartjs.Bar;
+import org.apache.syncope.client.console.chartjs.BarDataSet;
+import org.apache.syncope.client.console.chartjs.ChartJSPanel;
import org.apache.syncope.client.console.rest.CamelRoutesRestClient;
import org.apache.syncope.client.console.wicket.ajax.IndicatorAjaxTimerBehavior;
import org.apache.syncope.common.lib.to.CamelMetrics;
@@ -42,7 +41,7 @@ public class CamelMetricsWidget extends BaseExtWidget {
private List<CamelMetrics.MeanRate> meanRates;
- private final BarChartPanel chart;
+ private final ChartJSPanel chart;
private final CamelRoutesRestClient restClient = new CamelRoutesRestClient();
@@ -59,7 +58,7 @@ public class CamelMetricsWidget extends BaseExtWidget {
meanRates.add(metrics.getResponseMeanRates().get(i));
}
- chart = new BarChartPanel("chart", Model.of(build(meanRates)));
+ chart = new ChartJSPanel("chart", Model.of(build(meanRates)));
container.add(chart);
container.add(new IndicatorAjaxTimerBehavior(Duration.seconds(60)) {
@@ -84,8 +83,6 @@ public class CamelMetricsWidget extends BaseExtWidget {
private Bar build(final List<CamelMetrics.MeanRate> meanRates) {
Bar bar = new Bar();
bar.getOptions().setScaleBeginAtZero(true);
- bar.getOptions().setScaleShowGridLines(true);
- bar.getOptions().setScaleGridLineWidth(1);
bar.getOptions().setBarShowStroke(true);
bar.getOptions().setBarStrokeWidth(2);
bar.getOptions().setBarValueSpacing(5);
@@ -93,13 +90,13 @@ public class CamelMetricsWidget extends BaseExtWidget {
bar.getOptions().setResponsive(true);
bar.getOptions().setMaintainAspectRatio(true);
- bar.getData().setLabels(
+ bar.getData().getLabels().addAll(
meanRates.stream().map(input -> input.getRouteId()).collect(Collectors.toList()));
BarDataSet dataset = new BarDataSet(
meanRates.stream().map(input -> input.getValue()).collect(Collectors.toList()));
dataset.setFillColor("blue");
- bar.getData().setDatasets(Collections.singletonList(dataset));
+ bar.getData().getDatasets().add(dataset);
return bar;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/e78f91e2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 368be71..547ed90 100644
--- a/pom.xml
+++ b/pom.xml
@@ -439,11 +439,11 @@ under the License.
<codemirror.version>5.33.0</codemirror.version>
<googlediffmatchpath.version>20121119-1</googlediffmatchpath.version>
<jsplumb.version>2.0.7</jsplumb.version>
+ <chartjs.version>1.0.2</chartjs.version>
<wicket.version>7.10.0</wicket.version>
<wicket-jqueryui.version>7.10.2</wicket-jqueryui.version>
<wicket-bootstrap.version>0.10.17</wicket-bootstrap.version>
- <wicket-chartjs.version>7.0.1</wicket-chartjs.version>
<angular.version>1.6.10</angular.version>
<angular-ui-router.version>0.3.2</angular-ui-router.version>
@@ -1213,22 +1213,7 @@ under the License.
<artifactId>momentjs</artifactId>
</exclusion>
</exclusions>
- </dependency>
- <dependency>
- <groupId>com.pingunaut</groupId>
- <artifactId>wicket-chartjs</artifactId>
- <version>${wicket-chartjs.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ </dependency>
<!-- /Wicket -->
<dependency>
@@ -1355,6 +1340,11 @@ under the License.
<version>${jsplumb.version}</version>
</dependency>
<dependency>
+ <groupId>org.webjars.bower</groupId>
+ <artifactId>chart.js</artifactId>
+ <version>${chartjs.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery-cookie</artifactId>
<version>${jquery-cookie.version}</version>