Exemple #1
0
        public async Task CloseLoginModal(bool collapse)
        {
            IsBusy = false;
            await JsRuntime.InvokeAsync <object>("HideModal", "resetModal", collapse);

            //await JsRuntime.InvokeAsync<object>("ShowModal", "loginModal");
        }
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         await JsRuntime.InvokeAsync <string>("MdbThemeInitialization");
     }
 }
Exemple #3
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         await JsRuntime.InvokeAsync <string>("material_blazor.menu.init", ElementReference, ObjectReference);
     }
 }
Exemple #4
0
        protected async Task OnClickHandler(MouseEventArgs ev)
        {
            MudMenu.CloseMenu();

            if (Link != null)
            {
                if (string.IsNullOrWhiteSpace(Target))
                {
                    UriHelper.NavigateTo(Link, ForceLoad);
                }
                else
                {
                    await JsRuntime.InvokeAsync <object>("open", Link, Target);
                }
            }
            else
            {
                await OnClick.InvokeAsync(ev);

                if (Command?.CanExecute(CommandParameter) ?? false)
                {
                    Command.Execute(CommandParameter);
                }
            }
        }
        public async void GoToLogin()
        {
            //LoginModel.UserName = "******";
            await CloseRegisterModal(false);

            await JsRuntime.InvokeAsync <object>("ShowModal", "loginModal");
        }
 protected override async Task OnAfterRenderAsync()
 {
     if (Type == RazorInputType.Price)
     {
         await JsRuntime.InvokeAsync <object>("ApplyMask");
     }
 }
 protected async override Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         await JsRuntime.InvokeAsync <object>("initializeCarousel");
     }
 }
        /// <summary>
        /// Shows the dialog on the next render after a show action. Also on the next render after the dialog is initiated each
        /// embedded Material.Blazor component is initiated here.
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (AfterRenderShowAction)
            {
                try
                {
                    AfterRenderShowAction = false;
                    Tcs.SetResult(await JsRuntime.InvokeAsync <string>("material_blazor.dialog.show", DialogElem, ObjectReference, EscapeKeyAction, ScrimClickAction));
                    IsOpen = false;
                    StateHasChanged();
                }
                catch
                {
                    Tcs?.SetCanceled();
                }
            }
            else if (AfterDialogInitialization)
            {
                AfterDialogInitialization = false;

                foreach (var child in LayoutChildren)
                {
                    child.RequestInstantiation();
                }

                LayoutChildren.Clear();

                hasInstantiated = true;

                StateHasChanged();
            }
        }
Exemple #9
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            _jsTask = new Lazy <Task <IJSObjectReference> >(() => JsRuntime.InvokeAsync <IJSObjectReference>(
                                                                "import", "./index.js").AsTask());
        }
Exemple #10
0
        protected override async Task OnInitializedAsync()
        {
            StatusEnum = PatientsAllOperationStatusEnum.Pending;

            try
            {
                var response = await HttpClient.GetAsync("http://localhost:8080/api/patient");

                if ((int)response.StatusCode == 200)
                {
                    var stringContent = await response.Content.ReadAsStringAsync();

                    var content = JsonConvert.DeserializeObject <IEnumerable <PatientInputModel> >(stringContent);

                    PatientList = content;

                    await JsRuntime.InvokeAsync <object>("InitDataTable", "patients-table");
                }

                else
                {
                    PatientList = new List <PatientInputModel>();
                    await JsRuntime.InvokeAsync <object>("InitDataTable", "patients-table");
                }

                StatusEnum = PatientsAllOperationStatusEnum.Success;
                StateHasChanged();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                StatusEnum = PatientsAllOperationStatusEnum.Error;
                StateHasChanged();
            }
        }
        protected override async Task OnInitializedAsync()
        {
            NoteModel       = null;
            OperationStatus = APIOperationStatus.Initial;
            StateHasChanged();

            try
            {
                var response = await HttpClient.GetAsync($"http://localhost:8082/api/history/note/{NoteId}");

                if ((int)response.StatusCode == 200)
                {
                    var stringContent = await response.Content.ReadAsStringAsync();

                    var content = JsonConvert.DeserializeObject <NoteInputModel>(stringContent);

                    NoteModel = content;

                    await JsRuntime.InvokeAsync <object>("InitDataTable", "auditlog-table");
                }

                OperationStatus = APIOperationStatus.GET_Success;
                StateHasChanged();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                OperationStatus = APIOperationStatus.GET_Error;
                StateHasChanged();
            }
        }
 public Task clearListeners(string eventName)
 {
     return(JsRuntime.InvokeAsync <bool>(
                "googleMapEventJsFunctions.clearListeners",
                DivId,
                eventName));
 }
        public void LoadSample()
        {
            if (!initilized)
            {
                initilized = true;
                this.StateHasChanged();

                for (int i = 0; i < ComponentsTypes.Count; i++)
                {
                    ComponentsTypes[i]?.InitComponent();
                }
                isLoading = false;
                this.StateHasChanged();
                Task.Run(async() =>
                {
                    editor = await JsRuntime.InvokeAsync <IJSObjectReference>("window.demo.editorInit", codeArea, SampleCodeLanguage);

                    foreach (ISampleComponentEvents item in this.ComponentsTypes.OfType <ISampleComponentEvents>())
                    {
                        foreach (var ev in item.Events)
                        {
                            ev.jSRuntime = JsRuntime;
                            ev.OnOccured = () => this.StateHasChanged();
                        }
                    }
                });
            }
        }
