-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d628c88
commit 5672341
Showing
1 changed file
with
1 addition
and
69 deletions.
There are no files selected for viewing
70 changes: 1 addition & 69 deletions
70
src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmInputSearchComponent.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,4 @@ | ||
@namespace Masa.Tsc.Web.Admin.Rcl.Components.Apm | ||
@inherits ApmComponentBase | ||
|
||
@* <SSearch BackgroundColor="white" @bind-Value="@Value" OnEnter="OnValueChange" Class="rounded-2" Style="width:100%" /> *@ | ||
|
||
<SAutoComplete BackgroundColor="white" | ||
Items="items" | ||
TItem="KeyValuePair<int,string>" | ||
TValue="string" | ||
TItemValue="string" | ||
ItemText="item=>item.Value" | ||
ItemValue="item=>item.Value" | ||
Value="Value" | ||
OnSearchInputUpdate="InputChanged" | ||
Filter="Filter" | ||
OnEnter="OnValueChange" Class="rounded-2" Style="width:100%"> | ||
|
||
</SAutoComplete> | ||
|
||
@code { | ||
Dictionary<int, string> list = new Dictionary<int, string>() | ||
{ | ||
{0,"" }, | ||
{1,"ServiceName" }, | ||
{2,"Endpoint" } | ||
|
||
}; | ||
|
||
List<KeyValuePair<int, string>> items = new(); | ||
|
||
protected override void OnInitialized() | ||
{ | ||
base.OnInitialized(); | ||
list[0] = Value; | ||
items = list.ToList(); | ||
} | ||
|
||
Regex reg = new Regex(@"^\S+$|(?<=(and|or)\s*)\S+"); | ||
|
||
string lastMatch = string.Empty; | ||
|
||
|
||
private void InputChanged(string search) | ||
{ | ||
if (reg.IsMatch(search)) | ||
{ | ||
var str = reg.Matches(search).Last().Value; | ||
//str.StartsWith(lastMatch) | ||
lastMatch = str; | ||
list[0] = search; | ||
} | ||
|
||
} | ||
|
||
|
||
private bool Filter(KeyValuePair<int, string> _, string a, string b) | ||
{ | ||
if (!string.IsNullOrEmpty(b) && reg.IsMatch(a)) | ||
{ | ||
var value = reg.Matches(b).Last().Value; | ||
|
||
return b.StartsWith(value, StringComparison.CurrentCultureIgnoreCase); | ||
} | ||
return false; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
<SSearch BackgroundColor="white" @bind-Value="@Value" OnEnter="OnValueChange" Class="rounded-2" Style="width:100%" /> |