Ejemplo n.º 1
0
        private async Task SaveAsync()
        {
            this.Loading = true;

            try
            {
                this.UpdateActiveCodeFileContentAction?.Invoke();

                var snippetId = await this.SnippetsService.SaveSnippetAsync(this.CodeFiles);

                var urlBuilder = new UriBuilder(this.NavigationManager.BaseUri)
                {
                    Path = $"snippet/{snippetId}"
                };
                var url = urlBuilder.Uri.ToString();
                this.SnippetLink = url;

                this.JsRuntime.InvokeVoid("App.changeDisplayUrl", url);
            }
            catch (InvalidOperationException ex)
            {
                Snackbar.Add(ex.Message, Severity.Error);
            }
            catch (Exception)
            {
                Snackbar.Add("Error while saving snippet. Please try again later.", Severity.Error);
            }
            finally
            {
                this.Loading = false;
            }
        }
        private async Task Add()
        {
            if (_nodeName == null)
            {
                return;
            }

            var dashboards = await HttpClient.GetFromJsonAsync <List <DashboardConfig> >("api/dashboards/configuration");

            var dashboardToModify = dashboards?.FirstOrDefault(d => d.DashboardId == DashboardId);

            if (dashboardToModify != null)
            {
                dashboardToModify.Nodes.Add(new NodeConfig()
                {
                    NodeName = _nodeName
                });
                await HttpClient.PutAsJsonAsync("api/dashboards/configuration", dashboards);

                Snackbar.Add($"\"{_nodeName}\" added to \"{dashboardToModify.DashboardName}\"", Severity.Success);
                MudDialog.Close(DialogResult.Ok(true));
            }
            else
            {
                Snackbar.Add($"Can't find dashboard \"{DashboardId}\"", Severity.Error);
                MudDialog.Close(DialogResult.Ok(false));
            }
        }
Ejemplo n.º 3
0
        private async Task CreateTabAsync()
        {
            if (string.IsNullOrWhiteSpace(this.newTab))
            {
                this.TerminateTabCreating();
                return;
            }

            var normalizedTab = CodeFilesHelper.NormalizeCodeFilePath(this.newTab, out var error);

            if (!string.IsNullOrWhiteSpace(error) || this.Tabs.Contains(normalizedTab))
            {
                if (this.previousInvalidTab != this.newTab)
                {
                    Snackbar.Add("File already exists.", Severity.Warning);
                    this.previousInvalidTab = this.newTab;
                }

                await this.newTabInput.FocusAsync();

                return;
            }

            this.previousInvalidTab = null;

            this.Tabs.Add(normalizedTab);

            this.TerminateTabCreating();
            var newTabIndex = this.Tabs.Count - 1;

            await this.OnTabCreate.InvokeAsync(normalizedTab);

            await this.ActivateTabAsync(newTabIndex);
        }
Ejemplo n.º 4
0
        protected async Task DischargePatient(HospitalBed bed)
        {
            var parameters = new DialogParameters();
            var patient    = bed.Patient;

            parameters.Add("patient", patient);
            parameters.Add("units", State.Value.AvailableUnits);
            parameters.Add("preSelectedBed", bed);

            var dialog = Dialog.Show <PainelDialogs.DischargePatient>($"Discharge Patient: {patient.Name}", parameters, new DialogOptions()
            {
                MaxWidth = MaxWidth.Medium, FullWidth = true
            });
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var data = ((Guid PatientId, int CareUnitId, int HospitalBedId))result.Data;

                var ok = await PatientService.DischargePatientFromBed(
                    patientId : data.PatientId,
                    hospitalBedId : data.HospitalBedId,
                    careUnitId : data.CareUnitId);

                if (!ok)
                {
                    Snackbar.Add($"Could not discharge {patient?.Name} on bed {bed?.HospitalBedId}", Severity.Error);
                }
            }
        }
Ejemplo n.º 5
0
        public async Task PutPatient(Patient patient, [AllowNull, MaybeNull] HospitalBed bed = null)
        {
            var parameters = new DialogParameters();

            parameters.Add("patient", patient);
            parameters.Add("units", State.Value.AvailableUnits);
            parameters.Add("preSelectedBed", bed);

            var dialog = Dialog.Show <PainelDialogs.PutPatientOnBed>("Put Patient", parameters, new DialogOptions()
            {
                MaxWidth = MaxWidth.Medium, FullWidth = true
            });
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var data = ((Guid PatientId, int CareUnitId, int HospitalBedId))result.Data;

                var ok = await PatientService.PutPatientOnBed(data.PatientId, data.HospitalBedId, data.CareUnitId);

                if (!ok)
                {
                    Snackbar.Add($"Could not put {patient?.Name} on bed {bed?.HospitalBedId}", Severity.Error);
                }
            }
        }
