use of io.jmix.dashboards.model.DashboardModel in project jmix by jmix-framework.
the class PersistentDashboardEdit method setDashboardModel.
protected void setDashboardModel() {
DashboardModel model;
if (entityStates.isNew(getEditedEntity())) {
model = metadata.create(DashboardModel.class);
model.setVisualModel(metadata.create(RootLayout.class));
model.setCreatedBy(accessHelper.getCurrentUsername());
} else {
persistentDashboardDl.load();
model = converter.dashboardFromJson(getEditedEntity().getDashboardModel());
}
dashboardDc.setItem(model);
}
use of io.jmix.dashboards.model.DashboardModel in project jmix by jmix-framework.
the class PersistentDashboardEdit method onWidgetMoved.
@EventListener
public void onWidgetMoved(WidgetMovedEvent event) {
UUID targetLayoutId = event.getParentLayoutUuid();
DashboardModel dashboard = getDashboardModel();
dropLayoutTools.moveComponent(event.getSource(), targetLayoutId, event.getLocation());
uiEventPublisher.publishEvent(new DashboardRefreshEvent(dashboard.getVisualModel(), event.getSource().getId()));
}
use of io.jmix.dashboards.model.DashboardModel in project jmix by jmix-framework.
the class PersistentDashboardEdit method onDashboardDcItemChange.
@Subscribe(id = "dashboardDc", target = Target.DATA_CONTAINER)
public void onDashboardDcItemChange(InstanceContainer.ItemChangeEvent<DashboardModel> event) {
DashboardModel dashboardModel = event.getItem();
if (dashboardModel != null) {
getEditedEntity().setName(dashboardModel.getTitle());
getEditedEntity().setCode(dashboardModel.getCode());
getEditedEntity().setIsAvailableForAllUsers(dashboardModel.getIsAvailableForAllUsers());
String jsonModel = converter.dashboardToJson(dashboardModel);
getEditedEntity().setDashboardModel(jsonModel);
}
}
use of io.jmix.dashboards.model.DashboardModel in project jmix by jmix-framework.
the class DashboardImpl method refresh.
/**
* Refreshes widget with passed parameters.
* Dashboard will be refreshed with merged existed and new parameters.
* If existed parameter has the same name as one of the param from passed map, it will be overwritten by param from map.
*
* @param params map with new dashboard parameters
*/
@Override
public void refresh(Map<String, Object> params) {
DashboardModel dashboardModel = null;
if (isNotBlank(jsonPath)) {
dashboardModel = loadDashboardByJson(jsonPath);
} else if (isNotBlank(code)) {
dashboardModel = loadDashboardByCode(code);
}
if (MapUtils.isNotEmpty(params) && Objects.nonNull(dashboardModel)) {
Map<String, Parameter> newParams = params.keySet().stream().map(key -> {
Parameter parameter = metadata.create(Parameter.class);
parameter.setName(key);
parameter.setAlias(key);
parameter.setValue(parameterTransformer.createParameterValue(params.get(key)));
return parameter;
}).collect(Collectors.toMap(Parameter::getName, Function.identity()));
Map<String, Parameter> paramMap = dashboardModel.getParameters().stream().collect(Collectors.toMap(Parameter::getName, Function.identity()));
paramMap.putAll(newParams);
dashboardModel.setParameters(new ArrayList<>(paramMap.values()));
}
updateDashboard(dashboardModel);
}
use of io.jmix.dashboards.model.DashboardModel in project jmix by jmix-framework.
the class JsonConverter method dashboardFromJson.
public DashboardModel dashboardFromJson(String json) {
DashboardModel dashboardModel = gson.fromJson(json, DashboardModel.class);
RootLayout rootLayout = dashboardModel.getVisualModel();
initLayoutParents(rootLayout);
return dashboardModel;
}
Aggregations