Skip to content
Snippets Groups Projects
Commit 151cce25 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#585 - load images for each chart

parent 4f74b417
No related branches found
No related tags found
No related merge requests found
...@@ -30,8 +30,9 @@ public class Chart ...@@ -30,8 +30,9 @@ public class Chart
private ChartDisplayType displayType; private ChartDisplayType displayType;
private ChartGroupType groupType; private ChartGroupType groupType;
private String previewImageFileName;
public Chart(String name, String script, ChartType type, int version, ChartDisplayType displayType, ChartGroupType groupType) public Chart(String name, String script, ChartType type, int version, ChartDisplayType displayType, ChartGroupType groupType, String previewImageFileName)
{ {
this.name = name; this.name = name;
this.script = script; this.script = script;
...@@ -39,6 +40,7 @@ public class Chart ...@@ -39,6 +40,7 @@ public class Chart
this.version = version; this.version = version;
this.displayType = displayType; this.displayType = displayType;
this.groupType = groupType; this.groupType = groupType;
this.previewImageFileName = previewImageFileName;
} }
public Chart() public Chart()
...@@ -115,6 +117,16 @@ public class Chart ...@@ -115,6 +117,16 @@ public class Chart
this.groupType = chartGroupType; this.groupType = chartGroupType;
} }
public String getPreviewImageFileName()
{
return previewImageFileName;
}
public void setPreviewImageFileName(String previewImageFileName)
{
this.previewImageFileName = previewImageFileName;
}
@Override @Override
public String toString() public String toString()
{ {
...@@ -126,6 +138,7 @@ public class Chart ...@@ -126,6 +138,7 @@ public class Chart
", version=" + version + ", version=" + version +
", displayType=" + displayType + ", displayType=" + displayType +
", chartGroupType=" + groupType + ", chartGroupType=" + groupType +
", previewImageFileName=" + previewImageFileName +
'}'; '}';
} }
...@@ -135,12 +148,12 @@ public class Chart ...@@ -135,12 +148,12 @@ public class Chart
if(this == o) return true; if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false; if(o == null || getClass() != o.getClass()) return false;
Chart chart = (Chart) o; Chart chart = (Chart) o;
return version == chart.version && Objects.equals(ID, chart.ID) && Objects.equals(name, chart.name) && Objects.equals(script, chart.script) && type == chart.type && displayType == chart.displayType && groupType == chart.groupType; return version == chart.version && Objects.equals(ID, chart.ID) && Objects.equals(name, chart.name) && Objects.equals(script, chart.script) && type == chart.type && displayType == chart.displayType && groupType == chart.groupType && Objects.equals(previewImageFileName, chart.previewImageFileName);
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
return Objects.hash(ID, name, script, type, version, displayType, groupType); return Objects.hash(ID, name, script, type, version, displayType, groupType, previewImageFileName);
} }
} }
\ No newline at end of file
...@@ -73,6 +73,7 @@ public class ChartService implements Resettable, AccessAllEntities<Chart> ...@@ -73,6 +73,7 @@ public class ChartService implements Resettable, AccessAllEntities<Chart>
currentChart.setScript(chart.getScript()); currentChart.setScript(chart.getScript());
currentChart.setDisplayType(chart.getDisplayType()); currentChart.setDisplayType(chart.getDisplayType());
currentChart.setGroupType(chart.getGroupType()); currentChart.setGroupType(chart.getGroupType());
currentChart.setPreviewImageFileName(chart.getPreviewImageFileName());
chartRepository.save(currentChart); chartRepository.save(currentChart);
} }
} }
......
...@@ -16,39 +16,39 @@ public class DefaultCharts ...@@ -16,39 +16,39 @@ public class DefaultCharts
public static final Chart CHART_DEFAULT = new Chart(null, public static final Chart CHART_DEFAULT = new Chart(null,
getChartFromFile("charts/Default.js"), getChartFromFile("charts/Default.js"),
ChartType.CUSTOM, -1, ChartDisplayType.CUSTOM, ChartGroupType.NONE); ChartType.CUSTOM, -1, ChartDisplayType.CUSTOM, ChartGroupType.NONE, null);
private static final Chart CHART_ACCOUNT_SUM_PER_DAY = new Chart("charts.default.accountSumPerDay", private static final Chart CHART_ACCOUNT_SUM_PER_DAY = new Chart("charts.default.accountSumPerDay",
getChartFromFile("charts/AccountSumPerDay.js"), getChartFromFile("charts/AccountSumPerDay.js"),
ChartType.DEFAULT, 10, ChartDisplayType.LINE, ChartGroupType.NONE); ChartType.DEFAULT, 11, ChartDisplayType.LINE, ChartGroupType.NONE, "accountSumPerDay.png");
private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BAR = new Chart("charts.default.incomesAndExpendituresPerMonthBar", private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BAR = new Chart("charts.default.incomesAndExpendituresPerMonthBar",
getChartFromFile("charts/IncomesAndExpendituresPerMonthBar.js"), getChartFromFile("charts/IncomesAndExpendituresPerMonthBar.js"),
ChartType.DEFAULT, 10, ChartDisplayType.BAR, ChartGroupType.MONTH); ChartType.DEFAULT, 11, ChartDisplayType.BAR, ChartGroupType.MONTH, "incomesAndExpendituresPerMonthBar.png");
private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_LINE = new Chart("charts.default.incomesAndExpendituresPerMonthLine", private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_LINE = new Chart("charts.default.incomesAndExpendituresPerMonthLine",
getChartFromFile("charts/IncomesAndExpendituresPerMonthLine.js"), getChartFromFile("charts/IncomesAndExpendituresPerMonthLine.js"),
ChartType.DEFAULT, 10, ChartDisplayType.LINE, ChartGroupType.MONTH); ChartType.DEFAULT, 11, ChartDisplayType.LINE, ChartGroupType.MONTH, "incomesAndExpendituresPerMonthLine.png");
private static final Chart CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_BAR = new Chart("charts.default.incomesAndExpendituresByCategoryBar", private static final Chart CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_BAR = new Chart("charts.default.incomesAndExpendituresByCategoryBar",
getChartFromFile("charts/IncomesAndExpendituresByCategoryBar.js"), getChartFromFile("charts/IncomesAndExpendituresByCategoryBar.js"),
ChartType.DEFAULT, 5, ChartDisplayType.BAR, ChartGroupType.NONE); ChartType.DEFAULT, 6, ChartDisplayType.BAR, ChartGroupType.NONE, "incomesAndExpendituresByCategoryBar.png");
private static final Chart CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_PIE = new Chart("charts.default.incomesAndExpendituresByCategoryPie", private static final Chart CHART_INCOMES_AND_EXPENDITURES_BY_CATEGORY_PIE = new Chart("charts.default.incomesAndExpendituresByCategoryPie",
getChartFromFile("charts/IncomesAndExpendituresByCategoryPie.js"), getChartFromFile("charts/IncomesAndExpendituresByCategoryPie.js"),
ChartType.DEFAULT, 6, ChartDisplayType.PIE, ChartGroupType.NONE); ChartType.DEFAULT, 7, ChartDisplayType.PIE, ChartGroupType.NONE, "incomesAndExpendituresByCategoryPie.png");
private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BY_CATEGORIES = new Chart("charts.default.incomesAndExpendituresPerMonthByCategories", private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_MONTH_BY_CATEGORIES = new Chart("charts.default.incomesAndExpendituresPerMonthByCategories",
getChartFromFile("charts/IncomesAndExpendituresPerMonthByCategories.js"), getChartFromFile("charts/IncomesAndExpendituresPerMonthByCategories.js"),
ChartType.DEFAULT, 20, ChartDisplayType.BAR, ChartGroupType.MONTH); ChartType.DEFAULT, 21, ChartDisplayType.BAR, ChartGroupType.MONTH, "incomesAndExpendituresPerMonthByCategories.png");
private static final Chart CHART_REST_PER_MONTH = new Chart("charts.default.restPerMonth", private static final Chart CHART_REST_PER_MONTH = new Chart("charts.default.restPerMonth",
getChartFromFile("charts/RestPerMonth.js"), getChartFromFile("charts/RestPerMonth.js"),
ChartType.DEFAULT, 6, ChartDisplayType.BAR, ChartGroupType.MONTH); ChartType.DEFAULT, 7, ChartDisplayType.BAR, ChartGroupType.MONTH, "restPerMonth.png");
private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_YEAR_BAR = new Chart("charts.default.incomesAndExpendituresPerYearBar", private static final Chart CHART_INCOMES_AND_EXPENDITURES_PER_YEAR_BAR = new Chart("charts.default.incomesAndExpendituresPerYearBar",
getChartFromFile("charts/IncomesAndExpendituresPerYearBar.js"), getChartFromFile("charts/IncomesAndExpendituresPerYearBar.js"),
ChartType.DEFAULT, 5, ChartDisplayType.BAR, ChartGroupType.YEAR); ChartType.DEFAULT, 6, ChartDisplayType.BAR, ChartGroupType.YEAR, "incomesAndExpendituresPerYearBar.png");
private DefaultCharts() private DefaultCharts()
{ {
......
...@@ -296,7 +296,7 @@ ...@@ -296,7 +296,7 @@
<div class="col s6 m4 l3 center-align"> <div class="col s6 m4 l3 center-align">
<div class="card chart-preview background-grey-dark"> <div class="card chart-preview background-grey-dark">
<div class="card-image"> <div class="card-image">
<img src="<@s.url '/images/charts/a.png'/>"> <img src="<@s.url '/images/charts/' + chart.getPreviewImageFileName()!"placeholder.png"/>">
</div> </div>
<div class="card-action bold"> <div class="card-action bold">
${chartFunctions.getChartName(chart)} ${chartFunctions.getChartName(chart)}
......
...@@ -68,7 +68,7 @@ class DatabaseParser_v7_convertToInternalTest ...@@ -68,7 +68,7 @@ class DatabaseParser_v7_convertToInternalTest
DatabaseParser_v7 importer = new DatabaseParser_v7(json); DatabaseParser_v7 importer = new DatabaseParser_v7(json);
InternalDatabase database = importer.parseDatabaseFromJSON().convertToInternal(); InternalDatabase database = importer.parseDatabaseFromJSON().convertToInternal();
final Chart chart = new Chart("The best chart", "/* This list will be dynamically filled with all the transactions between\r\n* the start and and date you select on the \"Show Chart\" page\r\n* and filtered according to your specified filter.\r\n* An example entry for this list and tutorial about how to create custom charts ca be found in the BudgetMaster wiki:\r\n* https://github.com/deadlocker8/BudgetMaster/wiki/How-to-create-custom-charts\r\n*/\r\nvar transactionData \u003d [];\r\n\r\n// Prepare your chart settings here (mandatory)\r\nvar plotlyData \u003d [{\r\n x: [],\r\n y: [],\r\n type: \u0027bar\u0027\r\n}];\r\n\r\n// Add your Plotly layout settings here (optional)\r\nvar plotlyLayout \u003d {};\r\n\r\n// Add your Plotly configuration settings here (optional)\r\nvar plotlyConfig \u003d {\r\n showSendToCloud: false,\r\n displaylogo: false,\r\n showLink: false,\r\n responsive: true\r\n};\r\n\r\n// Don\u0027t touch this line\r\nPlotly.newPlot(\"containerID\", plotlyData, plotlyLayout, plotlyConfig);\r\n", ChartType.CUSTOM, 7, ChartDisplayType.CUSTOM, ChartGroupType.NONE); final Chart chart = new Chart("The best chart", "/* This list will be dynamically filled with all the transactions between\r\n* the start and and date you select on the \"Show Chart\" page\r\n* and filtered according to your specified filter.\r\n* An example entry for this list and tutorial about how to create custom charts ca be found in the BudgetMaster wiki:\r\n* https://github.com/deadlocker8/BudgetMaster/wiki/How-to-create-custom-charts\r\n*/\r\nvar transactionData \u003d [];\r\n\r\n// Prepare your chart settings here (mandatory)\r\nvar plotlyData \u003d [{\r\n x: [],\r\n y: [],\r\n type: \u0027bar\u0027\r\n}];\r\n\r\n// Add your Plotly layout settings here (optional)\r\nvar plotlyLayout \u003d {};\r\n\r\n// Add your Plotly configuration settings here (optional)\r\nvar plotlyConfig \u003d {\r\n showSendToCloud: false,\r\n displaylogo: false,\r\n showLink: false,\r\n responsive: true\r\n};\r\n\r\n// Don\u0027t touch this line\r\nPlotly.newPlot(\"containerID\", plotlyData, plotlyLayout, plotlyConfig);\r\n", ChartType.CUSTOM, 7, ChartDisplayType.CUSTOM, ChartGroupType.NONE, null);
chart.setID(9); chart.setID(9);
assertThat(database.getCharts()).hasSize(1) assertThat(database.getCharts()).hasSize(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment