1
0
mirror of https://github.com/anope/anope.git synced 2026-07-09 13:23:13 +02:00

Merge pull request #12 from MatthewM/webcpanel

Web Panel Modifications
This commit is contained in:
Adam
2013-02-20 14:58:59 -08:00
8 changed files with 226 additions and 30 deletions
@@ -18,7 +18,7 @@ bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::
std::vector<Anope::string> params;
params.push_back(HTTPUtils::URLDecode(message.post_data["req"]));
WebPanel::RunCommand(na->nc->display, na->nc, Config->HostServ, "hostserv/request", params, replacements);
WebPanel::RunCommand(na->nc->display, na->nc, Config->HostServ, "hostserv/request", params, replacements, "CMDR");
}
if (na->HasVhost())
@@ -57,7 +57,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st
params.push_back(HTTPUtils::URLDecode(message.post_data["receiver"]));
params.push_back(HTTPUtils::URLDecode(message.post_data["message"]));
WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/send", params, replacements);
WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/send", params, replacements, "CMDR");
}
if (message.get_data.count("del") > 0 && message.get_data.count("number") > 0)
{
@@ -66,7 +66,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st
params.push_back(chname);
params.push_back(message.get_data["number"]);
WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/del", params, replacements);
WebPanel::RunCommand(na->nc->display, na->nc, Config->MemoServ, "memoserv/del", params, replacements, "CMDR");
}
if (message.get_data.count("read") > 0 && message.get_data.count("number") > 0)
{
@@ -1,6 +1,8 @@
{INCLUDE header.html}
<b>Channels you have access in:</b><br/>
<div class="cinfo">
{FOR CH,ECH IN CHANNEL_NAMES,ESCAPED_CHANNEL_NAMES}
<a href="/chanserv/set?channel={ECH}">{CH}</a></br>
{END FOR}
</div>
{INCLUDE footer.html}
@@ -2,9 +2,98 @@
<html>
<head>
<link href="/static/style.css" media="screen" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<title>{TITLE}</title>
{IF EXISTS CMDR}
<script type="text/javascript">
var tSec=5; //Time in seconds to keep the overlay open
var t=(tSec*1000); //Convert the time to ms so we can use it
$(document).ready(function() \{
/*Modal*/
var id = "#dialog";
var mHeight;
var mWidth;
var oHeight = $(id).height();
var oWidth = $(id).height();
var top;
var left;
showModal();
$('.close').click(function (e) \{
e.preventDefault();
hideModal();
\});
$('#mask').click(function () \{
hideModal();
\});
function hideModal() \{
if ($('#mask').not(':hidden')) \{
$('.master').fadeTo('slow',1.0);
$('#mask, .window').fadeOut(200);
\}
\}
function showModal() \{
mHeight = $(document).height();
mWidth = $(window).width();
var alertMsg = '<br/>{CMDR}<br/>';
$('#mask').css(\{'width': mWidth, 'height': mHeight\});
$('#mask').fadeIn(200);
$('#mask').fadeTo('fast',0.75);
$('#dialogMsg').html(alertMsg);
top = mHeight/2-oHeight/2;
left = mWidth/2-oHeight/2;
$(id).css('top', top);
$(id).css('left', left);
$('.master').fadeTo('fast',0.3);
$(id).fadeIn(500);
setTimeout(hideModal, t);
\}
$(window).resize(function() \{
if ($('#mask').not(':hidden')) \{
mHeight = $(document).height();
mWidth = $(window).width();
/* Might as well only change the postion of box if the window is large enough */
if ((mHeight > oHeight) && (mWidth > oWidth)) \{
top = mHeight/2-oHeight/2;
left = mWidth/2-oHeight/2;
$('#mask').css(\{'width': mWidth, 'height': mHeight\});
$(id).css('top', top);
$(id).css('left', left);
\}
\}
\})
\});
</script>
{END IF}
</head>
<body>
<div id="boxes">
<div id="dialog" class="window">
<h2>Status Message:</h2>
<div id="dialogMsg"></div>
<div id="dialogClose"><a href="#" class="close">Dismiss</a></div>
</div>
<div id="mask"></div>
</div>
<div class="master">
<div class="header">
<ul id="button">
@@ -1,7 +1,7 @@
{INCLUDE header.html}
<b>Channels you have access in:</b><br/>
{FOR CH,ECH IN CHANNEL_NAMES,ESCAPED_CHANNEL_NAMES}
<a href="/memoserv/memos?channel={ECH}">{CH}</a>
<a href="/memoserv/memos?channel={ECH}" class="channel">{CH}</a>
{END FOR}
<br/><br/>
{FOR M IN MESSAGES}
@@ -9,29 +9,48 @@
{END FOR}
<br/>
{IF EXISTS NUMBER}
<script type="text/javascript">
$("#memoTable").ready(function() \{
$(".reply").click(function(e) \{
e.preventDefault();
var recv = $(this).attr('href');
$("#receiver").val(recv);
\});
\});
</script>
<b>Memos List:</b>
<table width="100%" height="100%">
<table width="100%" height="100%" id="memoTable">
<tr>
<th>Number</th>
<th>Sender</th>
<th>Time/Message</th>
<th class="akillR1">Number</th>
<th class="akillR3">Sender</th>
<th class="akillR2">Time/Message</th>
</tr>
{FOR I,S,T,TXT,U IN NUMBER,SENDER,TIME,TEXT,UNREAD}
<tr>
<td>{I}</td>
<td>{S}</td>
<td>{T}</td>
{IF EQ U YES}
<td><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=1">Mark as Read</a></td>
<tr class="read">
{ELSE}
<td><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=2">Mark as Unread</a></td>
<tr class="unread">
{END IF}
<td><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a></td>
<td class="akillR1">{I}</td>
<td class="akillR3">{S}</td>
<td class="akillR2"><abbr title="{T}">{TXT}</abbr></td>
</tr>
<tr>
<td></td><td></td>
<td>{TXT}</td>
{IF EQ U YES}
<tr class="read">
<td></td>
<td></td>
<td class="right"><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=1">Mark as Read</a> &nbsp;
<a href="{S}" class="reply" id="memo{I}">Reply</a>&nbsp;
<a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a></td>
{ELSE}
<tr class="unread">
<td></td>
<td></td>
<td class="right"><a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=2">Mark as Unread</a> &nbsp;
<a href="{S}" class="reply" id="memo{I}">Reply</a> &nbsp;
<a href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a></td>
{END IF}
</tr>
{END FOR}
</table>
@@ -43,7 +62,7 @@
<b>Send a new Memo</b>
<form method="post" action="/memoserv/memos?channel={ESCAPED_CHANNEL}">
Receiver: <input type="text" name="receiver">
Receiver: <input type="text" name="receiver" id="receiver" value="">
Message: <input type="text" name="message">
<input type="submit" value="Send">
</form>
@@ -3,6 +3,7 @@ font-family: 'Cabin', Helvetica, Arial, sans-serif;
}
body {
overflow:hidden;
z-index: 10;
}
.master {
margin-left:0px;
@@ -101,6 +102,15 @@ body {
height: 125px;
}
.cinfo {
overflow-x: scroll;
height: 450px;
}
.right {
text-align: right;
}
/* Table Stuff */
.akillR1 {
width: 80px;
text-align: left;
@@ -114,7 +124,81 @@ body {
text-align: left;
}
.danger {
color: red;
weight: bolder;
td.right a:link, td.right a:visited {
color: #000;
background-color: #FFF;
border: 1px solid #000;
padding: 0px 4px;
-webkit-border-radius: 5x;
border-radius: 5px;
text-decoration: none;
}
td.right a:hover {
color: #00F;
}
table#memoTable {
border-spacing: 0px;
border-collapse: collapse;
}
table#memoTable tr {
padding: 1px;
}
tr.read {
background-color: #FFF;
}
tr.unread {
background-color: #EEE;
}
tr.read td, tr.unread td {
padding: 2px;
}
/* Modal Window */
#mask {
position: absolute;
z-index: 9000;
background-color: #000;
height: 100%;
width: 100%;
display: none;
}
#boxes .window {
position:fixed;
width:440px;
height:200px;
display:none;
z-index:9999;
padding:20px;
}
#boxes #dialog {
text-align: center;
background-color: #FFF;
width:375px;
height:203px;
padding: 20px;
-webkit-border-radius: 15px;
border-radius: 15px;
display: none;
}
#dialogClose {
padding-top: 20px;
}
#dialogClose a:link, #dialogClose a:visited {
color: #000;
text-decoration: none;
}
#dialogClose a:hover {
color: #000;
text-decoration: underline;
}
+6 -5
View File
@@ -217,12 +217,12 @@ class ModuleWebCPanel : public Module
namespace WebPanel
{
void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> &params, TemplateFileServer::Replacements &r)
void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> &params, TemplateFileServer::Replacements &r, const Anope::string &key)
{
ServiceReference<Command> cmd("Command", c);
if (!cmd)
{
r["MESSAGES"] = "Unable to find command " + c;
r[key] = "Unable to find command " + c;
return;
}
@@ -237,15 +237,16 @@ namespace WebPanel
struct MyComandReply : CommandReply
{
TemplateFileServer::Replacements &re;
const Anope::string &k;
MyComandReply(TemplateFileServer::Replacements &_r) : re(_r) { }
MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { }
void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override
{
re["MESSAGES"] = msg;
re[k] = msg;
}
}
my_reply(r);
my_reply(r, key);
CommandSource source(user, NULL, nc, &my_reply, bi);
cmd->Execute(source, params);
+3 -2
View File
@@ -145,9 +145,10 @@ namespace WebPanel
* @param service Service for source.owner and source.service
* @param c Command to run (as a service name)
* @param params Command parameters
* @param r Replacements, reply from command goes back into r["MESSAGES"]
* @param r Replacements, reply from command goes back here into key
* @param key The key to put the replies into r
*/
extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> &params, TemplateFileServer::Replacements &r);
extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> &params, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES");
}
#include "pages/index.h"