Ejemplo n.º 6
0
        public async Task SearchUser(string value)
        {
            if (value.IsNullOrEmptyExt())
            {
                return;
            }

            _cancelToken?.Cancel();
            _cancelToken = new CancellationTokenSource();

            ShowLoading();
            var user = await GraphClientService.GetUserByUpnEmail(value, _cancelToken.Token);

            HideLoading();
            if (user != null)
            {
                var members = Selectedmembers.ToHashSet();
                if (!members.Contains(value))
                {
                    members.Add(user.AvailableUn);
                    Selectedmembers = members;
                    Snackbar.Add($"Member {user.DisplayName} added");
                }
                else
                {
                    Snackbar.Add($"Member {user.DisplayName} already selected");
                }
                //todo update model.priv
            }
        }
Ejemplo n.º 7
0
        private void UpdateActiveCodeFileContent()
        {
            if (this.activeCodeFile == null)
            {
                Snackbar.Add("No active file to update.", Severity.Error);
                return;
            }

            this.activeCodeFile.Content = this.CodeEditorComponent.GetCode();
        }
Ejemplo n.º 8
0
    protected async Task AddItemsToCollection(
        List <int> movieIds,
        List <int> showIds,
        List <int> seasonIds,
        List <int> episodeIds,
        List <int> artistIds,
        List <int> musicVideoIds,
        List <int> otherVideoIds,
        List <int> songIds,
        string entityName = "selected items")
    {
        int count = movieIds.Count + showIds.Count + seasonIds.Count + episodeIds.Count + artistIds.Count +
                    musicVideoIds.Count + otherVideoIds.Count + songIds.Count;

        var parameters = new DialogParameters
        {
            { "EntityType", count.ToString() }, { "EntityName", entityName }
        };
        var options = new DialogOptions {
            CloseButton = true, MaxWidth = MaxWidth.ExtraSmall
        };

        IDialogReference dialog = Dialog.Show <AddToCollectionDialog>("Add To Collection", parameters, options);
        DialogResult     result = await dialog.Result;

        if (!result.Cancelled && result.Data is MediaCollectionViewModel collection)
        {
            var request = new AddItemsToCollection(
                collection.Id,
                movieIds,
                showIds,
                seasonIds,
                episodeIds,
                artistIds,
                musicVideoIds,
                otherVideoIds,
                songIds);

            Either <BaseError, Unit> addResult = await Mediator.Send(request, CancellationToken);

            addResult.Match(
                Left: error =>
            {
                Snackbar.Add($"Unexpected error adding items to collection: {error.Value}");
                Logger.LogError("Unexpected error adding items to collection: {Error}", error.Value);
            },
                Right: _ =>
            {
                Snackbar.Add(
                    $"Added {count} items to collection {collection.Name}",
                    Severity.Success);
                ClearSelection();
            });
        }
    }
Ejemplo n.º 9
0
        private async Task CompileAsync()
        {
            this.Loading    = true;
            this.LoaderText = "Processing";

            await Task.Delay(10); // Ensure rendering has time to be called

            CompileToAssemblyResult compilationResult = null;
            CodeFile mainComponent = null;
            string   originalMainComponentContent = null;

            try
            {
                this.UpdateActiveCodeFileContent();

                // Add the necessary main component code prefix and store the original content so we can revert right after compilation.
                if (this.CodeFiles.TryGetValue(CoreConstants.MainComponentFilePath, out mainComponent))
                {
                    originalMainComponentContent = mainComponent.Content;
                    mainComponent.Content        = MainComponentCodePrefix + originalMainComponentContent.Replace(MainComponentCodePrefix, "");
                }

                compilationResult = await this.CompilationService.CompileToAssemblyAsync(
                    this.CodeFiles.Values,
                    this.UpdateLoaderTextAsync);

                this.Diagnostics         = compilationResult.Diagnostics.OrderByDescending(x => x.Severity).ThenBy(x => x.Code).ToList();
                this.AreDiagnosticsShown = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Snackbar.Add("Error while compiling the code.", Severity.Error);
            }
            finally
            {
                if (mainComponent != null)
                {
                    mainComponent.Content = originalMainComponentContent;
                }

                this.Loading = false;
            }

            if (compilationResult?.AssemblyBytes?.Length > 0)
            {
                this.UnmarshalledJsRuntime.InvokeUnmarshalled <byte[], object>(
                    "App.Repl.updateUserAssemblyInCacheStorage",
                    compilationResult.AssemblyBytes);

                // TODO: Add error page in iframe
                this.JsRuntime.InvokeVoid("App.reloadIFrame", "user-page-window", MainUserPagePath);
            }
        }
