diff options
Diffstat (limited to 'funcweb')
19 files changed, 509 insertions, 17 deletions
diff --git a/funcweb/funcweb/controllers.py b/funcweb/funcweb/controllers.py index 2bdbe80..4d01c10 100644 --- a/funcweb/funcweb/controllers.py +++ b/funcweb/funcweb/controllers.py @@ -428,9 +428,108 @@ class Funcweb(object): """ identity.current.logout() raise redirect("/") + +################################ Groups API methods here ############################# + @expose(template="funcweb.templates.groups_main") + @identity.require(identity.not_anonymous()) + def groups_main(self): + """ + The main page of the groups + """ + #a dummy object to let us to get the groups api + #we dont supply a new group file it will handle the default + minion_api = Minions("*") + groups = minion_api.group_class.get_group_names() + del minion_api + #result to the template please :) + return dict(groups = groups) + + @expose(template="funcweb.templates.list_group") + @identity.require(identity.not_anonymous()) + def add_new_group(self,group_name,submit): + """ + Adding a new group + """ + minion_api = Minions("*") + minion_api.group_class.add_group(group_name,save=True) + groups = minion_api.group_class.get_group_names() + del minion_api + return dict(groups = groups) + @expose(template="funcweb.templates.list_group") + @identity.require(identity.not_anonymous()) + def remove_group(self,**kw): + """ + Adding a new group + """ + minion_api = Minions("*") + minion_api.group_class.remove_group(kw['group_name'],save=True) + groups = minion_api.group_class.get_group_names() + del minion_api + return dict(groups = groups) + + @expose(template="funcweb.templates.group_minion") + @identity.require(identity.not_anonymous()) + def list_host_by_group(self,group_name): + """ + Get the hosts for the specified group_name + """ + from copy import copy + copy_group_name = copy(group_name) + if not group_name.startswith('@'): + group_name = "".join(["@",group_name.strip()]) + + minion_api = Minions("*") + hosts = minion_api.group_class.get_hosts_by_group_glob(group_name) + all_minions = minion_api.get_all_hosts() + del minion_api + return dict(hosts = hosts,all_minions = all_minions,group_name = copy_group_name) + @expose(template="funcweb.templates.group_small") + @identity.require(identity.not_anonymous()) + def add_minions_togroup(self,**kw): + """ + Add or remove multiple minions to given group + """ + #print "The dict value is : ",kw + minion_api = Minions("*") + hosts = [] + if not kw.has_key('group_name') or not kw.has_key('action_name'): + return dict(hosts =hosts,group_name = None) + + current_host_list = None + + #if we are adding some hosts + if kw['action_name'] == "add": + if not kw.has_key('checkminion'): + return dict(hosts =hosts,group_name = kw['group_name']) + current_host_list = kw['checkminion'] + else:#it is a remove action + if not kw.has_key('rmgroup'): + return dict(hosts =hosts,group_name = kw['group_name']) + current_host_list = kw['rmgroup'] + #sanity checks + if type(current_host_list)!=list: + hosts.extend(current_host_list.split(",")) + else: + hosts.extend(current_host_list) + + if kw['action_name'] == "add": + minion_api.group_class.add_host_list(kw['group_name'],hosts,save = True) + else:#remove them + minion_api.group_class.remove_host_list(kw['group_name'],hosts,save = True) + + from copy import copy + #we need that check because @ is a sign for group search + group_name = copy(kw['group_name']) + if not group_name.startswith('@'): + group_name = "".join(["@",group_name.strip()]) + + hosts = minion_api.group_class.get_hosts_by_group_glob(group_name) + return dict(hosts =hosts,group_name = kw['group_name']) + +############################# END of GROUPS API METHODS ############################ class Root(controllers.RootController): @expose() diff --git a/funcweb/funcweb/static/css/groupscss.css b/funcweb/funcweb/static/css/groupscss.css new file mode 100644 index 0000000..84e171c --- /dev/null +++ b/funcweb/funcweb/static/css/groupscss.css @@ -0,0 +1,178 @@ +@charset "utf-8";
+/* CSS Document */
+
+
+#addgroupbigbox {
+background-color:#f7f7f7;
+height: 100px;
+width: 90%;
+padding:10px;
+border: 2px solid #dddddd;
+float:left;
+margin-left:30px;
+margin-right:30px;
+}
+#addgroup {
+height:50px;
+width:400px;
+margin-left:auto;
+margin-right:auto;
+margin-top: 2em;
+}
+#groupnametext {
+height:40px;
+width:50px;
+float:left;
+margin-right:10px;
+padding-top:2px;
+margin-left:2.2em;
+}
+#groupsbigbox {
+background-color:#f7f7f7;
+overflow: auto;
+max-height: 250px;
+width: 90%;
+padding:10px;
+border: 2px solid #dddddd;
+float:left;
+margin-left:30px;
+margin-right:30px;
+}
+#groupstexts {
+float:left;
+margin-left: 4em;
+height:25px;
+max-width: 250px;
+margin-top: 2em;
+}
+
+#miniongroupsbigbox {
+background-color:#f7f7f7;
+min-height: 150px;
+width: 90%;
+padding:10px;
+border: 2px solid #dddddd;
+float:left;
+margin-left:30px;
+margin-right:30px;
+}
+
+.addgroupbox {
+background-color: #FFFFFF;
+border: 2px solid #dddddd;
+width:200px;
+height:20px;
+float:left;
+}
+.removebtn {
+height:25px;
+width:25px;
+background-image:url(../images/removebtn.jpg);
+background-repeat:no-repeat;
+display:block;
+border: 0px;
+margin-top: 2.4em;
+float:left;
+}
+.removebtn:link {
+height:25px;
+width:25px;
+background-image:url(../images/removebtn.jpg);
+background-repeat:no-repeat;
+display:block;
+border: 0px;
+margin-top: 2.4em;
+float:left;
+}
+.removebtn:hover {
+height:25px;
+width:25px;
+background-image: url(../images/removebtnhover.jpg);
+background-repeat:no-repeat;
+display:block;
+border: 0px;
+margin-top: 2.4em;
+float:left;
+}
+
+.removegroupbtn {
+height:25px;
+width:25px;
+background-image:url(../images/groupremovebtn.jpg);
+background-repeat:no-repeat;
+display:block;
+border: 0px;
+}
+.removegroupbtn:link {
+height:25px;
+width:25px;
+background-image:url(../images/groupremovebtn.jpg);
+background-repeat:no-repeat;
+display:block;
+border: 0px;
+}
+.removegroupbtn:hover {
+height:25px;
+width:25px;
+background-image: url(../images/groupremovebtnhover.jpg);
+background-repeat:no-repeat;
+display:block;
+border: 0px;
+}
+
+#group {
+max-height: 400px;
+width: 40%;
+padding:10px;
+float:left;
+margin-left:30px;
+margin-right:30px;
+}
+#groupbox {
+background-color:#F1F5F6;
+border: 2px solid #dddddd;
+overflow: auto;
+max-height: 150px;
+margin-top: 2em;
+}
+#grouptextbox {
+max-width:100px;
+margin-bottom:15px;
+margin-top:10px;
+margin-left:190px;
+}
+#minions2 {
+max-height: 400px;
+width: 40%;
+padding:10px;
+float:left;
+margin-left:30px;
+margin-right:30px;
+}
+#minions2box {
+background-color:#F1F5F6;
+border: 2px solid #dddddd;
+overflow: auto;
+max-height: 150px;
+margin-top: 2em;
+}
+#minionstextbox {
+margin-left:190px;
+max-width:250px;
+margin-bottom:15px;
+margin-top:10px;
+}
+#selectallbox {
+float:right;
+margin-top:10px;
+}
+#selectallgroupboxes {
+float:left;
+margin-top:10px;
+}
+.minionsandgroupsbluetext {
+font-family: Arial, Helvetica, sans-serif;
+font-size:18px;
+color: #5499d4;
+text-decoration:none;
+}
\ No newline at end of file diff --git a/funcweb/funcweb/static/images/button_overadd.jpg b/funcweb/funcweb/static/images/button_overadd.jpg Binary files differnew file mode 100644 index 0000000..32d0e2d --- /dev/null +++ b/funcweb/funcweb/static/images/button_overadd.jpg diff --git a/funcweb/funcweb/static/images/buttonadd.jpg b/funcweb/funcweb/static/images/buttonadd.jpg Binary files differnew file mode 100644 index 0000000..5942919 --- /dev/null +++ b/funcweb/funcweb/static/images/buttonadd.jpg diff --git a/funcweb/funcweb/static/images/groupremovebtn.jpg b/funcweb/funcweb/static/images/groupremovebtn.jpg Binary files differnew file mode 100644 index 0000000..03adf3f --- /dev/null +++ b/funcweb/funcweb/static/images/groupremovebtn.jpg diff --git a/funcweb/funcweb/static/images/groupremovebtnhover.jpg b/funcweb/funcweb/static/images/groupremovebtnhover.jpg Binary files differnew file mode 100644 index 0000000..4c57451 --- /dev/null +++ b/funcweb/funcweb/static/images/groupremovebtnhover.jpg diff --git a/funcweb/funcweb/static/images/removebtn.jpg b/funcweb/funcweb/static/images/removebtn.jpg Binary files differnew file mode 100644 index 0000000..f790fc7 --- /dev/null +++ b/funcweb/funcweb/static/images/removebtn.jpg diff --git a/funcweb/funcweb/static/images/removebtnhover.jpg b/funcweb/funcweb/static/images/removebtnhover.jpg Binary files differnew file mode 100644 index 0000000..eef98b8 --- /dev/null +++ b/funcweb/funcweb/static/images/removebtnhover.jpg diff --git a/funcweb/funcweb/static/javascript/ajax.js b/funcweb/funcweb/static/javascript/ajax.js index b54ed7a..d9927a3 100644 --- a/funcweb/funcweb/static/javascript/ajax.js +++ b/funcweb/funcweb/static/javascript/ajax.js @@ -24,8 +24,18 @@ function addDomAjaxREsult(){ function remoteFormRequest(form, target, options) { var query = Array(); var contents = formContents(form); - for (var j=0; j<contents[0].length; j++) - query[contents[0][j]] = contents[1][j]; + for (var j=0; j<contents[0].length; j++){ + if(compare(target,'group_small')==0){ + if(!query[contents[0][j]]){ + query[contents[0][j]] = []; + } + //add that here + query[contents[0][j]].push(contents[1][j]); + + } + else + query[contents[0][j]] = contents[1][j]; + } query["tg_random"] = new Date().getTime(); //makePOSTRequest(form.action, target, queryString(query)); remoteRequest(form, form.action, target, query, options); @@ -104,3 +114,59 @@ function makePOSTRequest(source, url, target, parameters, options) { http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } + +function glob_submit(form_element,target_dom){ + /* + * Because it is a common function we have to move it here for better results + * form_element is what we submit and the target_dom is the place that will be replaced + */ + + before_action = null; + //sometimes we are not sure which dom to get so is that situation + if(compare(target_dom,'not_sure')==0) + target_dom = which_dom(); + + //if we are in the index page should to that + if (compare(target_dom,'minioncontent')==0){ + before_action = "myj('#resultcontent').hide();myj('#widgetcontent').hide();myj('#methotdscontent').hide();myj('#modulescontent').hide();"; + } + else if(compare(target_dom,'groupscontent')==0){ + before_action = "myj('#miniongroupcontents').hide();"; + } + + form_result = remoteFormRequest(form_element,target_dom, { + 'loading': null, + 'confirm': null, + 'after':null, + 'on_complete':null, + 'loaded':null, + 'on_failure':null, + 'on_success':null, + 'before':before_action + } + ); + + return form_result; +} + +function which_dom(){ + /* + * We use the glob submit in lots of places so we should + * know where we are actually so that method will handle that + */ + + dom_result = getElement('minioncontent'); + if (dom_result != null){ + //alert("Im giving back the minioncontent"); + return 'minioncontent'; + + } + + dom_result = getElement('another'); + //will change it later + if (dom_result != null){ + return 'another'; + } + + return dom_result; +} diff --git a/funcweb/funcweb/static/javascript/utils.js b/funcweb/funcweb/static/javascript/utils.js new file mode 100644 index 0000000..d06be6c --- /dev/null +++ b/funcweb/funcweb/static/javascript/utils.js @@ -0,0 +1,15 @@ +function checkAll(form_element){ + +} + +function uncheckAll(form_element){ + +} + +function checkController(form_element,check_element){ + if (check_element.checked == 1){ + checkAll(form_element); + } + else + uncheckAll(form_element); +} diff --git a/funcweb/funcweb/templates/add_group.html b/funcweb/funcweb/templates/add_group.html new file mode 100644 index 0000000..3386cbc --- /dev/null +++ b/funcweb/funcweb/templates/add_group.html @@ -0,0 +1,20 @@ +<div class="minioncontent" id="addgroupcontent" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude" + > + <div class="addgroupbigbox" id="addgroupbigbox"> + <div align="center" class="graytexts">Add Group</div> + <div class="graytexts" id="addgroup"> + <div class="groupnametext" id="groupnametext">Name:</div> + <form id="form_addgroup" name="form_addgroup" method="post" onsubmit="return !glob_submit(this, 'groupscontent');" action="/funcweb/add_new_group"> + <label> + <input name="group_name" type="text" class="addgroupbox" id="addgroupfield"/> + </label> + <label> + <input name="submit" type="submit" class="addnewgroupbtn" id="submit" value="ADD" /> + </label> + </form> + </div> + </div> +</div> diff --git a/funcweb/funcweb/templates/glob_form.html b/funcweb/funcweb/templates/glob_form.html new file mode 100644 index 0000000..8499d56 --- /dev/null +++ b/funcweb/funcweb/templates/glob_form.html @@ -0,0 +1,13 @@ +<div class="minionglob" id="minionglob" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> + + <form action="/funcweb/minions" method="post" onsubmit="return !glob_submit(this,'not_sure');" class="tableform" name="minion_form"> + <div class="graytexts2" id="minionglobtext"> + <div align="center">Minion Glob</div> + </div> + <input name="submit" type="submit" class="minionbutton" id="button" value="submit" border="0"/> + <input name="glob" type="text" class="minionbox" id="textfield" /> + </form> +</div> + diff --git a/funcweb/funcweb/templates/group_minion.html b/funcweb/funcweb/templates/group_minion.html new file mode 100644 index 0000000..5d9ea7a --- /dev/null +++ b/funcweb/funcweb/templates/group_minion.html @@ -0,0 +1,13 @@ +<div class="graytexts" id="miniongroupsbigbox" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude"> + + <div id="group_small"> + <xi:include href="group_small.html"/> + </div> + <div id="minion_small"> + <xi:include href="minion_small.html"/> + </div> + +</div> diff --git a/funcweb/funcweb/templates/group_small.html b/funcweb/funcweb/templates/group_small.html new file mode 100644 index 0000000..eff3965 --- /dev/null +++ b/funcweb/funcweb/templates/group_small.html @@ -0,0 +1,27 @@ +<div class="group" id="group" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> + <div align="center">Group</div> + <form action="/funcweb/add_minions_togroup" method="post" onsubmit="return !glob_submit(this,'group_small');" name="group_remove"> + <div class="groupbox" id="groupbox"> + <span py:for="host in hosts"> + <div class="minionstextblue" id="grouptextbox"><span class="minionsandgroupsbluetext">${host}</span> + <label> + <input type="checkbox" name="rmgroup" id="groupcheckbox" value="${host}"/> + </label> + </div> + </span> + </div> + <div class="selectallgroupboxes" id="selectallgroupboxes"> + <input type="hidden" name="action_name" value="remove"/> + <input type="hidden" name="group_name" value="${group_name}"/> + <span class="graytexts2">Select all:</span> + <label> + <input type="checkbox" name="groupcheckbox2" id="groupcheckbox2"/> + </label> + <label> + <input name="removegroups" type="submit" class="addnewgroupbtn" id="removegroups" value="Remove" /> + </label> + </div> + </form> +</div> diff --git a/funcweb/funcweb/templates/groups_main.html b/funcweb/funcweb/templates/groups_main.html new file mode 100644 index 0000000..5965c47 --- /dev/null +++ b/funcweb/funcweb/templates/groups_main.html @@ -0,0 +1,18 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude"> + <xi:include href="master.html"/> + <head/> + <body> + <xi:include href="add_group.html" /> + <div class="minioncontent" id="groupscontent"> + <xi:include href="list_group.html" /> + </div> + + <div class="minioncontent" id="miniongroupcontents"> + <!-- group_minion ends here --> + </div> + + </body> +</html> diff --git a/funcweb/funcweb/templates/index.html b/funcweb/funcweb/templates/index.html index 87c446e..3f3944d 100644 --- a/funcweb/funcweb/templates/index.html +++ b/funcweb/funcweb/templates/index.html @@ -6,20 +6,9 @@ <head/> <body onLoad = "window.setTimeout('check_async_change()',10000);"> - <div class="minionglob" id="minionglob"> - <form action="/funcweb/minions" method="post" onsubmit="return !remoteFormRequest(this, 'minioncontent', {"loading": null, "confirm": null, "after": null, "on_complete": null, "loaded": null, "on_failure": null, "on_success": null, "before":"myj('#resultcontent').hide();myj('#widgetcontent').hide();myj('#methotdscontent').hide();myj('#modulescontent').hide();"});" class="tableform" name="minion_form"> - - <div class="graytexts2" id="minionglobtext"> - <div align="center">Minion Glob</div> - </div> - <input name="submit" type="submit" class="minionbutton" id="button" value="submit" border="0"/> - <input name="glob" type="text" class="minionbox" id="textfield" /> - </form> - </div> - - - <div class="emptyimagebox" id="emptyimagebox"></div> - <div class="minioncontent" id="minioncontent"> + <xi:include href="glob_form.html" /> + <div class="emptyimagebox" id="emptyimagebox"></div> + <div class="minioncontent" id="minioncontent"> <div class="minionsbigbox" id="minionsbigbox" py:if="minions"> <div align="center" class="graytexts">Mininons</div> <div id="minionstexts" py:for="minion in minions"> diff --git a/funcweb/funcweb/templates/list_group.html b/funcweb/funcweb/templates/list_group.html new file mode 100644 index 0000000..6c6ce8c --- /dev/null +++ b/funcweb/funcweb/templates/list_group.html @@ -0,0 +1,16 @@ +<div class="groupsbigbox" id="groupsbigbox" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> + + <div align="center" class="graytexts">Groups</div> + <span py:for="group_name in groups"> + <div class="minionstextblue" id="groupstexts"><a href="#" onclick="myj('#miniongroupcontents').hide().load('/funcweb/list_host_by_group/${group_name}').show('slow');" >${group_name}</a></div> + <form action="/funcweb/remove_group" method="post" onsubmit="return !glob_submit(this,'groupscontent');" name="remove_form"> + + <input type="hidden" name="group_name" value="${group_name}"/> + <span> + <input name="removebtn2" type="submit" class="removebtn" id="removebtn" value=""/> + </span> + </form> + </span> +</div> diff --git a/funcweb/funcweb/templates/master.html b/funcweb/funcweb/templates/master.html index 0b5bcae..dc0e962 100644 --- a/funcweb/funcweb/templates/master.html +++ b/funcweb/funcweb/templates/master.html @@ -17,6 +17,9 @@ <style type="text/css" media="screen"> @import url("/funcweb/static/css/style.css"); </style> + <style type="text/css" media="screen"> + @import url("/funcweb/static/css/groupscss.css"); + </style> <link media="screen" href="/funcweb/static/css/expanding_form.css" type="text/css" rel="stylesheet"/> <script src="${tg.url('/funcweb/static/javascript/expanding_form.js')}" type="text/javascript"/> @@ -35,7 +38,14 @@ <div class="underheader" id="underheader"></div> <div id="menudiv"> <div class="navgation" id="navigaton"> - <span class="lines">|</span><a href="/funcweb/" class="navlinks">Home</a><span class="lines">|</span><a href="/funcweb/display_async_results" class="navlinks">Async Results</a><span class="lines">|</span> + <span class="lines">|</span> + <a href="/funcweb/" class="navlinks">Home</a> + <span class="lines">|</span> + <a href="/funcweb/display_async_results" class="navlinks">Async Results</a> + <span class="lines">|</span> + <a href="/funcweb/groups_main" class="navlinks">Group Management</a> + <span class="lines">|</span> + </div> </div> diff --git a/funcweb/funcweb/templates/minion_small.html b/funcweb/funcweb/templates/minion_small.html new file mode 100644 index 0000000..b180576 --- /dev/null +++ b/funcweb/funcweb/templates/minion_small.html @@ -0,0 +1,28 @@ +<div class="minions2" id="minions2" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> + + <div align="center">Minions</div> + <form action="/funcweb/add_minions_togroup" method="post" onsubmit="return !glob_submit(this,'group_small');" name="minion_merge"> + <div class="minions2box" id="minions2box"> + <span py:for="minion in all_minions"> + <div class="minionstextbox" id="minionstextbox"><span class="minionsandgroupsbluetext">${minion}</span> + <label> + <input type="checkbox" class = "checkminion" name="checkminion" id="checkminion" value="${minion}"/> + </label> + </div> + </span> + </div> + <div class="graytexts2" id="selectallbox"> Select all: + <label> + <input type="checkbox" name="groupcheckbox2" id="groupcheckbox2" /> + </label> + + <input type="hidden" name="group_name" value="${group_name}"/> + <input type="hidden" name="action_name" value="add"/> + <label> + <input name="addbtn" type="submit" class="addnewgroupbtn" id="addbtn" value="Add" /> + </label> + </div> + </form> +</div> |