Пример #1
0
        private async Task DownloadConfig()
        {
            if (selectedConfig == null)
            {
                await ShowNoConfigSelectedMessage();

                return;
            }

            if (selectedConfig.IsRemote)
            {
                await js.AlertError(Loc["RemoteConfig"], Loc["CannotDownloadRemoteConfig"]);

                return;
            }

            try
            {
                var fileName = selectedConfig.Metadata.Name.ToValidFileName() + ".opk";
                await BlazorDownloadFileService.DownloadFile(fileName, await ConfigPacker.Pack(selectedConfig), "application/octet-stream");
            }
            catch (Exception ex)
            {
                await js.AlertError(ex.GetType().Name, ex.Message);

                return;
            }
        }
Пример #2
0
        private async Task CloneConfig()
        {
            if (selectedConfig == null)
            {
                await ShowNoConfigSelectedMessage();

                return;
            }

            // Pack and unpack to clone
            var packed = await ConfigPacker.Pack(selectedConfig);

            using var ms = new MemoryStream(packed);
            var newConfig = await ConfigPacker.Unpack(ms);

            // Change the id and save it again
            newConfig.Id = Guid.NewGuid().ToString();
            await ConfigRepo.Save(newConfig);

            // Set it as currently selected config
            configs.Insert(0, newConfig);
            selectedConfig = newConfig;
            ConfigService.Configs.Add(selectedConfig);
            ConfigService.SelectedConfig = selectedConfig;

            VolatileSettings.DebuggerLog = new();
            Nav.NavigateTo("config/edit/metadata");
        }