UNPKG

@metacell/geppetto-meta-client

Version:

Geppetto web frontend. Geppetto is an open-source platform to build web-based tools to visualize and simulate neuroscience data and models.

131 lines (129 loc) 5.09 kB
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var _excluded = ["path", "component", "panelName"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; } import { WidgetStatus } from './model'; export var layoutActions = { SET_LAYOUT: 'SET_LAYOUT', SET_WIDGETS: 'SET_WIDGETS', UPDATE_WIDGET: 'UPDATE_WIDGET', ACTIVATE_WIDGET: 'ACTIVATE_WIDGET', ADD_WIDGET: 'ADD_WIDGET', ADD_WIDGETS: 'ADD_WIDGETS', RESET_LAYOUT: 'RESET_LAYOUT', DESTROY_WIDGET: 'DESTROY_WIDGET', REMOVE_WIDGET: 'REMOVE_WIDGET', UPDATE_LAYOUT: 'UPDATE_LAYOUT' }; export var newWidget = function newWidget(_ref) { var path = _ref.path, component = _ref.component, panelName = _ref.panelName, others = _objectWithoutProperties(_ref, _excluded); return { type: layoutActions.ADD_WIDGET, data: _objectSpread({ id: path, instancePath: path, component: component, name: path, status: WidgetStatus.ACTIVE, panelName: panelName }, others) }; }; export var addWidget = function addWidget(widget) { return { type: layoutActions.ADD_WIDGET, data: widget }; }; export var addWidgets = function addWidgets(widgets) { return { type: layoutActions.ADD_WIDGETS, data: widgets }; }; export var setWidgets = function setWidgets(widgets) { return { type: layoutActions.SET_WIDGETS, data: widgets }; }; export var updateWidget = function updateWidget(newConf) { return { type: layoutActions.UPDATE_WIDGET, data: newConf }; }; /** * Support action: do not consider as part of the api * @param id */ export var setLayout = function setLayout(newLayout) { return { type: layoutActions.SET_LAYOUT, data: JSON.parse(JSON.stringify(newLayout.toJson())) // toJson creates a mutable object, so we need to clone it full }; }; export var updateLayout = function updateLayout(layout) { return { type: layoutActions.UPDATE_LAYOUT, data: JSON.parse(JSON.stringify(layout.toJson())) // toJson creates a mutable object, so we need to clone it full }; }; export var minimizeWidget = function minimizeWidget(id) { return { type: layoutActions.UPDATE_WIDGET, data: { id: id, status: WidgetStatus.MINIMIZED } }; }; export var maximizeWidget = function maximizeWidget(id) { return { type: layoutActions.UPDATE_WIDGET, data: { id: id, status: WidgetStatus.MAXIMIZED } }; }; export var activateWidget = function activateWidget(id) { return { type: layoutActions.ACTIVATE_WIDGET, data: { id: id } }; }; export var deleteWidget = function deleteWidget(id) { return { type: layoutActions.DESTROY_WIDGET, data: { id: id } }; }; export var destroyWidget = deleteWidget; /** * Support action: do not consider as part of the api * @param id */ export var removeWidgetFromStore = function removeWidgetFromStore(id) { return { type: layoutActions.REMOVE_WIDGET, data: { id: id } }; }; export var resetLayout = { type: layoutActions.RESET_LAYOUT };