Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yswenli committed Sep 7, 2020
1 parent 1aa147b commit b4de4de
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 25 deletions.
23 changes: 22 additions & 1 deletion SAEA.WebRedisManager/Controllers/ConsoleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,39 @@
*****************************************************************************/
using SAEA.MVC;
using SAEA.Redis.WebManager.Libs;
using SAEA.Redis.WebManager.Models;
using SAEA.WebRedisManager.Libs;
using System;
using System.Collections.Generic;

namespace SAEA.WebRedisManager.Controllers
{
public class ConsoleController : Controller
{
public ActionResult SendCmd(string name, string cmd)
{
if (!string.IsNullOrEmpty(name) &&!string.IsNullOrEmpty(cmd))
if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(cmd))
{
return Content(CurrentRedisClient.Send(name, cmd));
}
return Content("输入的命令不能为空~");
}

/// <summary>
/// 获取输入的命令
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public ActionResult GetCMD(string input)
{
try
{
return Json(new JsonResult<IEnumerable<string>>() { Code = 1,Data= RedisCmdHelper.GetList(input) });
}
catch(Exception ex)
{
return Json(new JsonResult<string>() { Code = 2, Message = ex.Message });
}
}
}
}
43 changes: 43 additions & 0 deletions SAEA.WebRedisManager/Libs/RedisCmdHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/****************************************************************************
*项目名称:SAEA.WebRedisManager.Libs
*CLR 版本:4.0.30319.42000
*机器名称:WALLE-PC
*命名空间:SAEA.WebRedisManager.Libs
*类 名 称:RedisCmdHelper
*版 本 号:V1.0.0.0
*创建人: yswenli
*电子邮箱:yswenli@outlook.com
*创建时间:2020/9/7 13:25:07
*描述:
*=====================================================================
*修改时间:2020/9/7 13:25:07
*修 改 人: yswenli
*版 本 号: V1.0.0.0
*描 述:
*****************************************************************************/
using SAEA.RedisSocket.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SAEA.WebRedisManager.Libs
{
public static class RedisCmdHelper
{
static IEnumerable<string> _list;
static RedisCmdHelper()
{
_list = Enum.GetNames(typeof(RequestType)).Select(b => b.Replace("_", " "));
}

public static IEnumerable<string> GetList(string input, int max = 10)
{
if (string.IsNullOrEmpty(input))

return _list.OrderBy(b => b).Take(max);

return _list.Where(b => b.IndexOf(input, StringComparison.InvariantCultureIgnoreCase) > -1).OrderBy(b => b).Take(max);
}
}
}
6 changes: 3 additions & 3 deletions SAEA.WebRedisManager/SAEA.WebRedisManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SAEA.MVC" Version="5.3.3.6" />
<PackageReference Include="SAEA.RedisSocket" Version="5.3.3.5" />
<PackageReference Include="SAEA.WebSocket" Version="5.3.3.5" />
<PackageReference Include="SAEA.MVC" Version="5.3.3.7" />
<PackageReference Include="SAEA.RedisSocket" Version="5.3.3.7" />
<PackageReference Include="SAEA.WebSocket" Version="5.3.3.7" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion SAEA.WebRedisManager/wwwroot/Console.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<div class="layui-card-body layuiadmin-card-list" style="height:36px;">
<div class="layui-col-sm12 layui-col-md12">
<input type="text" id="cmdTxt" placeholder="请输入redis命令" class="layui-input" style="display:inline-block;width:800px;border-radius: 10px 0 0 10px;font-family:'Microsoft YaHei'" />
<input type="text" id="cmdTxt" placeholder="请输入redis命令" class="layui-input autocomplete" style="display:inline-block;width:800px;border-radius: 10px 0 0 10px;font-family:'Microsoft YaHei'" autocomplete="off"/>
<button id="runBtn" class="layui-btn" style="margin-left: -4px;margin-top: -2px;border-radius: 0 10px 10px 0px;">Run</button><button id="clearBtn" class="layui-btn">清空</button>
</div>
</div>
Expand Down
47 changes: 45 additions & 2 deletions SAEA.WebRedisManager/wwwroot/Content/js/redis.console.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ layui.use(['jquery', 'layer', 'form'], function () {
, shade: 0.01
});

var input = `${new Date().Format("yyyy-MM-dd HH:mm:ss")}输入:\r\n ${decodeURI(cmd)}\r\n\r\n`;
var t1 = new Date();

var input = `${t1.Format("yyyy-MM-dd hh:mm:ss.S")}\r\nCommand:${decodeURI(cmd)},`;

