private void ShowClassScores(ClassRoom classRoom)
 {
     ClassScores   = classRoom.Scores.OrderBy(x => x.Grade).ToList();
     SelectedClass = classRoom;
     this.StateHasChanged();
     Js.InvokeVoidAsync("ScrollToScores");
 }
        protected async Task DistrictsProvidersToExcel()
        {
            var kerszolg   = $"{DistrictName} szolgáltatói szerződései {Period} időszakban";
            var excelBytes = DistrictService.DistrictsProvidersToExcel(kerszolg, DistrictSummaryByProviderVMs);
            await Js.InvokeVoidAsync("saveAsFile", $"Szolgáltatók {DateTime.Now:yyyyMMdd_HHmmss}.xlsx", Convert.ToBase64String(excelBytes));

            await InvokeAsync(StateHasChanged);
        }
 /// <summary>
 /// If the window is resized, calculate the new coordinates of the PortalItem
 /// </summary>
 private async void OnWindowResize(object sender, BrowserWindowSize e)
 {
     if (!IsVisible)
     {
         return;
     }
     var item = Portal.GetItem(_id).Clone();
     await Js.InvokeVoidAsync("mudHandlePortal", item.JavaScriptModel, _portalRef);
 }
        protected async Task DownloadSchedule()
        {
            var scheduleName = SchedulesState.Schedules.FirstOrDefault(s => s.Id == Id)?.Name;

            ActivatePdfStyle = true;

            await Task.Run(async() => await Js.InvokeVoidAsync("generatePdf", scheduleName !))
            .ContinueWith(a => ActivatePdfStyle = false);
        }
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender)
     {
         DotNetInstance = DotNetObjectReference.Create(this);
         await Js.InvokeVoidAsync($"{ns}.addMediaQueryList", DotNetInstance);
     }
     await base.OnAfterRenderAsync(firstRender);
 }
 public void Dispose()
 {
     if (DotNetInstance != null)
     {
         Js.InvokeVoidAsync($"{ns}.removeMediaQueryList", DotNetInstance);
         DotNetInstance.Dispose();
         DotNetInstance = null;
     }
 }
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     SetSuppressInput();
     if (firstRender && ParentSelect.EnableSearch)
     {
         DomEventService.AddEventListener("window", "beforeunload", Reloading, false);
         await Js.InvokeVoidAsync(JSInteropConstants.AddPreventCursorMoveOnArrowUp, ParentSelect._inputRef);
     }
     await base.OnAfterRenderAsync(firstRender);
 }
Exemple #8
0
        protected override Task OnInitializedAsync()
        {
            if (Program.LogEnabled)
            {
                Console.WriteLine("Main component opened");
            }

            Js.InvokeVoidAsync("initializeClient", Program.GetClientToken(), DotNetObjectReference.Create(this));
            return(base.OnInitializedAsync());
        }
Exemple #9
0
 protected async Task Busy(bool state, string element = "body")
 {
     try
     {
         await Js.InvokeVoidAsync("Busy", state, element);
     }
     catch (Exception ex)
     {
     }
 }
Exemple #10
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            SetSuppressInput();
            if (firstRender && ParentSelect.EnableSearch)
            {
                DomEventService.AddEventListener("window", "beforeunload", Reloading, false);
                await Js.InvokeVoidAsync(JSInteropConstants.AddPreventKeys, ParentSelect._inputRef, new[] { "ArrowUp", "ArrowDown" });

                await Js.InvokeVoidAsync(JSInteropConstants.AddPreventEnterOnOverlayVisible, ParentSelect._inputRef, ParentSelect.DropDownRef);
            }
            await base.OnAfterRenderAsync(firstRender);
        }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                WindowResizeListener.OnResized += OnWindowResize;
            }

            var item = Portal.GetItem(_id).Clone();

            item.IsVisible = IsVisible;
            Portal.Update(item);
            await Js.InvokeVoidAsync("mudHandlePortal", item.JavaScriptModel, _portalRef);
        }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await Js.InvokeVoidAsync("loadScript", "https://www.google.com/recaptcha/api.js");

            await Js.InvokeVoidAsync("loadScript", "_content/GoogleCaptchaComponent/Scripts/JsOfReCAPTCHA.js");

            if (firstRender)
            {
                await Js.InvokeVoidAsync("render_recaptcha", DotNetObjectReference.Create(this), "recaptcha_container", CaptchaConfiguration.Value.SiteKey);
            }

            await base.OnAfterRenderAsync(firstRender);
        }