Ejemplo n.º 10
0
        private async Task AddInstitution()
        {
            var dialog = Dialog.Show <InstitutionAddOrUpdateDialog>("Новое учебное заведение");
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var addedInstitution = await InstitutionService.AddInstitution(dialog.Result.Result.Data as Institution);

                institutions.Add(addedInstitution);
                Snackbar.Add("Добавлено новое учебное заведение!", Severity.Success);
            }
        }
Ejemplo n.º 11
0
        private async Task AddSpeaker()
        {
            var dialog = Dialog.Show <SpeakerAddOrUpdateDialog>("Новый участник коференции");
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var addedSpeaker = await SpeakerService.AddSpeaker(dialog.Result.Result.Data as Speaker);

                speakers.Add(addedSpeaker);
                Snackbar.Add("Участник конференции успешно добавлен!", Severity.Success);
            }
        }
Ejemplo n.º 12
0
        private async Task CreateDashboard()
        {
            var config = await HttpClient.GetFromJsonAsync <List <DashboardConfig> >("api/dashboards/configuration");

            config.Add(new DashboardConfig {
                DashboardId = _dashboardName.Replace(" ", "-").Trim().ToLower(), DashboardName = _dashboardName
            });

            await HttpClient.PutAsJsonAsync("api/dashboards/configuration", config);

            Snackbar.Add(_dashboardName + " created", Severity.Success);
            MudDialog.Close(DialogResult.Ok(true));
        }
Ejemplo n.º 13
0
        private async Task AddReport()
        {
            var dialog = Dialog.Show <ReportAddOrUpdateDialog>("Новый доклад");
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var addedReport = await ReportService.AddReport(dialog.Result.Result.Data as Report);

                reports.Add(addedReport);
                Snackbar.Add("Новый доклад успешно добавлен!", Severity.Success);
            }
        }
Ejemplo n.º 14
0
        private async Task AddConference()
        {
            var dialog = Dialog.Show <ConferenceAddOrUpdateDialog>("Новая коференция");
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var addedConfirence = await ConferenceService.AddConference(dialog.Result.Result.Data as Conference);

                conferences.Add(addedConfirence);
                Snackbar.Add("Конференция добавлена!", Severity.Success);
            }
        }
Ejemplo n.º 15
0
 void DeleteEmployee()
 {
     if (objinsert.EmpId > 0)
     {
         Http.DeleteAsync("http://localhost:56001/api/Employee/DeleteById/" + objinsert.EmpId);
         popupDelete = false;
         Snackbar.Add("The recorod is Delete", Severity.Success);
         //Http.GetAsync("http://localhost:56001/api/Employee");
     }
     else
     {
         popupDelete = false;
     }
 }
Ejemplo n.º 16
0
 public async Task DeleteTrack(string id)
 {
     if (track != null && track.Id != string.Empty)
     {
         await Http.DeleteAsync(Constants.API_PATH + id);
     }
     else
     {
         Snackbar.Add("Error", Severity.Error);
     }
     Snackbar.Add("Track Deleted", Severity.Success);
     this.StateHasChanged();
     await GetTrack();
 }
Ejemplo n.º 17
0
        private async Task DeleteConference(Conference conference)
        {
            var parameters = new DialogParameters {
                ["conference"] = conference
            };
            var dialog = Dialog.Show <ConferenceDeleteDialog>("Удаление конференции", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var deletedConfirence = await ConferenceService.DeleteConference(dialog.Result.Result.Data as Conference);

                conferences.Remove(deletedConfirence);
                Snackbar.Add("Конференция удалена!", Severity.Success);
            }
        }
