示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }