Author: eallen
Date: 2008-10-17 22:20:09 -0400 (Fri, 17 Oct 2008)
New Revision: 2657
Modified:
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/job.strings
Log:
Changes for the latest SqlTable find_item method.
Display error message when job is not found.
Revert to default prompt after search field is exited.
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-10-18 02:18:27 UTC (rev 2656)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-10-18 02:20:09 UTC (rev 2657)
@@ -207,19 +207,31 @@
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)
+ search_term = self.job_search.get(session)
+ if search_term:
object = self.frame.get_object(session)
- data = self.find_item(session, "custom_id", search, object)
- if data:
- job = Identifiable(data["id"])
- branch = session.branch()
- self.frame.show_job(branch, job).show_view(branch)
- self.page.set_redirect_url(session, branch.marshal())
+ rows = self.find_item(session, object)
+ if rows:
+ try:
+ first = rows[0]
+ job = Identifiable(first["id"])
+ branch = session.branch()
+ self.frame.show_job(branch, job).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
+ except:
+ self.job_search.set_not_found(session, search_term)
+ else:
+ self.job_search.set_not_found(session, search_term)
+ self.job_search.set(session, None)
+
+ def render_find_sql_where(self, session, *args):
+ return "j.custom_id = %(custom_id)s"
+
+ def get_find_sql_values(self, session, *args):
+ return {"custom_id": self.job_search.get(session)}
+
def get_visible_columns(self, session):
return self.get_request_visible_columns(session, ["custom_group",
"scheduler", "submitter"])
@@ -242,7 +254,23 @@
self.__go = self.JobSearchButton(app, "go")
self.add_child(self.__go)
+
+ self.not_found = Attribute(app, "error")
+ self.add_attribute(self.not_found)
+ def set_not_found(self, session, value):
+ self.not_found.set(session, value)
+
+ def render_search_prompt(self, session):
+ not_found = self.not_found.get(session)
+ return not_found and "%s Not Found" % not_found or
self.render_search_default_prompt(session)
+
+ def render_search_default_prompt(self, session):
+ return "Enter Job ID"
+
+ def render_search_class(self, session):
+ return self.not_found.get(session) and "search_error" or "
"
+
def find_job(self, session):
self.parent.find_job(session)
Modified: mgmt/trunk/cumin/python/cumin/job.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.strings 2008-10-18 02:18:27 UTC (rev 2656)
+++ mgmt/trunk/cumin/python/cumin/job.strings 2008-10-18 02:20:09 UTC (rev 2657)
@@ -24,6 +24,14 @@
{sql_orderby}
{sql_limit}
+[JobSet.find_sql]
+select
+ j.id,
+ j.custom_id
+from job as j
+left outer join job_stats as c on c.id = j.stats_curr_id
+left outer join job_stats as p on p.id = j.stats_prev_id
+
[JobSet.count_sql]
select count(1)
from job as j
@@ -35,36 +43,41 @@
[JobTab.css]
input.search_input {
- color: #444;
+ color: #555;
border: 1px solid #333;
font-size: 0.9em;
font-weight: normal;
padding-left: 0.25em;
}
+input.search_error {
+ color: #CC0000 !important;
+}
div.searchbox {
padding-top: 2px;
}
+
[JobTab.javascript]
function JobSearchFocus() {
var val = this.value;
- if (val == this.default_value) {
+ if (val == job_search_prompt) {
this.value = "";
this.style.color = "#000";
+ this.className = "search_input"; // remove search_error class
}
}
function JobSearchBlur() {
var val = this.value;
if (val == "") {
- this.style.color = "#444";
- this.value = this.default_value;
+ this.style.color = "#555";
+ job_search_prompt = job_search_default_prompt;
+ this.value = job_search_prompt;
}
}
function attachJobSearch() {
var oInput = document.getElementById("job_search");
if (oInput) {
- oInput.default_value = "Enter Job ID";
oInput.onfocus = JobSearchFocus;
oInput.onblur = JobSearchBlur;
}
@@ -97,11 +110,14 @@
[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" />
+ <h2><label for="job_search">Go To Job:</label></h2>
+ <input class="search_input {search_class}" type="text"
name="{name}" id="job_search" value="{search_prompt}" />
{go}
</div>
-
+ <script type="text/javascript">
+ var job_search_default_prompt = "{search_default_prompt}"
+ var job_search_prompt = "{search_prompt}"
+ </script>
[JobGroupSet.sql]
select distinct
j.custom_group as id,
Show replies by date