Save dashboard layout for users individually

Is it possible to save dashboard layout for users individually. It seems the layout of the dashboard is saved global on the gateway

I don't think you can do it automatically. You can, however, save the value of the widgets property to a database for each user and load that specific configuration when that user is logged in. You may also need to keep a copy of availableWidgets if that is going to vary between users.

https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Dashboard

1 Like

Building on specifics for what @zacht mentioned:

  • To save to the database you will need to get it into a specific format, here is a sample where the data gets prepped for storing in a database:
	#Import libraries
	from com.inductiveautomation.ignition.common import TypeUtilities

	#Get current widgets and settings
	widgets = {}
	widgets = self.getSibling("Dashboard").props.widgets

	#Convert widget for storage
	widget_save = str(TypeUtilities.pyToGson(widgets))
  • Similarly once you query your database to restore your information you will need to convert it back, here is another sample:
    #Import Libraries
	import copy
	
	#Get data from query out
	pyData = system.dataset.toPyDataSet(queryResult)
	widgets = pyData[0]
	
	#Decode object to be used for the widgets
	self.props.widgets = copy.deepcopy(system.util.jsonDecode(str(widgets[0])))
3 Likes

Thanks

There is also now a free module Ignition Extensions, which among other awesome features provides a system.util.deepcopy() which correctly deep copies objects with out the need to jsonDecode.

2 Likes

Cool, I didn't know about this. Thanks! I've been waiting for a proper deepcopy function.