Author: eallen
Date: 2008-10-17 15:09:35 -0400 (Fri, 17 Oct 2008)
New Revision: 2650
Modified:
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/job.strings
mgmt/trunk/cumin/python/cumin/limits.strings
mgmt/trunk/cumin/python/cumin/scheduler.strings
mgmt/trunk/cumin/python/cumin/submitter.strings
Log:
1st crack at job search
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-10-17 17:51:24 UTC (rev 2649)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-10-17 19:09:35 UTC (rev 2650)
@@ -167,7 +167,7 @@
name = fmt_shorten(data["submitter"])
return fmt_olink(branch, submitter, name=name)
else:
- return data["scheduler"]
+ return data["submitter"]
class SchedulerColumn(SqlTableColumn):
def render_title(self, session, data):
@@ -204,6 +204,36 @@
self.__release = JobReleaseButton(app, "release")
self.add_child(self.__release)
+ self.job_search = self.JobSearch(app, "job_search")
+ self.add_child(self.job_search)
+
+
+ def find_job(self, session):
+ search = self.job_search.get(session)
+ if search:
+ self.job_search.set(session, None)
+ job = self.safe_sql_find_job(session, search)
+ if job:
+ branch = session.branch()
+ self.frame.show_job(branch, job).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def safe_sql_find_job(self, session, search):
+ #job = Job.select("custom_id = '%s'" % search)[0]
+ try:
+ conn = self.get_connection(session)
+ if conn:
+ cursor = conn.cursor()
+ sql = "select id from job where custom_id = %(search_term)s"
+ sql_values = {"search_term": search}
+
+ cursor.execute(sql, sql_values)
+ data = cursor.fetchone()
+ return Identifiable(data[0])
+ except:
+ pass
+
+
def get_visible_columns(self, session):
return self.get_request_visible_columns(session, ["custom_group",
"scheduler", "submitter"])
@@ -217,7 +247,26 @@
if phase == "All":
phase = ""
return "%i %s %s" % (count, phase, count == 1 and "Job" or
"Jobs")
+
+ class JobSearch(StringInput):
+ """ displays the input box and button used to search for job id
"""
+
+ def __init__(self, app, name):
+ super(JobTab.JobSearch, self).__init__(app, name)
+
+ self.__go = self.JobSearchButton(app, "go")
+ self.add_child(self.__go)
+
+ def find_job(self, session):
+ self.parent.find_job(session)
+ class JobSearchButton(FormButton):
+ def process_submit(self, session):
+ self.parent.find_job(session)
+
+ def render_content(self, session):
+ return "Go"
+
class JobSetFrame(object):
""" Intermediate class to consolidate the show_xxx methods associated
with a jobset
Modified: mgmt/trunk/cumin/python/cumin/job.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.strings 2008-10-17 17:51:24 UTC (rev 2649)
+++ mgmt/trunk/cumin/python/cumin/job.strings 2008-10-17 19:09:35 UTC (rev 2650)
@@ -33,10 +33,49 @@
inner join submitter as b on b.id = j.submitter_id
{sql_where}
+[JobTab.css]
+input.search_input {
+ color: #444;
+ border: 1px solid #333;
+ font-size: 0.9em;
+ font-weight: normal;
+ padding-left: 0.25em;
+}
+div.searchbox {
+ padding-top: 2px;
+}
+
+[JobTab.javascript]
+function JobSearchFocus() {
+ var val = this.value;
+ if (val == this.default_value) {
+ this.value = "";
+ this.style.color = "#000";
+ }
+}
+function JobSearchBlur() {
+ var val = this.value;
+ if (val == "") {
+ this.style.color = "#444";
+ this.value = this.default_value;
+ }
+}
+
+function attachJobSearch() {
+ var oInput = document.getElementById("job_search");
+ if (oInput) {
+ oInput.default_value = "Enter Job ID";
+ oInput.onfocus = JobSearchFocus;
+ oInput.onblur = JobSearchBlur;
+ }
+}
+addEvent(window, "load", attachJobSearch);
+
[JobTab.html]
<form id="{id}" method="post" action="?">
<div class="sactions">
+ {job_search}
<h2>Act on Selected Jobs:</h2>
{hold} {release} {remove}
</div>
@@ -56,6 +95,13 @@
<div>{hidden_inputs}</div>
</form>
+[JobSearch.html]
+ <div class="rfloat searchbox">
+ <h2><label for="job_search">Search for a
Job:</label></h2>
+ <input class="search_input" type="text"
name="{name}" id="job_search" value="Enter Job ID" />
+ {go}
+ </div>
+
[JobGroupSet.sql]
select distinct
j.custom_group as id,
@@ -114,6 +160,7 @@
<form id="{id}" style="clear:right;" method="post"
action="?">
<div class="sactions">
+ {job_search}
<h2>Act on Selected Jobs:</h2>
{hold} {release} {remove}
</div>
Modified: mgmt/trunk/cumin/python/cumin/limits.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.strings 2008-10-17 17:51:24 UTC (rev 2649)
+++ mgmt/trunk/cumin/python/cumin/limits.strings 2008-10-17 19:09:35 UTC (rev 2650)
@@ -80,6 +80,7 @@
<form id="{id}" style="clear:right;" method="post"
action="?">
<div class="sactions">
+ {job_search}
<h2>Act on Selected Jobs:</h2>
{hold} {release} {remove}
</div>
Modified: mgmt/trunk/cumin/python/cumin/scheduler.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/scheduler.strings 2008-10-17 17:51:24 UTC (rev 2649)
+++ mgmt/trunk/cumin/python/cumin/scheduler.strings 2008-10-17 19:09:35 UTC (rev 2650)
@@ -68,6 +68,7 @@
<form id="{id}" style="clear:right;" method="post"
action="?">
<div class="sactions">
+ {job_search}
<h2>Act on Selected Jobs:</h2>
{hold} {release} {remove}
</div>
Modified: mgmt/trunk/cumin/python/cumin/submitter.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/submitter.strings 2008-10-17 17:51:24 UTC (rev 2649)
+++ mgmt/trunk/cumin/python/cumin/submitter.strings 2008-10-17 19:09:35 UTC (rev 2650)
@@ -44,6 +44,7 @@
<form id="{id}" style="clear:right;" method="post"
action="?">
<div class="sactions">
+ {job_search}
<h2>Act on Selected Jobs:</h2>
{hold} {release} {remove}
</div>