Ejemplo n.º 1
0
        public static async Task <DashboardModel> DashboardGet(Func <int, WidgetOptions, Task <ChartModel <string, int> > > widgetData, IWidgetDomain widgetDomain)
        {
            int?dashboardPageId = NTContext.Context.DashboardPageId;

            if (dashboardPageId != null)
            {
                DashboardModel dashboard = await widgetDomain.DashboardGet(dashboardPageId.Value);

                foreach (WidgetModel widget in dashboard.AllWidgets)
                {
                    WidgetOptions options = new WidgetOptions()
                    {
                        XAxisLabel = widget.XAxisLabel,
                        YAxisLabel = widget.YAxisLabel,
                    };
                    widget.Chart.Model = await widgetData(widget.WidgetId, options);
                }

                return(dashboard);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        private void InitListWidget(Widget widget)
        {
            var type = widget.ListType ?? ModelUtils.ResolveType(widget.ListId);

            var widgetOptionsType       = typeof(WidgetOptions <>).MakeGenericType(type);
            var listOptionsType         = typeof(ListOptions <>).MakeGenericType(type);
            var listResultType          = typeof(ListResult <>).MakeGenericType(type);
            var listRecordType          = typeof(ListRecord <>).MakeGenericType(type);
            var listNavigateCommandType = typeof(Command <>).MakeGenericType(listRecordType);

            var widgetOptions = Activator.CreateInstance(widgetOptionsType);
            var listOptions   = Activator.CreateInstance(listOptionsType);
            var listResults   = Activator.CreateInstance(listResultType);

            var listOptionsIsLoadingProperty = listOptionsType.GetTypeInfo().GetDeclaredProperty("IsLoading");

            listOptionsIsLoadingProperty?.SetValue(listOptions, false);

            var listOptionsLoadedProperty = listOptionsType.GetTypeInfo().GetDeclaredProperty("Loaded");

            listOptionsLoadedProperty?.SetValue(listOptions, false);

            var listOptionsListResultsProperty = listOptionsType.GetTypeInfo().GetDeclaredProperty("ListResults");

            listOptionsListResultsProperty?.SetValue(listOptions, listResults);

            var widgetOptionslistOptionsProperty = widgetOptionsType.GetTypeInfo().GetDeclaredProperty("ListOptions");

            widgetOptionslistOptionsProperty?.SetValue(widgetOptions, listOptions);

            WidgetOptions.Add(widgetOptions);
        }
Ejemplo n.º 3
0
        public static IServiceCollection AddWidgets(this IServiceCollection services, Action <WidgetOptions> action = null)
        {
            var options = new WidgetOptions();

            action?.Invoke(options);

            new WidgetFactory(services, options);

            //var mvcBuilder = services.AddControllersWithViews();
            //services.AddSingleton<ITypeActivatorCache, TypeActivatorCache>();
            //services.AddSingleton<IApplicationWidgetPartManager, ApplicationWidgetPartManager>();


            //services.AddSingleton<WidgetPackageLoader>();
            //services.AddScoped<IWidgetViewInvoker, WidgetViewInvoker>();
            //services.AddScoped<IWidgetFactory, WidgetFactory>();
            //services.AddScoped<IWidgetComponentActivator, WidgetComponentActivator>();


            //using (var scope = services.BuildServiceProvider().CreateScope())
            //{
            //	var loader = scope.ServiceProvider.GetRequiredService<WidgetPackageLoader>();
            //	var manager = scope.ServiceProvider.GetRequiredService<IApplicationWidgetPartManager>();
            //	var configurationService = scope.ServiceProvider.GetRequiredService<IWidgetConfigurationService>();

            //	var widgets = loader.Load();

            //	RegisterWidgets(services, manager, configurationService, widgets);
            //}

            return(services);
        }
 public WidgetScriptsViewComponent(
     IPageWidgetManager pageWidgetManager,
     IOptions <WidgetOptions> options)
 {
     PageWidgetManager = pageWidgetManager;
     Options           = options.Value;
 }
Ejemplo n.º 5
0
        public static void AddWidgets <T>(this WidgetOptions options)
            where T : IWidgetDefinitionProvider, new()
        {
            var widgets = new T().GetDefinitions();

            options.Widgets.AddRange(widgets);
        }
Ejemplo n.º 6
0
 public static StatsFetchingOptions Factory(WidgetOptions widgetOptions)
 {
     return(new StatsFetchingOptions
     {
         Platform = widgetOptions.Platform,
         EpicUserName = widgetOptions.EpicUserName,
         ApiKey = widgetOptions.ApiKey,
         StatsFields = widgetOptions.Stats.SplitCommaSeparatedValues()
     });
 }
Ejemplo n.º 7
0
        public ActionResult Index(WidgetOptions options)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View("Error", ErrorModel.Factory(this.ModelState)));
            }

            var outputModel = new WidgetOutputModel
            {
                Options = options
            };

            return(this.View(outputModel));
        }