Ejemplo n.º 18
0
 void Insert()
 {
     if (objinsert.EmpId > 0)
     {
         Http.PutJsonAsync("http://localhost:56001/api/Employee", objinsert);
         popup = false;
         Snackbar.Add("The recorod is Edit", Severity.Success);
     }
     else
     {
         Http.PostJsonAsync("http://localhost:56001/api/Employee", objinsert);
         Snackbar.Add("The recorod is Add", Severity.Success);
         Http.GetAsync("http://localhost:56001/api/Employee");
         popup = false;
     }
 }
Ejemplo n.º 19
0
        private async Task DeleteInstitution(Institution institution)
        {
            var parameters = new DialogParameters {
                ["institution"] = institution
            };
            var dialog = Dialog.Show <InstitutionDeleteDialog>("Удаление учебного заведения", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var deletedInstitution = await InstitutionService.DeleteInstitution(dialog.Result.Result.Data as Institution);

                institutions.Remove(deletedInstitution);
                Snackbar.Add("Учебное заведение удалено!", Severity.Success);
            }
        }
Ejemplo n.º 20
0
        public async Task GetBooks(bool paging)
        {
            if (!paging)
            {
                PageIndex = 1;
            }
            Loading = true;
            await Mediator.Send(new GetAudiobookFilesRequest(Title, Author, SeriesName, PageIndex, PageSize))
            .Tap(r => Series    = r.Series)
            .Tap(r => PageIndex = r.Page)
            .Tap(r => PageCount = r.PageCount)
            .OnFailure(e => Snackbar.Add(e, Severity.Error))
            .Finally(r => Loading = false);

            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 21
0
        private async Task DeleteReport(Report report)
        {
            var parameters = new DialogParameters {
                ["report"] = report
            };
            var dialog = Dialog.Show <ReportDeleteDialog>("Удаление доклада", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var deletedReport = await ReportService.DeleteReport(dialog.Result.Result.Data as Report);

                reports.Remove(deletedReport);
                Snackbar.Add("Информация о докладе удалена!", Severity.Success);
            }
        }
Ejemplo n.º 22
0
        private async Task DeleteSpeaker(Speaker speaker)
        {
            var parameters = new DialogParameters {
                ["speaker"] = speaker
            };
            var dialog = Dialog.Show <SpeakerDeleteDialog>("Удаление участника конференции", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var deletedSpeaker = dialog.Result.Result.Data as Speaker;
                await SpeakerService.DeleteSpeaker(deletedSpeaker);

                speakers.Remove(deletedSpeaker);
                Snackbar.Add("Участник конференции удален!", Severity.Success);
            }
        }
Ejemplo n.º 23
0
        private async Task UpdateSpeaker(Speaker speaker)
        {
            var parameters = new DialogParameters {
                ["speaker"] = speaker
            };
            var dialog = Dialog.Show <SpeakerAddOrUpdateDialog>("Редактирование участника коференции", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var updatedSpeaker = await SpeakerService.UpdateSpeaker(dialog.Result.Result.Data as Speaker);

                var index = speakers.IndexOf(speaker);
                speakers.Remove(speaker);
                speakers.Insert(index, updatedSpeaker);
                Snackbar.Add("Информация об участнике конференции обновлена!", Severity.Success);
            }
        }
Ejemplo n.º 24
0
        private async Task UpdateInstitution(Institution institution)
        {
            var parameters = new DialogParameters {
                ["institution"] = institution
            };
            var dialog = Dialog.Show <InstitutionAddOrUpdateDialog>("Редактирование учебного заведения", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var updatedInstitution = await InstitutionService.UpdateInstitution(dialog.Result.Result.Data as Institution);

                var index = institutions.IndexOf(institution);
                institutions.Remove(institution);
                institutions.Insert(index, updatedInstitution);
                Snackbar.Add("Информация об учебном заведении обновлена!", Severity.Success);
            }
        }
Ejemplo n.º 25
0
        private async Task UpdateReport(Report report)
        {
            var parameters = new DialogParameters {
                ["report"] = report
            };
            var dialog = Dialog.Show <ReportAddOrUpdateDialog>("Редактирование доклада", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var updatedReport = await ReportService.UpdateReport(dialog.Result.Result.Data as Report);

                var index = reports.IndexOf(report);
                reports.Remove(report);
                reports.Insert(index, updatedReport);
                Snackbar.Add("Информация о докладе успешно обновлена!", Severity.Success);
            }
        }
Ejemplo n.º 26
0
        private async Task UpdateConference(Conference conference)
        {
            var parameters = new DialogParameters {
                ["conference"] = conference
            };
            var dialog = Dialog.Show <ConferenceAddOrUpdateDialog>("Редактирование конференции", parameters);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var updatedConfirence = await ConferenceService.UpdateConference(dialog.Result.Result.Data as Conference);

                var index = conferences.IndexOf(conference);
                conferences.Remove(conference);
                conferences.Insert(index, updatedConfirence);
                Snackbar.Add("Информация о конференции успешно обновлена!", Severity.Success);
            }
        }
        private async Task RenameNode()
        {
            var dashboardConfigs = await HttpClient.GetFromJsonAsync <List <DashboardConfig> >("api/dashboards/configuration");

            var dashboard = dashboardConfigs?.FirstOrDefault(d => d.DashboardId == DashboardId);
            var node      = dashboard?.Nodes.FirstOrDefault(n => n.NodeName == DashboardNode.Name);

            if (node != null)
            {
                node.NodeName = _newNodeName;
                await HttpClient.PutAsJsonAsync("api/dashboards/configuration", dashboardConfigs);

                Snackbar.Add($"Node renamed to \"{_newNodeName}\"", Severity.Success);
                MudDialog.Close(DialogResult.Ok(true));
            }
            else
            {
                Snackbar.Add($"Node \"{DashboardNode.Name}\" not found.", Severity.Error);
                MudDialog.Close(DialogResult.Ok(true));
            }
        }