Exemple #14
0
 public BaseReactSharpBlazor()
 {
     runtime = new ReactRuntime()
     {
         Step = () =>
         {
             InvokeAsync(async() =>
             {
                 try
                 {
                     //var dom = new ReactRendererDOMJson();
                     var renderer = new ReactRenderer(runtime);
                     runtime.Root = renderer.Render(Element, runtime.Root, dom);
                     await JsRuntime.InvokeAsync <object>("reactSharp.renderJsonString", Ref,
                                                          dom.StringWriter.ToString());
                 }
                 catch (Exception e)
                 {
                     Console.WriteLine(e);
                     throw;
                 }
             });
         }
     };
 }
        ///<inheritdoc/>
        protected async override Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                JQueryElementRef = await JsRuntime.InvokeAsync <IJSObjectReference>("$", RootElement);

                //if (EnterTransition.HasValue )//to do add paramter
                //{
                //    ViewportVisibility.Apply();
                //    OnTopVisibilityUpdatedEvent += async d =>
                //    {
                //        Console.WriteLine("Should Play Animation");
                //        if (!isEnterAnimationPlayed)
                //        {
                //            await Animator.AnimatedShow(EnterTransition.Value, EnterTransitionDuration);
                //            isEnterAnimationPlayed = true;
                //        }
                //    };
                //}
                //else
                if (EnterTransition.HasValue)
                {
                    if (!isEnterAnimationPlayed)
                    {
                        await Animator.AnimatedShow(EnterTransition.Value, EnterTransitionDuration);

                        isEnterAnimationPlayed = true;
                    }
                }
            }
        }
        protected virtual async Task InitializeJsInterop()
        {
            var myRef = DotNetObjectReference.Create(this);
            await JsRuntime.InvokeAsync <object>("blazorAdaptiveCards.setCardComponent", myRef, Id);

            JsInitialized = true;
        }
Exemple #17
0
        //Note: whenever running a javascript method, it needs to be async. Not sure if it needs to return a Task<object>, but this is the only way I can get it to work right now.
        private async Task <object> CloseModal()
        {
            //this is apparently all that's required to populate a separate set of fields on the page when this method is invoked. The RetrievedAddress object still has its values
            AddressForDisplay = RetrievedAddress;

            return(await JsRuntime.InvokeAsync <object>("BingMap.HideModal"));
        }
Exemple #18
0
        private async Task OnTimerTick()
        {
            Debug.WriteLine($"Timer tick: {_inputValueTmp}");
            _timer.Stop();

            _searchString = _inputValueTmp;

            if (!_isOpen)
            {
                _inputElementInfo = await JsRuntime.InvokeAsync <HtmlElementInfo>("getElementInfo", _inputElementReference);

                _isOpen = true;
            }


            if (SourceFiltered.Count == 0)
            {
                if (AllowAdd)
                {
                    _isAddOpen = true;
                    _isOpen    = false;
                }
                else
                {
                    _isAddOpen = false;
                }
            }
            else
            {
                _isAddOpen = false;
            }

            await InvokeAsync(() => { this.StateHasChanged(); });
        }
