コード例 #1
0
		public object CreatePanel(HttpRequestParams request)
		{
			Guid dashboardId = request.GetRequiredGuid("dashboard");
			string title = request.GetRequiredString("title");

			using (var session = Context.OpenSession())
			{
				var dashboard = session.Load<Dashboard>(dashboardId);

				var panel = new Panel
				{
					Id = Guid.NewGuid(),
					Title = title,
					Dashboard = dashboard,
					SortOrder = int.MaxValue
				};

				session.Save(panel);
				session.Flush();

				return panel.Id;
			}
		}
コード例 #2
0
		private object[] GetPanelListModel(Panel[] allPanels, Widget[] allWidgets, WidgetParameter[] allParameters, ISession session)
		{
			var list = new List<object>();

			foreach (var panel in allPanels)
			{
				var panelWidgets = allWidgets.Where(w => w.Panel.Id == panel.Id).ToArray();
				var widgetListModel = GetWidgetListModel(panelWidgets, allParameters, session);

				var model = new {
					id = panel.Id,
					title = panel.Title,
					widgets = widgetListModel,
					sortOrder = panel.SortOrder
				};

				list.Add(model);
			}

			return list.ToArray();
		}
コード例 #3
0
		private Tuple<EditorModel, EditorParameterModel[]> GetEditorModel(
			string type, Panel panel, ISession session)
		{
			if (!defs.ContainsKey(type))
			{
				throw new Exception(string.Format("invalid widget type {0}", type));
			}

			var def = defs[type];

			var metaData = def.GetWidgetMetaData(session, Logger) 
				?? new WidgetParameterMetaData[0];

			var parameters = metaData
						.Select(GetEditorParameterModel)
						.ToArray();

			var model = new EditorModel
			{
				typeDisplayName = def.DisplayName,
				panelId = panel.Id,
				panelTitle = panel.Title,
				dashboardId = panel.Dashboard.Id,
				dashboardTitle = panel.Dashboard.Title,
				type = type
			};

			return new Tuple<EditorModel, EditorParameterModel[]>(model, parameters);
		}