Ejemplo n.º 8
0
        static Main()
        {
            settings_service_component.Name    = "com.teknision.android.chameleon.settingsswitchservice.SettingsService";
            settings_service_component.Package = "com.chameleonlauncher.preorder";
            settings_service_component.Type    = "service";
            _root = jQuery.Select("#chameleon-widget");

            jQuery.OnDocumentReady(delegate()
            {
                WidgetOptions wop = new WidgetOptions();
                wop.OnLoad        = delegate()
                {
                    if (DependencyExists())
                    {
                        UpdateSwitchStates();
                    }
                    else
                    {
                        DisplayNoDependencyError();
                    }
                };

                wop.OnResume = delegate()
                {
                    if (DependencyExists())
                    {
                        UpdateSwitchStates();
                    }
                    else
                    {
                        DisplayNoDependencyError();
                    }
                };

                wop.OnTitleBar = delegate()
                {
                    jQuery.Select("#chameleon-widget").Append("we are live");
                    LaunchGlobalSettings(null);
                };

                wop.NotChameleon = delegate()
                {
                    DrawSwitches(null);
                };

                Chameleon.Widget(wop);
            });
        }
Ejemplo n.º 9
0
        private void LoadListWidget(Widget widget, int index)
        {
            var type = widget.ListType ?? ModelUtils.ResolveType(widget.ListId);

            var getListOptionsMethod        = GetType().GetTypeInfo().DeclaredMethods.FirstOrDefault(s => s.Name == "GetListOptions");
            var genericGetListOptionsMethod = getListOptionsMethod.MakeGenericMethod(type);

            var widgetOptionsType       = typeof(WidgetOptions <>).MakeGenericType(type);
            var listOptionsType         = typeof(ListOptions <>).MakeGenericType(type);
            var listResultType          = typeof(ListResult <>).MakeGenericType(type);
            var listRecordType          = typeof(ListRecord <>).MakeGenericType(type);
            var listNavigateCommandType = typeof(Command <>).MakeGenericType(listRecordType);

            var widgetOptions = Activator.CreateInstance(widgetOptionsType);
            var listOptions   = Activator.CreateInstance(listOptionsType);
            var listResults   = Activator.CreateInstance(listResultType);
            var views         = new WidgetView[] { new WidgetView {
                                                       TitleProperty = new WidgetProperty {
                                                           PropertyName = "Title"
                                                       }
                                                   } };

            var listOptionsIsLoadingProperty = listOptionsType.GetTypeInfo().GetDeclaredProperty("IsLoading");

            listOptionsIsLoadingProperty?.SetValue(listOptions, false);

            var listOptionsLoadedProperty = listOptionsType.GetTypeInfo().GetDeclaredProperty("Loaded");

            listOptionsLoadedProperty?.SetValue(listOptions, false);

            var listOptionsListResultsProperty = listOptionsType.GetTypeInfo().GetDeclaredProperty("ListResults");

            listOptionsListResultsProperty?.SetValue(listOptions, listResults);

            var widgetOptionslistOptionsProperty = widgetOptionsType.GetTypeInfo().GetDeclaredProperty("ListOptions");

            widgetOptionslistOptionsProperty?.SetValue(widgetOptions, listOptions);

            WidgetOptions.Add(widgetOptions);

            var result = genericGetListOptionsMethod.Invoke(this, new object[] { widget, index });
        }
