Skip to content

Commit

Permalink
update to v4.8.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yswenli committed Aug 13, 2019
1 parent 37b3b66 commit 3c5c9f8
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 106 deletions.
48 changes: 48 additions & 0 deletions SAEA.WebRedisManager/Controllers/RedisController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ public ActionResult GetInfoString(string name)
}
}


public ActionResult GetClients(string name)
{
try
{
var data = CurrentRedisClient.Clients(name);

if (!string.IsNullOrEmpty(data))
{
return Json(new JsonResult<object>() { Code = 1, Data = data, Message = "OK" });
}
return Json(new JsonResult<string>() { Code = 2, Message = "暂未读取数据" });
}
catch (Exception ex)
{
return Json(new JsonResult<string>() { Code = 2, Message = ex.Message });
}
}

/// <summary>
/// 获取信息
/// </summary>
Expand Down Expand Up @@ -442,5 +461,34 @@ public ActionResult DelItem(RedisData redisData)
}
return Json(result);
}

[HttpPost]
public ActionResult AlterPWD(string name, string pwd1, string pwd2)
{
var result = new JsonResult<bool>() { Code = 3, Message = "操作失败" };
try
{
object data = string.Empty;
if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(pwd1) && !string.IsNullOrEmpty(pwd2) && pwd1 == pwd2)
{
if (CurrentRedisClient.AlterPWD(name, pwd2))
{
result.Code = 1;
result.Data = true;
result.Message = "ok";
}
}
else
{
result.Code = 2;
result.Message = "密码不一致!";
}
}
catch (Exception ex)
{
return Json(new JsonResult<string>() { Code = 2, Message = ex.Message });
}
return Json(result);
}
}
}
88 changes: 75 additions & 13 deletions SAEA.WebRedisManager/Libs/CurrentRedisClient.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using SAEA.Redis.WebManager.Models;
using SAEA.Common;
using SAEA.Redis.WebManager.Models;
using SAEA.RedisSocket;
using SAEA.RedisSocket.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SAEA.Redis.WebManager.Libs
{
Expand Down Expand Up @@ -73,6 +75,40 @@ public static string GetInfo(string name)
return string.Empty;
}

public static string Clients(string name)
{
if (_redisClients.ContainsKey(name))
{
var redisClient = _redisClients[name];

if (redisClient.IsConnected)
{
var list = redisClient.ClientList();

if (list != null && list.Any())
{
StringBuilder sb = new StringBuilder();

foreach (var item in list)
{
var arr = item.Split("id=", StringSplitOptions.RemoveEmptyEntries);

if (arr != null && arr.Any())
{
foreach (var sitem in arr)
{
sb.Append($"<p class='redisclient_p'>id={sitem}<p>");
}
}
}
return sb.ToString();
}
}
}

return string.Empty;
}




Expand Down Expand Up @@ -656,27 +692,53 @@ public static void DelItem(RedisData redisData)
}
}
}
/// <summary>
/// 修改密码
/// </summary>
/// <param name="name"></param>
/// <param name="pwd1"></param>
/// <param name="pwd2"></param>
/// <returns></returns>
public static bool AlterPWD(string name, string pwd)
{
if (_redisClients.ContainsKey(name))
{
var redisClient = _redisClients[name];
var result = redisClient.SetConfig("requirepass", pwd);
if (result)
{
var config = ConfigHelper.Get(name);
config.Password = pwd;
ConfigHelper.Set(config);
}
return result;
}
return false;
}

#region cluster

