Skip to content

Commit

Permalink
配置发布功能,配置详情页面调整。
Browse files Browse the repository at this point in the history
  • Loading branch information
Codespilot committed Jan 16, 2024
1 parent 7447ed6 commit ce86cff
Show file tree
Hide file tree
Showing 14 changed files with 733 additions and 31 deletions.
12 changes: 6 additions & 6 deletions Source/Starfish.Webapp/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
{
<Redirect Uri="/login" />
}
else if(ex is HttpRequestException e && e.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
<Redirect Uri="/login" />
}
else
{
<div class="blazor-error-boundary">@ex.Message</div>
Expand All @@ -61,14 +65,10 @@

<FluentFooter>
<div class="link1">
<span>
Nerosoft © 2024. All rights reserved.
</span>
<span>Nerosoft © @(DateTime.Today.Year). All rights reserved.</span>
</div>
<div class="link2">
<a href="javascript:void(0);" @onclick="@OnLogoutClicked">
Logout
</a>
<a href="javascript:void(0);" @onclick="@OnLogoutClicked">@(Resources.IDS_COMMON_LOGOUT)</a>
</div>
</FluentFooter>

Expand Down
18 changes: 9 additions & 9 deletions Source/Starfish.Webapp/Pages/Apps/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<FluentCard>
<FluentGrid>
<FluentGridItem lg="12" sm="12" md="12">
<div style="display: flex; width:100%;gap:10px;">
<div class="search-bar">
<FluentSearch Placeholder="@(Resources.IDS_COMMON_PLACEHOLDER_KEYWORD)" @bind-Value="Criteria.Keyword"/>
<FluentButton OnClick="@OnSearchClicked">@(Resources.IDS_COMMON_SEARCH)</FluentButton>
<FluentSpacer/>
Expand All @@ -23,15 +23,15 @@
</FluentGridItem>
<FluentGridItem lg="12" sm="12" md="12">
<FluentDataGrid ItemsProvider="_provider" Pagination="Pagination" ItemSize="46" GenerateHeader="GenerateHeaderOption.Sticky" TGridItem="AppInfoItemDto">
<PropertyColumn Style="line-height: 32px" Title="Id" Property="@(c => c.Id)"/>
<TemplateColumn Title="Name" Align="@Align.Start">
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_COMMON_COLUMN_ID)" Property="@(c => c.Id)"/>
<TemplateColumn Title="@(Resources.IDS_APPS_INDEX_COLUMN_NAME)" Align="@Align.Start">
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => HandleDetailClicked(context.Id))">@(context.Name)</FluentButton>
</TemplateColumn>
<PropertyColumn Style="line-height: 32px" Title="Code" Property="@(c => c.Code)"/>
<PropertyColumn Style="line-height: 32px" Title="Status" Property="@(c => c.StatusDescription)"/>
<PropertyColumn Style="line-height: 32px" Title="Create at" Property="@(c => c.CreateTime)"/>
<PropertyColumn Style="line-height: 32px" Title="Update at" Property="@(c => c.UpdateTime)"/>
<TemplateColumn Title="Actions" Align="@Align.End">
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_APPS_INDEX_COLUMN_CODE)" Property="@(c => c.Code)" />
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_APPS_INDEX_COLUMN_STATUS)" Property="@(c => c.StatusDescription)" />
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_COMMON_COLUMN_CREATE_TIME)" Property="@(c => c.CreateTime)" Format="yyyy-MM-dd HH:mm:ss" />
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_COMMON_COLUMN_UPDATE_TIME)" Property="@(c => c.UpdateTime)" Format="yyyy-MM-dd HH:mm:ss" />
<TemplateColumn Title="@(Resources.IDS_COMMON_COLUMN_ACTIONS)" Align="@Align.End">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Edit())" OnClick="@(() => OnEditClicked(context.Id))"/>
<FluentButton IconEnd="@(new Icons.Regular.Size16.LockClosedKey())" OnClick="@(() => OnResetSecretClicked(context.Id))"/>
<FluentButton IconEnd="@(new Icons.Regular.Size16.Delete())" OnClick="@(() => OnDeleteClicked(context.Id, context.Name))"/>
Expand Down Expand Up @@ -96,7 +96,7 @@

