move some stuff for live radar for compiled views

add chat icon to send messages to servers on server view
This commit is contained in:
RaidMax 2019-07-13 20:45:25 -05:00
parent b0365a5a43
commit fc43e47874
10 changed files with 105 additions and 38 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
@ -6,21 +6,24 @@
<RazorCompiledOnPublish Condition="'$(CONFIG)'!='Debug'">true</RazorCompiledOnPublish> <RazorCompiledOnPublish Condition="'$(CONFIG)'!='Debug'">true</RazorCompiledOnPublish>
<Version>0.1.0.0</Version> <Version>0.1.0.0</Version>
<Configurations>Debug;Release;Prerelease</Configurations> <Configurations>Debug;Release;Prerelease</Configurations>
<LangVersion>7.1</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\SharedLibraryCore\SharedLibraryCore.csproj"> <ProjectReference Include="..\..\SharedLibraryCore\SharedLibraryCore.csproj">
<Private>false</Private> <Private>false</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\WebfrontCore\WebfrontCore.csproj"> <ProjectReference Include="..\..\WebfrontCore\WebfrontCore.csproj" />
<Private>false</Private>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Web\wwwroot\images\" /> <Folder Include="Web\wwwroot\images\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)BUILD\Plugins&quot;" /> <Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)BUILD\Plugins&quot;" />
</Target> </Target>

View File

@ -167,6 +167,7 @@ namespace SharedLibraryCore.Commands
public override Task ExecuteAsync(GameEvent E) public override Task ExecuteAsync(GameEvent E)
{ {
E.Owner.Broadcast($"{(E.Owner.GameName == Server.Game.IW4 ? "^:" : "")}{E.Origin.Name} - ^6{E.Data}^7", E.Origin); E.Owner.Broadcast($"{(E.Owner.GameName == Server.Game.IW4 ? "^:" : "")}{E.Origin.Name} - ^6{E.Data}^7", E.Origin);
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SAY_SUCCESS"]);
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

View File

@ -203,5 +203,43 @@ namespace WebfrontCore.Controllers
var state = Manager.TokenAuthenticator.GenerateNextToken(Client.NetworkId); var state = Manager.TokenAuthenticator.GenerateNextToken(Client.NetworkId);
return string.Format(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GENERATETOKEN_SUCCESS"], state.Token, $"{state.RemainingTime} {Utilities.CurrentLocalization.LocalizationIndex["GLOBAL_MINUTES"]}", Client.ClientId); return string.Format(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GENERATETOKEN_SUCCESS"], state.Token, $"{state.RemainingTime} {Utilities.CurrentLocalization.LocalizationIndex["GLOBAL_MINUTES"]}", Client.ClientId);
} }
public IActionResult ChatForm(long id)
{
var info = new ActionInfo()
{
ActionButtonLabel = Localization["WEBFRONT_ACTION_LABEL_SUBMIT_MESSAGE"],
Name = "Chat",
Inputs = new List<InputInfo>
{
new InputInfo()
{
Name = "message",
Type = "text",
Label = Localization["WEBFRONT_ACTION_LABEL_MESSAGE"]
},
new InputInfo()
{
Name = "id",
Value = id.ToString(),
Type = "hidden"
}
},
Action = "ChatAsync"
};
return View("_ActionForm", info);
}
public async Task<IActionResult> ChatAsync(long id, string message)
{
var server = Manager.GetServers().First(_server => _server.EndPoint == id);
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
{
serverId = server.EndPoint,
command = $"!say {message}"
}));
}
} }
} }

View File

@ -72,7 +72,7 @@ namespace WebfrontCore.Controllers
if (clientId > 0) if (clientId > 0)
{ {
Client.ClientId = clientId; Client.ClientId = clientId;
Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertGuidToLong(); Client.NetworkId = clientId == 1 ? 0 : User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertGuidToLong();
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value); Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value }; Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
Authorized = Client.ClientId >= 0; Authorized = Client.ClientId >= 0;

View File

