public ActionResult ConfigureWidget(string systemName) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) return AccessDeniedView(); var widget = _widgetService.LoadWidgetBySystemName(systemName); if (widget == null) //No widget found with the specified id return RedirectToAction("List"); var model = new WidgetModel { DisplayOrder = widget.PluginDescriptor.DisplayOrder, FriendlyName = widget.PluginDescriptor.FriendlyName, SystemName = widget.PluginDescriptor.SystemName }; string actionName, controllerName; RouteValueDictionary routeValues; widget.GetConfigurationRoute(out actionName, out controllerName, out routeValues); model.ConfigurationActionName = actionName; model.ConfigurationControllerName = controllerName; model.ConfigurationRouteValues = routeValues; return View(model); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) return AccessDeniedView(); var widgetsModel = new List<WidgetModel>(); var widgets = _widgetService.LoadAllWidgets(); foreach (var widget in widgets) { var tmp1 = new WidgetModel { DisplayOrder = widget.PluginDescriptor.DisplayOrder, FriendlyName = widget.PluginDescriptor.FriendlyName, SystemName = widget.PluginDescriptor.SystemName }; tmp1.IsActive = widget.IsWidgetActive(_widgetSettings); widgetsModel.Add(tmp1); } var gridModel = new GridModel<WidgetModel> { Data = widgetsModel, Total = widgetsModel.Count() }; return View(gridModel); }
public ActionResult WidgetUpdate(WidgetModel model, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) return AccessDeniedView(); var widget = _widgetService.LoadWidgetBySystemName(model.SystemName); if (widget.IsWidgetActive(_widgetSettings)) { if (!model.IsActive) { //mark as disabled _widgetSettings.ActiveWidgetSystemNames.Remove(widget.PluginDescriptor.SystemName); _settingService.SaveSetting(_widgetSettings); } } else { if (model.IsActive) { //mark as active _widgetSettings.ActiveWidgetSystemNames.Add(widget.PluginDescriptor.SystemName); _settingService.SaveSetting(_widgetSettings); } } var pluginDescriptor = widget.PluginDescriptor; //display order pluginDescriptor.DisplayOrder = model.DisplayOrder; PluginFileParser.SavePluginDescriptionFile(pluginDescriptor); //reset plugin cache _pluginFinder.ReloadPlugins(); return List(command); }