Ejemplo n.º 28
0
        protected override void OnAfterRender(bool firstRender)
        {
            if (firstRender)
            {
                this.dotNetInstance = DotNetObjectReference.Create(this);

                this.JsRuntime.InvokeVoid(
                    "App.Repl.init",
                    "user-code-editor-container",
                    "user-page-window-container",
                    "user-code-editor",
                    this.dotNetInstance);
            }

            if (!string.IsNullOrWhiteSpace(this.errorMessage))
            {
                Snackbar.Add(this.errorMessage, Severity.Error);
                this.errorMessage = null;
            }

            base.OnAfterRender(firstRender);
        }
        private async Task RenameProperty()
        {
            var dashboardConfigs = await HttpClient.GetFromJsonAsync <List <DashboardConfig> >("api/dashboards/configuration");

            var dashboard = dashboardConfigs?.FirstOrDefault(d => d.DashboardId == DashboardId);
            var node      = dashboard?.Nodes.FirstOrDefault(n => n.NodeName == DashboardNode.Name);
            var property  = node?.Properties.FirstOrDefault(p => p.PropertyName == DashboardProperty.AlternativeName && p.PropertyPath == DashboardProperty.ActualPropertyPath);

            if (property != null)
            {
                property.PropertyName = _newPropertyName;
                await HttpClient.PutAsJsonAsync("api/dashboards/configuration", dashboardConfigs);

                Snackbar.Add($"Property renamed to \"{_newPropertyName}\"", Severity.Success);
                MudDialog.Close(DialogResult.Ok(true));
            }
            else
            {
                Snackbar.Add($"Property \"{DashboardProperty.AlternativeName}\" not found.", Severity.Error);
                MudDialog.Close(DialogResult.Ok(true));
            }
        }
        private async Task Rename()
        {
            var dashboardConfigs = await HttpClient.GetFromJsonAsync <List <DashboardConfig> >("api/dashboards/configuration");

            var dashboardConfig = dashboardConfigs?.FirstOrDefault(d => d.DashboardId == Dashboard.Id);

            if (dashboardConfig != null)
            {
                dashboardConfig.DashboardName = _newDashboardName;
                dashboardConfig.DashboardId   = _newDashboardName.Replace(" ", "-").Trim().ToLower();
                await HttpClient.PutAsJsonAsync("api/dashboards/configuration", dashboardConfigs);

                Snackbar.Add($"Dashboard renamed to \"{_newDashboardName}\"", Severity.Success);
                MudDialog.Close(DialogResult.Ok(true));

                NavigationManager.NavigateTo($"dashboards/{dashboardConfig.DashboardId}");
            }
            else
            {
                Snackbar.Add($"Dashboard \"{Dashboard.Id}\" not found.", Severity.Error);
                MudDialog.Close(DialogResult.Ok(true));
            }
        }