Ejemplo n.º 1
0
        private static Elt CreateParamterUpdateElement(Var <JobUpdateViewModel> map, int i, JobUpdateViewModel juvm)
        {
            var updateParamTypeLens = map.Lens(
                uvm => uvm.UpdateData.ParamUpdates[i].UpdateParamType,
                (a, b) =>
            {
                a.UpdateData.ParamUpdates[i].UpdateParamType = b;
                return(a);
            });
            var newParamTypeLens = map.Lens(
                uvm => uvm.UpdateData.ParamUpdates[i].NewParamType,
                (a, b) =>
            {
                a.UpdateData.ParamUpdates[i].NewParamType = b;
                return(a);
            });
            var updateParamValueLens = map.Lens(
                uvm => uvm.UpdateData.ParamUpdates[i].UpdateParamValue,
                (a, b) =>
            {
                a.UpdateData.ParamUpdates[i].UpdateParamValue = b;
                return(a);
            });
            var newParamValueLens = map.Lens(
                uvm => uvm.UpdateData.ParamUpdates[i].NewParamValue,
                (a, b) =>
            {
                a.UpdateData.ParamUpdates[i].NewParamValue = b;
                return(a);
            });

            return(div(
                       div(ElementCreators.CheckableTextInput("Type", updateParamTypeLens, newParamTypeLens,
                                                              juvm.MetaData.JobArgs[i].Type)),
                       //TODO: Make this a TextArea for larger Parameters
                       div(ElementCreators.CheckableTextInput("Value", updateParamValueLens, newParamValueLens,
                                                              juvm.MetaData.JobArgs[i].Value))
                       ));
        }