static RedisClient GetRedisClientByNodeID(string name, string nodeID)
{
var redisClient = _redisClients[name];
if (_redisClients.ContainsKey(name))
{
var redisClient = _redisClients[name];

var slaveNode = redisClient.ClusterNodes.Where(b => b.NodeID == nodeID).FirstOrDefault();
var slaveNode = redisClient.ClusterNodes.Where(b => b.NodeID == nodeID).FirstOrDefault();

if (slaveNode == null) return null;
if (slaveNode == null) return null;

if (!_redisClients.ContainsKey(nodeID))
{
var rc = new RedisClient(slaveNode.IPPort, redisClient.RedisConfig.Passwords);
rc.Connect();
_redisClients[nodeID] = rc;
}
if (!_redisClients.ContainsKey(nodeID))
{
var rc = new RedisClient(slaveNode.IPPort, redisClient.RedisConfig.Passwords);
rc.Connect();
_redisClients[nodeID] = rc;
}

if (_redisClients[nodeID].IsConnected)
{
return _redisClients[nodeID];
if (_redisClients[nodeID].IsConnected)
{
return _redisClients[nodeID];
}
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions SAEA.WebRedisManager/SAEA.WebRedisManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SAEA.MVC" Version="4.6.3.5" />
<PackageReference Include="SAEA.RedisSocket" Version="4.6.3.8" />
<PackageReference Include="SAEA.MVC" Version="4.8.6.6" />
<PackageReference Include="SAEA.RedisSocket" Version="4.8.6.6" />
</ItemGroup>
<ItemGroup>
<None Update="wwwroot\console.html">
Expand Down
8 changes: 6 additions & 2 deletions SAEA.WebRedisManager/wwwroot/Chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
<title>报表</title>
<link href="/content/css/layui.css" rel="stylesheet" />
<link href="/content/css/global.css" rel="stylesheet" />
<style type="text/css">
a {
color: #009688;
}
</style>
</head>
<body>
<div class="layui-fluid">
<div class="layui-row layui-col-space15" style="margin-top:15px;">
<div class="layui-card">
<div class="layui-card-header" style="font-size:18px;">
redis实例<a href="javascript:;" id="redis_name" style="color:#0094ff;"></a>资源使用情况 点击<a href="javascript:;" id="redis_console" style="color:#0094ff;">这里</a>进入命令行模式
<span id="redis_name"></span><a href="javascript:;" id="redis_info">Redis Info</a>】 【<a href="javascript:;" id="redis_console">Redis Console</a>】【<a href="javascript:;" id="redis_clients">Redis Clients</a>】【<a href="javascript:;" id="alter_passwords">Alter Passwords</a>
</div>
<div class="layui-card-body layuiadmin-card-list" style="height:400px;">
<div class="layui-col-sm6 layui-col-md6">
Expand Down Expand Up @@ -44,7 +49,6 @@
<div class="layui-card">
<div class="layui-card-header" style="font-size:18px;">
redis cluster nodes <button class="layui-btn" id="add_master">add cluster node</button>
<button class="layui-btn" id="add_slave">add cluster slave node</button>
</div>
<div class="layui-card-body layuiadmin-card-list" style="height:650px; overflow:auto">
<div class="layui-col-sm12 layui-col-md12">
Expand Down
130 changes: 111 additions & 19 deletions SAEA.WebRedisManager/wwwroot/Content/css/global.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
/**
layui瀹樼綉
By 璐ゅ績
*/


h1, h2, h3 {
font-size: 14px;
}

/* 甯冨眬 */
.site-inline {
font-size: 0;
}
Expand All @@ -34,7 +27,6 @@ h1, h2, h3 {
padding: 20px 0 10px 20px;
}

/* 澶撮儴 */
.header {
height: 59px;
border-bottom: 1px solid #404553;
Expand Down Expand Up @@ -613,7 +605,6 @@ body .layui-layout-admin .footer-demo {
text-align: center;
}

/* 璧炲姪鍟� */
.site-sponsor-home {
margin-top: 40px;
text-align: center;
Expand Down Expand Up @@ -1756,7 +1747,7 @@ body .site-demo-nav .layui-nav-item {



@-webkit-keyframes site-anim-closeup { /* 鐗瑰啓 */
@-webkit-keyframes site-anim-closeup {
from {
-webkit-transform: translate3d(0, 0, 0) scale(1);
opacity: 1;
Expand Down Expand Up @@ -1789,19 +1780,120 @@ body .site-demo-nav .layui-nav-item {
animation-name: site-anim-closeup;
overflow: hidden;
}
body::-webkit-scrollbar, textarea::-webkit-scrollbar {

body::-webkit-scrollbar, textarea::-webkit-scrollbar, div::-webkit-scrollbar {
width: 10px;
height: 1px;
}

body::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb {
body::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb, div::-webkit-scrollbar-thumb {
border-radius: 10px;
box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
background-image: radial-gradient(#fff,rgba(0,0,0,0.2));
box-shadow: inset 0 0 5px rgba(0,77,70,0.2);
background-image: radial-gradient(#00FFE8,rgba(0,77,70,0.2));
}

body::-webkit-scrollbar-track, textarea::-webkit-scrollbar-track{
box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
body::-webkit-scrollbar-track, textarea::-webkit-scrollbar-track, div::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px rgba(0,77,70,0.2);
border-radius: 10px;
background: #EDEDED;
}
background: #393D49;
}


#markImg {
display: inline-block;
width: 30px;
border-radius: 15px;
border: solid 1px;
position: relative;
top: -2px;
}

#markImg img {
width: 38px;
border: solid 2px #4bacff;
border-radius: 19px;
position: relative;
top: -4px;
}

@-webkit-keyframes rotation {

from {
-webkit-transform: rotate(0deg);
}

to {
-webkit-transform: rotate(360deg);
}
}

#markImg:hover {
-webkit-transform: rotate(360deg);
animation: rotation 1s linear infinite;
-moz-animation: rotation 1s linear infinite;
-webkit-animation: rotation 1s linear infinite;
-o-animation: rotation 1s linear infinite;
}

.redisclient_p {
margin-bottom: 20px;
}

.redisclient_p:hover {
background-color: #c8c8c8;
animation: bg-color 0.5s 1;
-webkit-animation: bg-color 0.5s 1;
}
@-webkit-keyframes bg-color {

0% {
background-color: #fff;
}

20% {
background-color: #f7f6f6;
}

40% {
background-color: #ebeaea;
}

60% {
background-color: #e1e0e0;
}

80% {
background-color: #d3d2d2;
}

100% {
background-color: #c8c8c8;
}
}

@keyframes bg-color {

0% {
background-color: #fff;
}

20% {
background-color: #f7f6f6;
}

40% {
background-color: #ebeaea;
}

60% {
background-color: #e1e0e0;
}

80% {
background-color: #d3d2d2;
}

100% {
background-color: #c8c8c8;
}
}
Loading

0 comments on commit 3c5c9f8

Please sign in to comment.