Exemple #13
0
        /// <summary>
        /// Method is called via EventCallBack if the keyboard key is no longer pressed inside the Input element.
        /// </summary>
        /// <param name="e">Contains the key (combination) which was pressed inside the Input element</param>
        protected async Task OnKeyDown(KeyboardEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            var key = e.Key.ToUpperInvariant();

            if (key == "ENTER" || key == "TAB" || key == "ESCAPE")
            {
                _duringManualInput = false;
                if (string.IsNullOrWhiteSpace(_inputStart.Value))
                {
                    ClearValue();
                }
                else
                {
                    await TryApplyInputValue();
                }

                if (key == "ESCAPE" && _dropDown.IsOverlayShow())
                {
                    Close();
                    await Js.FocusAsync(_inputStart.Ref);

                    return;
                }
                if (key == "ENTER")
                {
                    //needed only in wasm, details: https://github.com/dotnet/aspnetcore/issues/30070
                    await Task.Yield();

                    await Js.InvokeVoidAsync(JSInteropConstants.InvokeTabKey);
                }
                Close();
                AutoFocus = false;
                return;
            }

            if (key == "ARROWDOWN" && !_dropDown.IsOverlayShow())
            {
                await _dropDown.Show();

                return;
            }
            if (key == "ARROWUP" && _dropDown.IsOverlayShow())
            {
                Close();
                return;
            }
        }
Exemple #14
0
        protected override void OnInitialized()
        {
            InstantMessager.MessageReceived += (sender, args) =>
            {
                if (args.ChatId == ChatId)
                {
                    _messages.Insert(0, args.Message);
                    if (args.Message.Author == Username)
                    {
                        _messageSent = true;
                    }
                    StateHasChanged();
                }
            };

            InstantMessager.MessageEdited += (sender, args) =>
            {
                if (args.ChatId == ChatId)
                {
                    var editedIdx = _messages.FindIndex(m => m.Id == args.Message.Id);

                    _messages.RemoveAt(editedIdx);
                    _messages.Insert(editedIdx, args.Message);

                    StateHasChanged();
                }
            };

            InstantMessager.MessageDeleted += (sender, args) =>
            {
                if (args.ChatId == ChatId)
                {
                    var messageIdx = _messages.FindIndex(m => m.Id == args.MessageId);

                    if (args.DeletedForAll || args.Author == (AuthProvider as AuthStateProvider).Username)
                    {
                        _messages.RemoveAt(messageIdx);
                    }

                    StateHasChanged();
                }
            };

            InstantMessager.MessageRead += (sender, args) =>
            {
                _messages.Find(m => m.Id == args.MessageId).IsRead = true;
            };

            Js.InvokeVoidAsync("InitChat", DotNetObjectReference.Create(this));
            //Js.InvokeVoidAsync("initScrollListening", DotNetObjectReference.Create(this), nameof(OnMessageInViewportAsync));
        }
        public void RemoveQuery(MediaQuery mediaQuery)
        {
            var cache = GetMediaQueryFromCache(byMedia: mediaQuery.Media);

            if (cache != null)
            {
                cache.MediaQueries.Remove(mediaQuery);
                if (cache.MediaQueries.Count() == 0)
                {
                    Js.InvokeVoidAsync($"{ns}.removeMediaQuery", DotNetInstance, mediaQuery.InternalMedia.Media);
                    mediaQueries.Remove(cache);
                }
            }
        }
Exemple #16
0
        async Task DeleteWorkout()
        {
            var response = await WorkoutService.DeleteWorkoutAsync(Workout);

            if (response.IsSuccessStatusCode)
            {
                await Js.InvokeVoidAsync("closeModal", "#deleteWorkoutModal");

                Nav.NavigateTo("/workouts");
            }
            else
            {
                Message = await response.Content.ReadAsStringAsync();
            }
        }
Exemple #17
0
        public void RemoveQuery(MediaQuery mediaQuery)
        {
            bool byMediaProperties(MediaQueryCache q) => q.Value.Media == mediaQuery.InternalMedia.Media;

            var cache = mediaQueries.Find(byMediaProperties);

            if (cache != null)
            {
                cache.MediaQueries.Remove(mediaQuery);
                if (cache.MediaQueries.Count() == 0)
                {
                    Js.InvokeVoidAsync($"{ns}.removeMediaQuery", DotNetInstance, mediaQuery.InternalMedia.Media);
                    mediaQueries.Remove(cache);
                }
            }
        }
        async Task AddWorkout()
        {
            var response = await WorkoutService.AddWorkoutAsync(NewWorkout);

            if (response.IsSuccessStatusCode)
            {
                WorkoutList = await WorkoutService.GetWorkoutsAsync();

                await Js.InvokeVoidAsync("closeModal", "#addWorkoutModal");

                NewWorkout = new WorkoutModel();
            }
            else
            {
                Message = await response.Content.ReadAsStringAsync();
            }
        }
Exemple #19
0
 protected override void OnValueChanged(bool changed)
 {
     if (changed && Rendered)
     {
         InvokeAsync(async() =>
         {
             try
             {
                 await Js.InvokeVoidAsync("matBlazor.matSlider.updateValue", Ref, Value);
             }
             catch (Exception e)
             {
                 Console.WriteLine(e.Message);
             }
         });
     }
 }
Exemple #20
0
        private async Task SetConfig(ConfigModel configModel)
        {
            if (editor is null)
            {
                return;
            }

            if (isDirty)
            {
                var result = await Js.InvokeAsync <bool>("confirm", "This config has not been saved yet. Are you sure you want to load another one?");

                if (!result)
                {
                    return;
                }
            }

            string?content = default;

            try
            {
                var sourceConfig = await configModel.Load();

                content = sourceConfig?.Content ?? string.Empty;
                var model = await editor.GetModel();

                await Js.InvokeVoidAsync("blazorMonaco.editor.setModelLanguage", editor.Id, model.Id, sourceConfig?.Language ?? string.Empty);
            }
            catch (Exception e)
            {
                Logger.LogError(e, $"Exception while loading content.");
            }

            content ??= string.Empty;
            await editor.SetValue(content);

            currentConfig = configModel;
            isDirty       = false;

            await editor.UpdateOptions(new()
            {
                ReadOnly = currentConfig.IsReadOnly,
            });
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!_isReloading)
            {
                _ = InvokeAsync(async() =>
                {
                    await Task.Delay(100);
                    await Js.InvokeVoidAsync(JSInteropConstants.RemovePreventCursorMoveOnArrowUp, ParentSelect._inputRef);
                });
            }
            DomEventService.RemoveEventListerner <JsonElement>("window", "beforeunload", Reloading);

            if (IsDisposed)
            {
                return;
            }

            IsDisposed = true;
        }
Exemple #22
0
        public void AddTodo()
        {
            if (!string.IsNullOrWhiteSpace(inpVal))
            {
                var itm = new Item
                {
                    Title = inpVal,
                    Desc  = desc,
                    Id    = Guid.NewGuid().ToString(),
                    Done  = false
                };

                Todos.Add(itm);
                UpdateLocalStorage();
                Js.InvokeVoidAsync("clearInput", inpRef, decRef);
            }
            else
            {
                Js.InvokeVoidAsync("alert", "Title and/or Description cannot be empty.");
            }
        }
Exemple #23
0
        protected override async Task OnInitializedAsync()
        {
            var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);

            var hasCode = QueryHelpers.ParseQuery(uri.Query).TryGetValue("code", out Microsoft.Extensions.Primitives.StringValues code);

            if (Type == "alipay")
            {
                hasCode = QueryHelpers.ParseQuery(uri.Query).TryGetValue("auth_code", out code);
            }
            var hasState = QueryHelpers.ParseQuery(uri.Query).TryGetValue("state", out Microsoft.Extensions.Primitives.StringValues state);

            if (hasCode && hasState)
            {
                var response = await GetResultAsync <BlogResponse <string> >($"api/oauth/{Type}/token?code={code}&state={state}");

                if (response.Success)
                {
                    var token = response.Result;
                    await Js.InvokeVoidAsync("localStorage.setItem", "token", token);

                    NavigationManager.NavigateTo("/", true);
                }
                else
                {
                    await Notification.Warning(new NotificationConfig
                    {
                        Message     = response.Message,
                        Description = "Sorry, this account is not authorized, please contact administrator"
                    });

                    NavigationManager.NavigateTo("/login", true);
                }
            }
            else
            {
                var service = AuthenticationStateProvider as OAuthService;
                await service.GetOAuthUrl(Type);
            }
        }
        private async Task RemoveExercise()
        {
            try
            {
                var response = await WorkoutService.RemoveExerciseAsync(Workout.Id, Exercise);

                if (response.IsSuccessStatusCode)
                {
                    await ExerciseRemoved.InvokeAsync(true);

                    await Js.InvokeVoidAsync("closeModal", "#deleteExerciseModal");
                }
                else
                {
                    Message = await response.Content.ReadAsStringAsync();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #25
0
 private async Task CopyTextToClipboard(string Text)
 {
     await Js.InvokeVoidAsync("clipboardCopy.copyText", Text);
 }
Exemple #26
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender).ConfigureAwait(false);

            await Js.InvokeVoidAsync("SetEditor");
        }
Exemple #27
0
 protected void Close()
 {
     Js.InvokeVoidAsync("close");
 }
Exemple #28
0
 protected void SendData(string action, Dictionary <string, object> data, bool enableCallback = false)
 {
     Js.InvokeVoidAsync("sendData", action, data, enableCallback);
 }
Exemple #29
0
        /// <summary>
        /// Method is called via EventCallBack if the keyboard key is no longer pressed inside the Input element.
        /// </summary>
        /// <param name="e">Contains the key (combination) which was pressed inside the Input element</param>
        /// <param name="index">Refers to picker index - 0 for starting date, 1 for ending date</param>
        protected async Task OnKeyDown(KeyboardEventArgs e, int index)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            var key = e.Key.ToUpperInvariant();

            if (key == "ENTER" || key == "TAB" || key == "ESCAPE")
            {
                if (_duringManualInput)
                {
                    //A scenario when there are a lot of controls;
                    //It may happen that incorrect values were entered into one of the input
                    //followed by ENTER key. This event may be fired before input manages
                    //to get the value. Here we ensure that input will get that value.
                    await Task.Delay(5);

                    _duringManualInput = false;
                }
                var input = (index == 0 ? _inputStart : _inputEnd);
                if (string.IsNullOrWhiteSpace(input.Value))
                {
                    ClearValue(index, false);
                }
                else if (!await TryApplyInputValue(index, input.Value))
                {
                    return;
                }

                if (key == "ESCAPE" && _dropDown.IsOverlayShow())
                {
                    Close();
                    await Js.FocusAsync(input.Ref);

                    return;
                }

                if (index == 1)
                {
                    if (key != "TAB")
                    {
                        //needed only in wasm, details: https://github.com/dotnet/aspnetcore/issues/30070
                        await Task.Yield();

                        await Js.InvokeVoidAsync(JSInteropConstants.InvokeTabKey);

                        Close();
                    }
                    else if (!e.ShiftKey)
                    {
                        Close();
                        AutoFocus = false;
                    }
                }
                if (index == 0)
                {
                    if (key == "TAB" && e.ShiftKey)
                    {
                        Close();
                        AutoFocus = false;
                    }
                    else if (key != "TAB")
                    {
                        await Blur(0);
                        await Focus(1);
                    }
                }
                return;
            }
            if (key == "ARROWDOWN" && !_dropDown.IsOverlayShow())
            {
                await _dropDown.Show();

                return;
            }
            if (key == "ARROWUP" && _dropDown.IsOverlayShow())
            {
                Close();
                await Task.Yield();

                AutoFocus = true;
                return;
            }
        }
        /// <summary>
        /// Method is called via EventCallBack if the keyboard key is no longer pressed inside the Input element.
        /// </summary>
        /// <param name="e">Contains the key (combination) which was pressed inside the Input element</param>
        /// <param name="index">Refers to picker index - 0 for starting date, 1 for ending date</param>
        protected async Task OnKeyDown(KeyboardEventArgs e, int index)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            var key = e.Key.ToUpperInvariant();

            if (key == "ENTER" || key == "TAB")
            {
                _duringManualInput = false;
                var input = (index == 0 ? _inputStart : _inputEnd);
                if (string.IsNullOrWhiteSpace(input.Value))
                {
                    ClearValue(index, false);
                    await Focus(index);

                    return;
                }
                else if (!await TryApplyInputValue(index, input.Value))
                {
                    return;
                }

                if (index == 1)
                {
                    if (key != "TAB")
                    {
                        //needed only in wasm, details: https://github.com/dotnet/aspnetcore/issues/30070
                        await Task.Yield();

                        await Js.InvokeVoidAsync(JSInteropConstants.InvokeTabKey);

                        Close();
                    }
                    else if (!e.ShiftKey)
                    {
                        Close();
                    }
                }
                if (index == 0)
                {
                    if (key == "TAB" && e.ShiftKey)
                    {
                        Close();
                        AutoFocus = false;
                    }
                    else if (key != "TAB")
                    {
                        await Blur(0);
                        await Focus(1);
                    }
                }
                return;
            }
            if (key == "ARROWDOWN" && !_dropDown.IsOverlayShow())
            {
                await _dropDown.Show();

                return;
            }
            if (key == "ARROWUP" && _dropDown.IsOverlayShow())
            {
                Close();
                await Task.Yield();

                AutoFocus = true;
                return;
            }
        }