Ejemplo n.º 2
0
        public static IControlBody Main()
        {
            //var myList = Var.Create<IEnumerable<string>>(Remoting.GetQueueNameList());
            var criteria     = Var.Create(new JobSearchCriteria());
            var useQueueLens = criteria.Lens(q => q.UseQueue, (a, b) =>
            {
                a.UseQueue = b;
                return(a);
            });
            var statusLens = criteria.Lens(q => q.Status, (a, b) =>
            {
                a.Status = b;
                return(a);
            });
            var useStatus = criteria.Lens(q => q.UseStatus, (a, b) =>
            {
                a.UseStatus = b;
                return(a);
            });
            var methodLens = criteria.Lens(q => q.MethodName, (a, b) =>
            {
                a.MethodName = b;
                return(a);
            });
            var useMethod = criteria.Lens(q => q.UseMethod, (a, b) =>
            {
                a.UseMethod = b;
                return(a);
            });
            var statusOptions = Var.Create <IEnumerable <string> >(new[]
            {
                null, "Processed", "New", "Failed",
                "Retry", "InProgress", "Inserting"
            });
            var dummyQueueCriteriaFiller = Var.Create("");
            var criteriaFiller           = Submitter.CreateOption(dummyQueueCriteriaFiller.View);
            var updateSet     = new ListModel <string, JobUpdateViewModel>(q => q.JobGuid.ToString());
            var queueNames    = Var.Create <IEnumerable <string> >(new string[] { null });
            var queueNameView = criteriaFiller.View.MapAsync(async input =>
            {
                queueNames.Value = await Remoting.GetQueueNameList();
                return(queueNames.Value);
            });

            criteriaFiller.Trigger();

            var methodCriteria = Var.Create <IEnumerable <string> >(new string[] { null });
            var submit         = Submitter.CreateOption(criteria.View);
            var result         = updateSet.Doc(juvm =>
            {
                var map            = updateSet.Lens(juvm.JobGuid.ToString());
                var myUpdateItem   = Var.Create(div());
                var jobParamUpdate = juvm.UpdateData.ParamUpdates.Select((updateDateParamUpdate, i) =>
                {
                    return(CreateParamterUpdateElement(map, i, juvm));
                }).ToArray();
                var newMethodName = map.Lens(uvm => uvm.UpdateData.NewMethodName, (a, b) =>
                {
                    a.UpdateData.NewMethodName = b;
                    return(a);
                });
                var updateMethodName = map.Lens(uvm => uvm.UpdateData.UpdateMethodName, (a, b) =>
                {
                    a.UpdateData.UpdateMethodName = b;
                    return(a);
                });
                var updateStatus = map.Lens(uvm => uvm.UpdateData.UpdateStatus, (a, b) =>
                {
                    a.UpdateData.UpdateStatus = b;
                    return(a);
                });
                var newStatus = map.Lens(uvm => uvm.UpdateData.NewStatus, (a, b) =>
                {
                    a.UpdateData.NewStatus = b;
                    return(a);
                });
                var updateQueue = map.Lens(uvm => uvm.UpdateData.UpdateQueueName, (a, b) =>
                {
                    a.UpdateData.UpdateQueueName = b;
                    return(a);
                });
                var newQueue = map.Lens(uvm => uvm.UpdateData.NewQueueName, (a, b) =>
                {
                    a.UpdateData.NewQueueName = b;
                    return(a);
                });
                var updateMaxRetryCount = map.Lens(uvm => uvm.UpdateData.UpdateRetryCount, (a, b) =>
                {
                    a.UpdateData.UpdateRetryCount = b;
                    return(a);
                });
                var newMaxRetryCount = map.Lens(uvm => uvm.UpdateData.NewMaxRetryCount, (a, b) =>
                {
                    a.UpdateData.NewMaxRetryCount = b;
                    return(a);
                });
                var blurFilter    = Var.Create("");
                var disableUpdate = Var.Create(false);
                var disabledVar   = Var.Create("Disabled");
                var disabledColor = Var.Create("");
                return(div(style("display", "grid"), style("grid-template-columns", "50% 50%"), style("filter", blurFilter.View), style("background", disabledColor.View),
                           div(
                               new Jobitem.JobItem().MethodName(juvm.MetaData.MethodName).QueueName(juvm.MetaData.Queue)
                               .Status(juvm.MetaData.Status)
                               .JobGuid(juvm.MetaData.JobId.ToString()).Doc()
                               ),
                           div(
                               div(
                                   div(ElementCreators.CheckableTextInput("Status", updateStatus, newStatus,
                                                                          juvm.MetaData.Status)),
                                   div(ElementCreators.CheckableTextInput("MethodName", updateMethodName, newMethodName,
                                                                          juvm.MetaData.MethodName)),
                                   div(ElementCreators.CheckableTextInput("QueueName", updateQueue, newQueue,
                                                                          juvm.MetaData.Queue)),
                                   div(ElementCreators.CheckableNumberInput("MaxRetryCount", updateMaxRetryCount,
                                                                            newMaxRetryCount,
                                                                            juvm.MetaData.RetryParameters.MaxRetries))
                                   )
                               ),
                           //TODO: This looks bad with lots of Parameters.
                           div(div(juvm.MetaData.JobArgs.Select((r, i) =>
                                                                div(new Jobparameter.JobParameter().Type(r.Type).Name(r.Name).Value(r.Value)
                                                                    .Ordinal(i.ToString()).Doc())).ToArray())),
                           div(style("margin-left", "5%"), div(jobParamUpdate)),
                           button("Update", async() =>
                {
                    if (juvm == null)
                    {
                        myUpdateItem.Value = div("");
                    }

                    var success = await PerformJobUpdate(juvm);
                    if (success)
                    {
                        myUpdateItem.Value = div("Updated");
                        blurFilter.Value = "blur(1px)";
                        disabledColor.Value = "lightgrey";
                        disableUpdate.Value = true;
                    }
                    else
                    {
                        myUpdateItem.Value = div("Failed update");
                    }
                }, attr.disabled(disabledVar.View, disableUpdate.View)),
                           div(myUpdateItem)
                           ));
            });
            var results = submit.View.MapAsync(async input =>
            {
                return(await CreateSearchResults(input, methodCriteria, updateSet, result));
            });

            var queueNameLens = criteria.Lens(q => q.QueueName, (a, b) =>
            {
                a.QueueName = b;
                return(a);
            });
            var useCreatedLens = criteria.Lens(q => q.useCreatedDate, (a, b) =>
            {
                a.useCreatedDate = b;
                return(a);
            });
            var createdBeforeDateLens = criteria.Lens(q => q.createdBefore, (a, b) =>
            {
                a.createdBefore = b;
                return(a);
            });
            var createdAfterDateLens = criteria.Lens(q => q.createdAfter, (a, b) =>
            {
                a.createdBefore = b;
                return(a);
            });
            var createdBeforeTimeLens = criteria.Lens(q => q.createdBeforeTime, (a, b) =>
            {
                a.createdBeforeTime = b;
                return(a);
            });
            var createdAfterTimeLens = criteria.Lens(q => q.createdAfterTime, (a, b) =>
            {
                a.createdAfterTime = b;
                return(a);
            });
            var useAttemptedDTLens = criteria.Lens(q => q.useLastAttemptDate, (a, b) =>
            {
                a.useLastAttemptDate = b;
                return(a);
            });
            var lastExecutedBeforeTimeLens = criteria.Lens(q => q.attemptedBeforeTime, (a, b) =>
            {
                a.attemptedBeforeTime = b;
                return(a);
            });
            var lastExecutedBeforeDateLens = criteria.Lens(q => q.attemptedBeforeDate, (a, b) =>
            {
                a.attemptedBeforeDate = b;
                return(a);
            });
            var lastExecutedAfterTimeLens = criteria.Lens(q => q.attemptedAfterTime, (a, b) =>
            {
                a.attemptedAfterTime = b;
                return(a);
            });
            var lastExecutedAfterDateLens = criteria.Lens(q => q.attemptedAfterDate, (a, b) =>
            {
                a.attemptedAfterDate = b;
                return(a);
            });
            var content = div(div(style("width", "100%"),
                                  div(ElementCreators.OptionSearch("Queue Name", queueNameLens, queueNameView, useQueueLens, (r, e) => submit.Trigger()),
                                      ElementCreators.TextSearch("Method Name", methodLens, useMethod),
                                      ElementCreators.OptionSearch("Status", statusLens, statusOptions.View, useStatus,
                                                                   (a, b) => submit.Trigger()),
                                      ElementCreators.OptionSearch("Method", methodLens, methodCriteria.View, useMethod,
                                                                   (a, b) => submit.Trigger()),
                                      ElementCreators.DateTimeRangeSearch("Created", useCreatedLens, createdBeforeDateLens,
                                                                          createdBeforeTimeLens, createdAfterDateLens, createdAfterTimeLens),
                                      ElementCreators.DateTimeRangeSearch("Attempt", useAttemptedDTLens, lastExecutedBeforeDateLens,
                                                                          lastExecutedBeforeTimeLens, lastExecutedAfterDateLens, lastExecutedAfterTimeLens),
                                      div(button("Search", submit.Trigger)))),
                              div(br()),
                              div(style("overflow-y", "scroll"), results)
                              );

            return(content);
        }