private async Task HandleDetailClicked(long id)
{
Navigation.NavigateTo($"/apps/{id}");
Navigation.NavigateTo($"/apps/{id}/settings");
await Task.CompletedTask;
}

Expand Down
5 changes: 5 additions & 0 deletions Source/Starfish.Webapp/Pages/Logging/Detail.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h3>Detail</h3>

@code {

}
4 changes: 2 additions & 2 deletions Source/Starfish.Webapp/Pages/Logging/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<FluentCard>
<FluentGrid>
<FluentGridItem lg="12" sm="12" md="12">
<div style="display: flex; width:100%;gap:10px;">
<div class="search-bar">
<FluentSearch Placeholder="@(Resources.IDS_COMMON_PLACEHOLDER_KEYWORD)" @bind-Value="Criteria.UserName"/>
<FluentDatePicker @bind-Value="@Criteria.MinTime"/>
<FluentDatePicker @bind-Value="@Criteria.MaxTime"/>
Expand All @@ -24,7 +24,7 @@
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_TYPE)" Property="@(c => c.Type)"/>
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_DESCRIPTION)" Property="@(c => c.Description)" Tooltip="true"/>
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_USER_NAME)" Property="@(c => c.UserName)"/>
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_OPERATE_TIME)" Property="@(c => c.OperateTime)"/>
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_OPERATE_TIME)" Property="@(c => c.OperateTime)" Format="yyyy-MM-dd HH:mm:ss"/>
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_ERROR)" Property="@(c => c.Error)" Tooltip="true"/>
<PropertyColumn Class="data-grid-column" Title="@(Resources.IDS_LOGS_INDEX_COLUMN_REQUEST_TRACE_ID)" Property="@(c => c.RequestTraceId)"/>
</FluentDataGrid>
Expand Down
137 changes: 137 additions & 0 deletions Source/Starfish.Webapp/Pages/Setting/Edit.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
@using Nerosoft.Starfish.Common
@implements IDialogContentComponent<EditDialogArgs>

@inject ISettingApi SettingApi
@inject IToastService ToastService

<FluentDialogHeader ShowDismiss="true">
<FluentStack VerticalAlignment="VerticalAlignment.Center">
<FluentIcon Value="@(new Icons.Regular.Size24.Settings())"/>
<FluentLabel Typo="Typography.PaneHeader">
@Dialog.Instance.Parameters.Title
</FluentLabel>
</FluentStack>
</FluentDialogHeader>

<FluentDialogBody>
<FluentStack Orientation="Orientation.Vertical">
<FluentTextField Style="width: 100%"
Label="@(Resources.IDS_SETTING_EDIT_LABEL_ENVIRONMENT)"
@bind-Value="Content.Environment" ReadOnly="true"/>

<div style="height: 100%; width: 100%;">
<StandaloneCodeEditor @ref="_editor" CssClass="monaco-editor-container" ConstructionOptions="EditorConstructionOptions" OnDidInit="EditorOnDidInit" />
</div>
</FluentStack>
</FluentDialogBody>

<FluentDialogFooter>
<FluentButton Appearance="Appearance.Accent" OnClick="@SaveAsync" Loading="Loading">@(Resources.IDS_COMMON_SAVE)</FluentButton>
<FluentButton Appearance="Appearance.Neutral" OnClick="@CancelAsync">@(Resources.IDS_COMMON_CANCEL)</FluentButton>
</FluentDialogFooter>