Ejemplo n.º 10
0
        public async Task GetListResults <T>(WidgetOptions <T> widgetOptions, int index)
        {
            if (widgetOptions.ListOptions.Initialized && !widgetOptions.ListOptions.Loaded)
            {
                widgetOptions.ListOptions.IsLoading = true;

                var service = FreshTinyIOCBuiltIn.Current.Resolve <IGenericService <T> >();

                widgetOptions.ListOptions.ListResults = await service.Get(new GetOptions
                {
                    Url             = widgetOptions.ListOptions.Url,
                    PageIndex       = 1,
                    PageSize        = 10,
                    ViewId          = widgetOptions.ListOptions.SelectedViewId,
                    QueryParameters = new Dictionary <string, object> {
                    }
                });

                widgetOptions.ListOptions.IsLoading = false;
                widgetOptions.ListOptions.Loaded    = true;

                WidgetOptions[index] = widgetOptions;
            }
        }
Ejemplo n.º 11
0
        public void SubscribeOnStatsUpdates(WidgetOptions options)
        {
            var groupName = this.GetGroupName(options.EpicUserName, options.Platform, options.ApiKey);

            this.Groups.Add(this.Context.ConnectionId, groupName);
        }
Ejemplo n.º 12
0
        public override async Task <ChartModel <string, int> > GetWidgetData(int widgetId, WidgetOptions options)
        {
            string sql = null;

            object[] parameters = new object[] { this.CompanyId };

            switch (widgetId)
            {
            case 1:
                sql = "quarry.WidgetQuarryMaterialCounts @CompanyId = {0}";
                break;

            case 2:
                sql = "quarry.WidgetQuarryProductTypeMaterialCounts @CompanyId = {0}";
                break;

            case 3:
                sql = "quarry.WidgetQuarryMaterialColourMaterialCounts @CompanyId = {0}";
                break;

            case 4:
                sql = "quarry.WidgetProductTypeMaterialCounts @CompanyId = {0}";
                break;

            case 5:
                sql = "quarry.WidgetProductTypeQuarryMaterialCounts @CompanyId = {0}";
                break;

            case 6:
                sql = "quarry.WidgetProductTypeMaterialColourMaterialCounts @CompanyId = {0}";
                break;

            case 7:
                sql = "quarry.WidgetMaterialColourMaterialCounts @CompanyId = {0}";
                break;

            case 8:
                sql = "quarry.WidgetMaterialColourQuarryMaterialCounts @CompanyId = {0}";
                break;

            case 9:
                sql = "quarry.WidgetMaterialColourProductTypeMaterialCounts @CompanyId = {0}";
                break;

            case 10:
                sql = "quarry.WidgetYardMaterialCounts @CompanyId = {0}";
                break;

            case 11:
                sql = "quarry.WidgetYardProductTypeMaterialCounts @CompanyId = {0}";
                break;
            }

            return(await ChartFactory.Create <string, int>(options, this.repository.DbContext, sql, parameters));
        }
Ejemplo n.º 13
0
        public override async Task <ChartModel <string, int> > GetWidgetData(int widgetId, WidgetOptions options)
        {
            string sql = null;

            object[] parameters = new object[] { this.CompanyId };

            switch (widgetId)
            {
            default:
                break;
            }

            return(await ChartFactory.Create <string, int, FleetDbContext>(options, this.repository.DbContext, sql, parameters));
        }
Ejemplo n.º 14
0
 public DashboardViewModel(string dashboardName, DashboardOptions dashboardOptions, WidgetOptions widgetOptions)
 {
     Dashboard        = dashboardOptions.Dashboards.Single(d => d.Name.Equals(dashboardName));
     DashboardOptions = dashboardOptions;
     WidgetOptions    = widgetOptions;
 }
Ejemplo n.º 15
0
        public async Task <IViewComponentResult> InvokeAsync(string dashboardName, DashboardOptions dashboardOptions, WidgetOptions widgetOptions)
        {
            var model = new DashboardViewModel(dashboardName, dashboardOptions, widgetOptions);

            return(View("~/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/Default.cshtml", model));
        }
Ejemplo n.º 16
0
 public MyDashboardModel(IOptions <DashboardOptions> dashboardOptions, IOptions <WidgetOptions> widgetOptions)
 {
     _dashboardOptions = dashboardOptions.Value;
     _widgetOptions    = widgetOptions.Value;
 }
Ejemplo n.º 17
0
 public DashboardViewComponent(IOptions <DashboardOptions> dashboardOptions, IOptions <WidgetOptions> widgetOptions)
 {
     _dashboardOptions = dashboardOptions.Value;
     _widgetOptions    = widgetOptions.Value;
 }
Ejemplo n.º 18
0
 public MyWidget(WidgetOptions options)
 {
     Server = options.Server;
     Port   = options.Port;