use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class GraphicalViewDwr method saveAnalogGraphicComponent.
@DwrPermission(user = true)
public ProcessResult saveAnalogGraphicComponent(String viewComponentId, double min, double max, boolean displayText, String imageSetId) {
ProcessResult response = new ProcessResult();
// Validate
if (min >= max)
response.addContextualMessage("graphicRendererAnalogMin", "viewEdit.graphic.invalidMinMax");
ImageSet imageSet = getImageSet(imageSetId);
if (imageSet == null)
response.addContextualMessage("graphicRendererAnalogImageSet", "viewEdit.graphic.missingImageSet");
if (!response.getHasMessages()) {
AnalogGraphicComponent c = (AnalogGraphicComponent) getViewComponent(viewComponentId);
c.setMin(min);
c.setMax(max);
c.setDisplayText(displayText);
c.tsetImageSet(imageSet);
resetPointComponent(c);
}
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class GraphicalViewDwr method saveImageChartComponent.
@DwrPermission(user = true)
public ProcessResult saveImageChartComponent(String viewComponentId, String name, int width, int height, int durationType, int durationPeriods, int updatePeriodType, int updatePeriods, List<StringStringPair> childPointIds) {
ProcessResult response = new ProcessResult();
validateCompoundComponent(response, name);
if (width < 1)
response.addContextualMessage("imageChartWidth", "validate.greaterThanZero");
if (height < 1)
response.addContextualMessage("imageChartHeight", "validate.greaterThanZero");
if (!Common.TIME_PERIOD_CODES.isValidId(durationType))
response.addContextualMessage("imageChartDurationType", "validate.invalidValue");
if (durationPeriods <= 0)
response.addContextualMessage("imageChartDurationPeriods", "validate.greaterThanZero");
if (!Common.TIME_PERIOD_CODES.isValidId(updatePeriodType))
response.addContextualMessage("imageChartUpdatePeriodType", "validate.invalidValue");
if (updatePeriods < 0)
response.addContextualMessage("imageChartUpdatePeriods", "validate.cannotBeNegative");
if (!response.getHasMessages()) {
ImageChartComponent c = (ImageChartComponent) getViewComponent(viewComponentId);
c.setName(name);
c.setWidth(width);
c.setHeight(height);
c.setDurationType(durationType);
c.setDurationPeriods(durationPeriods);
c.setUpdatePeriodType(updatePeriodType);
c.setUpdatePeriods(updatePeriods);
saveCompoundPoints(c, childPointIds);
}
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class GraphicalViewDwr method setViewPoint.
/**
* Allows the setting of a given data point. Overrides BaseDwr to resolve the point view id.
*
* @param pointId
* @param valueStr
* @return
*/
@DwrPermission(user = true)
public String setViewPoint(String viewComponentId, String valueStr) {
User user = Common.getUser();
GraphicalView view = GraphicalViewsCommon.getUserView(user);
DataPointVO point = view.findDataPoint(viewComponentId);
if (point != null) {
// Check that setting is allowed.
if (!view.isSetter(user))
throw new PermissionException(new TranslatableMessage("permission.exception.setDataPoint", user.getUsername()), user);
// Try setting the point.
setPointImpl(point, valueStr, user);
}
return viewComponentId;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class GraphicalViewDwr method saveHtmlComponent.
//
// Save view component
//
@DwrPermission(user = true)
public void saveHtmlComponent(String viewComponentId, String content) {
HtmlComponent c = (HtmlComponent) getViewComponent(viewComponentId);
c.setContent(content);
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class GraphicalViewDwr method saveView.
@DwrPermission(user = true)
public ProcessResult saveView(String name, String xid, int anonymousAccess, String readPermission, String setPermission, String editPermission) {
ProcessResult result = new ProcessResult();
User user = Common.getUser();
GraphicalView view = GraphicalViewsCommon.getUserEditView(user);
view.setName(name);
view.setXid(xid);
view.setAnonymousAccess(anonymousAccess);
view.setReadPermission(readPermission);
view.setSetPermission(setPermission);
view.setEditPermission(editPermission);
view.validate(result);
if (!result.getHasMessages()) {
view.setUserId(user.getId());
new GraphicalViewDao().saveView(view);
result.addData("view", view);
}
return result;
}
Aggregations