@code {

[Parameter]
public EditDialogArgs Content { get; set; }

[CascadingParameter]
public FluentDialog Dialog { get; set; } = default!;

private string Mode => Content?.Properties?.TryGetValue("mode") as string;

private string Format => Content?.Properties?.TryGetValue("format") as string;

private StandaloneCodeEditor _editor = null!;

protected override async Task OnInitializedAsync()
{
if (Mode == "update")
{
await LoadValueAsync();
}
}

private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{
var options = new StandaloneEditorConstructionOptions
{
AutomaticLayout = true,
Theme = "vs-dark"
};

options.Language = Format switch
{
Constants.Setting.FormatJson => "json",
Constants.Setting.FormatText => "text",
_ => options.Language
};

return options;
}

private async Task EditorOnDidInit()
{
await Task.CompletedTask;
}

private bool Loading { get; set; }

private async Task SaveAsync()
{
try
{
Loading = true;
var value = await _editor.GetValue();
var request = new SettingEditDto()
{
Type = "diff",
Data = Cryptography.Base64.Encrypt(value)
};
var task = Mode switch
{
"create" => SettingApi.CreateAsync(Content.AppId, Content.Environment, Format, request)
.ContinueWith(task =>
{
task.WaitAndUnwrapException();
task.Result.EnsureSuccess();
}),
"update" => SettingApi.UpdateAsync(Content.AppId, Content.Environment, Format, request)
.ContinueWith(task =>
{
task.WaitAndUnwrapException();
task.Result.EnsureSuccess();
}),
_ => Task.CompletedTask
};
await task;
await Dialog.CloseAsync(Content);
}
catch (Exception exception)
{
var message = exception.GetPromptMessage();
ToastService.ShowError(message);
}
finally
{
Loading = false;
}
}

private async Task CancelAsync()
{
await Dialog.CancelAsync();
}

private Task LoadValueAsync()
{
return SettingApi.GetItemsAsync(Content.AppId, Content.Environment, Format)
.ContinueWith(task =>
{
task.WaitAndUnwrapException();
var value = Cryptography.Base64.Decrypt(task.Result.EnsureSuccess());
_editor.SetValue(value);
});
}

}
16 changes: 16 additions & 0 deletions Source/Starfish.Webapp/Pages/Setting/EditDialogArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Nerosoft.Starfish.Webapp.Pages.Setting;

public class EditDialogArgs
{
public EditDialogArgs(long appId, string environment)
{
AppId = appId;
Environment = environment;
}

public long AppId { get; set; }

public string Environment { get; set; }

public Dictionary<string, object> Properties { get; set; }
}
81 changes: 81 additions & 0 deletions Source/Starfish.Webapp/Pages/Setting/EditValue.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@implements IDialogContentComponent<EditDialogArgs>

@inject ISettingApi SettingApi
@inject IToastService ToastService

<FluentDialogHeader ShowDismiss="true">
<FluentStack VerticalAlignment="VerticalAlignment.Center">
<FluentIcon Value="@(new Icons.Regular.Size24.Settings())"/>
<FluentLabel Typo="Typography.PaneHeader">
@Dialog.Instance.Parameters.Title
</FluentLabel>
</FluentStack>
</FluentDialogHeader>

<FluentDialogBody>
<FluentStack Orientation="Orientation.Vertical">
<FluentTextField Style="width: 100%"
Label="Key"
Value="@Key" ReadOnly="true"/>

<FluentTextArea Style="width: 100%"
Label="Value"
@bind-Value="Request.Value"/>
</FluentStack>
</FluentDialogBody>

<FluentDialogFooter>
<FluentButton Appearance="Appearance.Accent" OnClick="@SaveAsync" Loading="Loading">@(Resources.IDS_COMMON_SAVE)</FluentButton>
<FluentButton Appearance="Appearance.Neutral" OnClick="@CancelAsync">@(Resources.IDS_COMMON_CANCEL)</FluentButton>
</FluentDialogFooter>

@code {

[Parameter]
public EditDialogArgs Content { get; set; }

[CascadingParameter]
public FluentDialog Dialog { get; set; } = default!;

private bool Loading { get; set; }

private string Key => Content?.Properties?.TryGetValue("key") as string;

private SettingValueUpdateDto Request { get; } = new();

protected override async Task OnInitializedAsync()
{
Request.Value = Content?.Properties?.TryGetValue("value") as string;
await Task.CompletedTask;
}

private async Task SaveAsync()
{
try
{
Loading = true;
await SettingApi.UpdateItemValueAsync(Content.AppId, Content.Environment, Key, Request)
.ContinueWith(task =>
{
task.WaitAndUnwrapException();
task.Result.EnsureSuccess();
});
await Dialog.CloseAsync(Content);
}
catch (Exception exception)
{
var message = exception.GetPromptMessage();
ToastService.ShowError(message);
}
finally
{
Loading = false;
}
}

private async Task CancelAsync()
{
await Dialog.CancelAsync();
}

}
Loading

0 comments on commit ce86cff

Please sign in to comment.