$.post("/console/sendcmd", `name=${redis_name}&cmd=${cmd}`, (result) => {

var output = `${new Date().Format("yyyy-MM-dd HH:mm:ss")}输出:\r\n${result}\r\n\r\n${$("#resultTxt").val()}`;
var t2 = new Date();

var output = `Cost:${t2.getTime() - t1.getTime()},Result:\r\n${result}\r\n\r\n${$("#resultTxt").val()}`;

$("#resultTxt").val(input + output);
$("#resultTxt")[0].scrollTop = 0;
Expand All @@ -70,4 +74,43 @@ layui.use(['jquery', 'layer', 'form'], function () {
$("#resultTxt").val("");
});

$(".autocomplete").keyup(function () {

var cur = $(this);

var wordStr = cur.val();

if ($("#autocomplete_div").html() === undefined) {
$("body").append("<div id='autocomplete_div' style='position:absolute;margin:0px;padding:3px;border:1px solid #ccc;display:block;width:150px;min-height:50px;height:auto;overflow:hidden;background:#fafafa;'></div>")
}

$("#autocomplete_div").css("left", cur.offset().left).css("top", cur.offset().top + 35);

$("#autocomplete_div").mouseleave(function () {
$("#autocomplete_div").slideUp(300);
});

$("#autocomplete_div").html("");

$.post("/api/console/getcmd?t=" + (new Date().getMilliseconds()), { input: wordStr }, function (data) {
if (data.Code === 1) {
var dhtml = "";
data.Data.forEach(function (element) {
dhtml += `<div>${element}</div>`;
});
$("#autocomplete_div").html(dhtml).slideDown(300);
$("#autocomplete_div div").hover(function () { $(this).css({ "background": "#0563C1", "color": "#fff", "cursor":"pointer" }); }, function () { $(this).css({ "background": "#fff", "color": "#000" }); });
}
else {
$("#autocomplete_div").slideUp(300);
}
$("#autocomplete_div div").click(function () {
cur.val($(this).html());
$("#autocomplete_div").slideUp(300);
});
});
});
$(".autocomplete").click(function () {
$(this).keyup();
});
});
27 changes: 15 additions & 12 deletions SAEA.WebRedisManagerForNet/SAEA.WebRedisManagerForNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@
<Reference Include="protobuf-net.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net.Core.3.0.29\lib\net461\protobuf-net.Core.dll</HintPath>
</Reference>
<Reference Include="SAEA.Common, Version=5.3.3.5, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.Common.5.3.3.5\lib\netstandard2.0\SAEA.Common.dll</HintPath>
<Reference Include="SAEA.Common, Version=5.3.3.7, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.Common.5.3.3.7\lib\netstandard2.0\SAEA.Common.dll</HintPath>
</Reference>
<Reference Include="SAEA.Http, Version=5.3.3.6, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.Http.5.3.3.6\lib\netstandard2.0\SAEA.Http.dll</HintPath>
<Reference Include="SAEA.Http, Version=5.3.3.7, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.Http.5.3.3.7\lib\netstandard2.0\SAEA.Http.dll</HintPath>
</Reference>
<Reference Include="SAEA.MVC, Version=5.3.3.6, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.MVC.5.3.3.6\lib\netstandard2.0\SAEA.MVC.dll</HintPath>
<Reference Include="SAEA.MVC, Version=5.3.3.7, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.MVC.5.3.3.7\lib\netstandard2.0\SAEA.MVC.dll</HintPath>
</Reference>
<Reference Include="SAEA.RedisSocket, Version=5.3.3.5, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.RedisSocket.5.3.3.5\lib\netstandard2.0\SAEA.RedisSocket.dll</HintPath>
<Reference Include="SAEA.RedisSocket, Version=5.3.3.7, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.RedisSocket.5.3.3.7\lib\netstandard2.0\SAEA.RedisSocket.dll</HintPath>
</Reference>
<Reference Include="SAEA.Sockets, Version=5.3.3.5, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.Sockets.5.3.3.5\lib\netstandard2.0\SAEA.Sockets.dll</HintPath>
<Reference Include="SAEA.Sockets, Version=5.3.3.7, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.Sockets.5.3.3.7\lib\netstandard2.0\SAEA.Sockets.dll</HintPath>
</Reference>
<Reference Include="SAEA.WebSocket, Version=5.3.3.5, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.WebSocket.5.3.3.5\lib\netstandard2.0\SAEA.WebSocket.dll</HintPath>
<Reference Include="SAEA.WebSocket, Version=5.3.3.7, Culture=neutral, PublicKeyToken=01a82380791791ab, processorArchitecture=MSIL">
<HintPath>..\packages\SAEA.WebSocket.5.3.3.7\lib\netstandard2.0\SAEA.WebSocket.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
Expand Down Expand Up @@ -189,6 +189,9 @@
<Compile Include="..\SAEA.WebRedisManager\Libs\CurrentRedisClient.cs">
<Link>Libs\CurrentRedisClient.cs</Link>
</Compile>
<Compile Include="..\SAEA.WebRedisManager\Libs\RedisCmdHelper.cs">
<Link>Libs\RedisCmdHelper.cs</Link>
</Compile>
<Compile Include="..\SAEA.WebRedisManager\Libs\ServerInfoDataHelper.cs">
<Link>Libs\ServerInfoDataHelper.cs</Link>
</Compile>
Expand Down
12 changes: 6 additions & 6 deletions SAEA.WebRedisManagerForNet/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<package id="Pipelines.Sockets.Unofficial" version="2.1.16" targetFramework="net462" />
<package id="protobuf-net" version="3.0.29" targetFramework="net462" />
<package id="protobuf-net.Core" version="3.0.29" targetFramework="net462" />
<package id="SAEA.Common" version="5.3.3.5" targetFramework="net462" />
<package id="SAEA.Http" version="5.3.3.6" targetFramework="net462" />
<package id="SAEA.MVC" version="5.3.3.6" targetFramework="net462" />
<package id="SAEA.RedisSocket" version="5.3.3.5" targetFramework="net462" />
<package id="SAEA.Sockets" version="5.3.3.5" targetFramework="net462" />
<package id="SAEA.WebSocket" version="5.3.3.5" targetFramework="net462" />
<package id="SAEA.Common" version="5.3.3.7" targetFramework="net462" />
<package id="SAEA.Http" version="5.3.3.7" targetFramework="net462" />
<package id="SAEA.MVC" version="5.3.3.7" targetFramework="net462" />
<package id="SAEA.RedisSocket" version="5.3.3.7" targetFramework="net462" />
<package id="SAEA.Sockets" version="5.3.3.7" targetFramework="net462" />
<package id="SAEA.WebSocket" version="5.3.3.7" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net462" />
<package id="System.Collections.Immutable" version="1.7.1" targetFramework="net462" />
Expand Down

0 comments on commit b4de4de

Please sign in to comment.