Exemple #19
0
 private async void StopTimer()
 {
     Timer.Stop();
     Timer.Dispose();
     TimerVerb = "Start";
     Time      = 60;
     await JsRuntime.InvokeAsync <object>("soundAlert");
 }
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         JsHelper = new VirtualScrollJsHelper(this);
         await JsRuntime.InvokeAsync <ScrollView>("blazorVirtualScrolling.init", "vscroll", DotNetObjectReference.Create(JsHelper));
     }
 }
Exemple #21
0
        private async Task OnOpenClick(MouseEventArgs args)
        {
            _inputElementInfo = await JsRuntime.InvokeAsync <HtmlElementInfo>("getElementInfo", _inputElementReference);

            _searchString = "";
            _isOpen       = !_isOpen;
            _isAddOpen    = false;
        }
        public async Task <BlazorQueryDOM> FadeOut(Action <string> completed)
        {
            var actionWrapper         = new ActionWrapper <string>(completed);
            var dotNetObjectReference = DotNetObjectReference.Create(actionWrapper);
            await JsRuntime.InvokeAsync <Task>(BlazorQueryList.FadeOut, CurrentSelector, dotNetObjectReference);

            return(this);
        }
 protected override async Task OnAfterRenderAsync()
 {
     if (JsRuntime == null)
     {
         return;
     }
     await JsRuntime.InvokeAsync <bool>("setInputToChange");
 }
        protected override void OnAfterRender(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender)
            {
                JsRuntime.InvokeAsync <object>("initRenderJS", DotNetObjectReference.Create(this));
            }
        }
        private async Task InvokeReturn()
        {
            var parameter = RandomGenerator.NextInt(50);

            Console.WriteLine($"{nameof(JsInteropPlayground)}.{nameof(InvokeReturn)}: parameter = {parameter}");
            var result = await JsRuntime.InvokeAsync <int>("jsInterop.returnDoubled", parameter);

            Console.WriteLine($"{nameof(JsInteropPlayground)}.{nameof(InvokeReturn)}: result = {result}");
        }
Exemple #26
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (!firstRender)
     {
         return;
     }
     _module = await JsRuntime.InvokeAsync <IJSObjectReference>(
         "import", "./js/login.js");
 }
Exemple #27
0
        public async Task CheckVisibleArea(IJSRuntime jsRuntime = null)
        {
            JsRuntime = jsRuntime ?? JsRuntime;
            var visibleArea = await JsRuntime.InvokeAsync <long[]>("GetSize");

            this.VisibleAreaX = visibleArea[0];
            this.VisibleAreaY = visibleArea[1];
            await JsRuntime.InvokeAsync <object>("AreaResized", CreateDotNetObjectRef(this));
        }
        /// <summary>
        /// Gets the current authenticated used using JavaScript interop.
        /// </summary>
        /// <returns>A <see cref="Task{ClaimsPrincipal}"/>that will return the current authenticated user when completes.</returns>
        protected internal virtual async ValueTask <ClaimsPrincipal> GetAuthenticatedUser()
        {
            await EnsureAuthService();

            var account = await JsRuntime.InvokeAsync <TAccount>("AuthenticationService.getUser");

            var user = await AccountClaimsPrincipalFactory.CreateUserAsync(account, Options.UserOptions);

            return(user);
        }
Exemple #29
0
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         moduleTask = new(() => JsRuntime.InvokeAsync <IJSObjectReference>("import", JsModulePath)
                          .AsTask());
         var module = await moduleTask.Value;
         await module.InvokeVoidAsync("initialize", VideoElement, DotNetObjectReference.Create(this));
     }
 }
        protected async Task DeleteFeed()
        {
            if (await JsRuntime.InvokeAsync <bool>("confirm", $"{Feed.Name} will be removed."))
            {
                await Service.DeleteFeed(Collection, Feed)
                .ConfigureAwait(false);

                UriHelper.NavigateTo($"feedcollections/{Collection.Id}/00000000-0000-0000-0000-000000000000");
            }
        }