@ -5,41 +5,47 @@
<form class="action-form" action="/Action/@Model.Action"> <form class="action-form" action="/Action/@Model.Action">
@foreach (var input in Model.Inputs) @foreach (var input in Model.Inputs)
{ {
<div class="input-group mb-3"> string inputType = input.Type ?? "text";
string value = input.Value ?? "";
<div class="input-group-prepend"> if (input.Type != "hidden")
<span class="input-group-text" id="basic-addon-@input.Name">@input.Label</span> {
</div> <div class="input-group mb-3">
@{
string inputType = input.Type ?? "text";
string value = input.Value ?? "";
if (inputType == "select") <div class="input-group-prepend">
{ <span class="input-group-text" id="basic-addon-@input.Name">@input.Label</span>
<select name="@input.Name" class="form-control" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name">
@foreach (var item in input.Values)
{
<option value="@item.Key">@item.Value</option>
}
</select>
}
else if (inputType == "checkbox")
{
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="checkbox" name="@input.Name" @(input.Checked ? "checked" : "") autocomplete="off">@input.Label
</label>
</div> </div>
}
else @if (inputType == "select")
{ {
<input type="@inputType" name="@input.Name" value="@value" class="form-control" placeholder="@input.Placeholder" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name"> <select name="@input.Name" class="form-control" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name">
} @foreach (var item in input.Values)
{
<option value="@item.Key">@item.Value</option>
}
</select>
}
else if (inputType == "checkbox")
{
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="checkbox" name="@input.Name" @(input.Checked ? "checked" : "") autocomplete="off">@input.Label
</label>
</div>
}
else
{
<input type="@inputType" name="@input.Name" value="@value" class="form-control" placeholder="@input.Placeholder" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name">
}
</div>
}
else
{
<input type="@inputType" name="@input.Name" value="@value" hidden="hidden">
} }
</div>
} }
<button type="submit" class="btn btn-block btn-primary">@Model.ActionButtonLabel</button> <button type="submit" class="btn btn-block btn-primary">@Model.ActionButtonLabel</button>
</form> </form>

View File

@ -6,13 +6,25 @@
<div class="row server-header pt-1 pb-1 bg-primary " id="server_header_@Model.ID"> <div class="row server-header pt-1 pb-1 bg-primary " id="server_header_@Model.ID">
<div class="col-md-4 text-center text-md-left d-inline-flex justify-content-center justify-content-md-start"> <div class="col-md-4 text-center text-md-left d-inline-flex justify-content-center justify-content-md-start">
<span>@Model.Name</span> <span>@Model.Name</span>
<a href="@Model.ConnectProtocolUrl" class="ml-2 align-self-center d-none d-md-flex server-join-button" title="@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]"> <a href="@Model.ConnectProtocolUrl" class="ml-2 mr-2 align-self-center d-none d-md-flex server-join-button" title="@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]">
<span class="oi oi-play-circle mr-2 align-self-center"></span> <span class="oi oi-play-circle mr-2 align-self-center"></span>
<span class="server-header-ip-address" style="display:none;">@Model.IPAddress</span> <span class="server-header-ip-address" style="display:none;">@Model.IPAddress</span>
</a> </a>
@if (ViewBag.Authorized)
{
<span class="oi oi-chat align-self-center profile-action d-none d-md-flex" data-action="chat" data-action-id="@Model.ID"></span>
}
</div> </div>
<div class="text-center col-md-4">@Model.Map</div> <div class="text-center col-md-4">@Model.Map</div>
<div class="text-center text-md-right col-md-4"><span class="server-clientcount">@Model.ClientCount</span>/<span class="server-maxclients">@Model.MaxClients</span></div> <div class="text-center text-md-right col-md-4"><span class="server-clientcount">@Model.ClientCount</span>/<span class="server-maxclients">@Model.MaxClients</span></div>
@if (ViewBag.Authorized)
{
<div class="col-12 p-1">
<span class="oi oi-chat justify-content-center align-self-center profile-action d-flex d-md-none" data-action="chat" data-action-id="@Model.ID"></span>
</div>
}
</div> </div>
<div id="server_clientactivity_@Model.ID" class="bg-dark row server-activity pt-2 pb-2"> <div id="server_clientactivity_@Model.ID" class="bg-dark row server-activity pt-2 pb-2">

View File

@ -80,7 +80,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles;</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Update="Microsoft.NETCore.App" Version="2.2.2" /> <PackageReference Update="Microsoft.NETCore.App" Version="2.2.2" />
<PackageReference Update="Microsoft.AspNetCore" Version="2.2.0" /> <PackageReference Update="Microsoft.AspNetCore" Version="2.2.0" />

View File

@ -32,7 +32,9 @@ $(document).ready(function () {
*/ */
$('.profile-action').click(function (e) { $('.profile-action').click(function (e) {
const actionType = $(this).data('action'); const actionType = $(this).data('action');
$.get('/Action/' + actionType + 'Form') const actionId = $(this).data('action-id');
const actionIdKey = actionId == undefined ? '' : '?id=' + actionId;
$.get('/Action/' + actionType + 'Form' + actionIdKey)
.done(function (response) { .done(function (response) {
$('#actionModal .modal-message').fadeOut('fast'); $('#actionModal .modal-message').fadeOut('fast');
$('#actionModal .modal-body-content').html(response); $('#actionModal .modal-body-content').html(response);

View File

@ -1,6 +1,11 @@
Version 2.4:
-added "live radar" feature
-added chat message to server on server list view
Version 2.3: Version 2.3:
-added configuration option to ignore bots -added configuration option to ignore bots
-updated anticheat slightly -updated anticheat slightly
-lots more
Version 2.2: Version 2.2:
-upgraded projects to .NET 2.1 -upgraded projects to .NET 2.1