Author: justi9
Date: 2009-09-21 17:44:47 -0400 (Mon, 21 Sep 2009)
New Revision: 3637
Modified:
mgmt/trunk/cumin/python/cumin/account/widgets.py
mgmt/trunk/cumin/python/cumin/account/widgets.strings
mgmt/trunk/cumin/python/cumin/main.py
mgmt/trunk/cumin/python/cumin/usergrid/main.py
mgmt/trunk/cumin/python/cumin/widgets.py
mgmt/trunk/cumin/python/cumin/widgets.strings
mgmt/trunk/wooly/python/wooly/parameters.py
mgmt/trunk/wooly/python/wooly/widgets.py
mgmt/trunk/wooly/python/wooly/widgets.strings
Log:
New global page navigation
Modified: mgmt/trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/widgets.py 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/cumin/python/cumin/account/widgets.py 2009-09-21 21:44:47 UTC (rev 3637)
@@ -26,88 +26,33 @@
self.set_default_frame(self.account)
def render_title(self, session):
- return "MRG Account"
+ return "Your Account"
class AccountMainView(CuminMainView):
def __init__(self, app, name):
super(AccountMainView, self).__init__(app, name)
- self.main = AccountFrame(app, "main")
- self.add_tab(self.main)
+ self.settings = SettingsFrame(app, "main")
+ self.add_tab(self.settings)
- def render_admin_href(self, session):
- return Session(self.app.main_page).marshal()
-
-class AccountFrame(CuminFrame):
+class SettingsFrame(CuminFrame):
def __init__(self, app, name):
- super(AccountFrame, self).__init__(app, name)
+ super(SettingsFrame, self).__init__(app, name)
- self.view = AccountView(app, "view")
+ self.view = SettingsView(app, "view")
self.add_mode(self.view)
def render_title(self, session):
- return "Account"
+ return "Settings"
-class AccountView(Widget):
- def __init__(self, app, name):
- super(AccountView, self).__init__(app, name)
+class SettingsView(Widget):
+ def init(self):
+ # XXX deferring this, but I don't like it
+ task = main.module.change_password
+ link = TaskLink(self.app, "change_password", task, None)
+ link.html_class = "action"
+ self.add_child(link)
- self.add_child(self.Heading(app, "heading"))
-
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
-
- self.__tabs.add_tab(self.AccountTab(app, "acct"))
- #self.__tabs.add_tab(UserGridJobs(app, "jobs", None))
-
- class AccountTab(ActionSet):
- def __init__(self, app, name):
- super(AccountView.AccountTab, self).__init__(app, name)
-
- def init(self):
- # XXX deferring this, but I don't like it
- task = main.module.change_password
- link = TaskLink(self.app, "change_password", task, None)
- self.add_child(link)
-
- super(AccountView.AccountTab, self).init()
-
- def render_title(self, session):
- return "Account Settings"
-
- class Heading(CuminHeading):
- def render_title(self, session):
- return "Account"
-
- def render_icon_href(self, session):
- return "resource?name=pool-36.png"
-
-from cumin.grid.job import JobTab
-
-class UserGridJobs(JobTab):
- def render_title(self, session):
- return "Your Grid Jobs %s" % fmt_count(self.get_item_count(session))
-
- def render_sql_where(self, session):
- if hasattr(session, "user_session"):
- user = session.user_session.subject.name
- else:
- user = ""
- elems = list()
- elems.append("b.name like '%s%s'" % (user, "%"))
- elems.append(self.get_phase_sql(session))
- return "where %s" % " and ".join(elems)
-
- def get_sql_values(self, session):
- pass
-
- def get_visible_columns(self, session):
- return self.get_request_visible_columns(session, ["custom_group",
"scheduler"])
-
- def render_user(self, session, *args):
- if hasattr(session, "user_session"):
- return session.user_session.subject.name
-
class LoginPage(HtmlPage):
def __init__(self, app, name):
super(LoginPage, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/account/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/widgets.strings 2009-09-15 21:39:08 UTC (rev
3636)
+++ mgmt/trunk/cumin/python/cumin/account/widgets.strings 2009-09-21 21:44:47 UTC (rev
3637)
@@ -75,55 +75,3 @@
[LoginForm.login_invalid]
<p class="login_invalid">The user name and password you entered do not
match any account.</p>
-
-[AccountMainView.html]
-<div id="head">
- <div id="user">
- Hi, {user_name}
- <strong>·</strong>
- <a id="account" onclick="wooly.clearUpdates()"
href="{admin_href}">MRG Management</a>
- <strong>·</strong>
- <a id="logout" onclick="wooly.clearUpdates()"
href="{logout_href}">Log Out</a>
- </div>
-
- <img id="logo" src="resource?name=rhlogo-32.png"/>
-
-</div>
-<div id="body">
-
-<div id="messages" style="display: {action_display};"><p
title="close"
onclick="cumin.hideActions()">x</p>{actions}</div>
- {heartbeat}
-
-{content}</div>
-
-<div id="foot"/>
-
-[AccountTab.html]
-<ul class="actions">
- <li>{change_password}</li>
-</ul>
-
-[MyGridJobs.html]
-<form id="{id}" method="post" action="?">
-<div class="rfloat">{phase}</div>
-Jobs submitted by {user}
-
- <div class="sactions" style="clear:right;">
- <h2>Act on Selected Jobs:</h2>
- {hold} {release} {remove}
- </div>
-
- <table class="mobjects">
- <thead>
- <tr>
- <th class="setnav" colspan="{column_count}">
- <div class="rfloat">{page}</div>
- {count}
- </th>
- </tr>
- <tr>{headers}</tr>
- </thead>
- <tbody>{items}</tbody>
- </table>
- <div>{hidden_inputs}</div>
-</form>
Modified: mgmt/trunk/cumin/python/cumin/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/main.py 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/cumin/python/cumin/main.py 2009-09-21 21:44:47 UTC (rev 3637)
@@ -121,7 +121,7 @@
self.set_default_frame(self.main)
def render_title(self, session):
- return "MRG Management"
+ return "MRG Administration"
class MainView(CuminMainView):
def __init__(self, app, name):
Modified: mgmt/trunk/cumin/python/cumin/usergrid/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/usergrid/main.py 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/cumin/python/cumin/usergrid/main.py 2009-09-21 21:44:47 UTC (rev 3637)
@@ -25,7 +25,7 @@
self.set_default_frame(self.main)
def render_title(self, session):
- return "MRG Grid"
+ return "User Grid"
class MainView(CuminMainView):
def __init__(self, app, name):
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2009-09-21 21:44:47 UTC (rev 3637)
@@ -35,6 +35,9 @@
self.heartbeat = CuminHeartBeat(app, "heartbeat")
self.add_child(self.heartbeat)
+ self.links = CuminPageLinks(app, "links")
+ self.add_child(self.links)
+
def do_process(self, session, *args):
self.tasks.process(session)
self.heartbeat.process(session)
@@ -63,9 +66,29 @@
return lsess.marshal()
- def render_account_href(self, session):
- return Session(self.app.account_page).marshal()
+class CuminPageLinks(ItemSet):
+ def __init__(self, app, name):
+ super(CuminPageLinks, self).__init__(app, name)
+ self.html_class = CuminPageLinks.__name__
+
+ def do_get_items(self, session):
+ return (self.app.main_page,
+ self.app.user_grid_page,
+ self.app.account_page)
+
+ def render_item_content(self, session, page):
+ href = Session(page).marshal()
+ title = page.render_title(session)
+
+ return fmt_link(href, title)
+
+ def render_item_class(self, session, page):
+ if page is session.page:
+ return "selected"
+ else:
+ return "_"
+
class CuminFrame(Frame, ModeSet):
def __init__(self, app, name):
super(CuminFrame, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings 2009-09-21 21:44:47 UTC (rev 3637)
@@ -1,21 +1,12 @@
[CuminMainView.css]
#head {
padding: 0;
- margin: 0;
- min-height: 2.75em;
background: #f9f9ff url("resource?name=shade.png") repeat-x scroll bottom
center;
}
-#logo {
- float: left;
- margin: 0.25em 1em;
-}
-
#tabs {
- padding: 0 0 0 2em;
+ padding: 0;
margin: 0;
- position: relative;
- top: 1.175em;
}
#tabs li {
@@ -31,7 +22,7 @@
-webkit-border-radius: 0.35em 0.35em 0 0;
color: #333;
background-color: #f7f7f7;
- line-height: 1.6em;
+ line-height: 1.625em;
}
#tabs li:first-child a {
@@ -44,12 +35,32 @@
z-index: 2;
}
+#logo {
+ float: left;
+ margin: 0.6em 1em;
+}
+
+#local {
+ padding: 0.15em 0 0 0;
+ margin: 0;
+}
+
+#global {
+ padding: 0.35em 1em;
+ margin: 0;
+ font-size: 0.9em;
+}
+
#user {
- padding: 0.25em 0.5em;
- float: right;
+ padding: 0.35em 1em;
+ margin: 0;
font-size: 0.9em;
}
+#user {
+ float: right;
+}
+
#actions {
padding: 0.25em 0.5em;
float: right;
@@ -122,12 +133,76 @@
};
cumin.expireIntervalUpdate();
+[CuminMainView.html]
+<div id="head">
+ <img id="logo" src="resource?name=mrg-logo-32.png"/>
+
+ <div id="user">
+ Hi, {user_name}
+ <span class="separator">|</span>
+ <a id="logout" onclick="wooly.clearUpdates()"
href="{logout_href}">Log out</a>
+ </div>
+
+ <div id="global">
+ {links}
+ </div>
+
+ <div id="local">
+ <ul id="tabs">{tabs}</ul>
+ </div>
+</div>
+
+<div id="body">
+ {tasks}
+
+ <div id="messages" style="display: {action_display};"><p
title="close"
onclick="cumin.hideActions()">x</p>{actions}</div>
+
+ {heartbeat}
+
+ {content}
+</div>
+
+<div id="foot"/>
+
+[CuminPageLinks.css]
+ul.CuminPageLinks {
+ padding: 0;
+ margin: 0;
+}
+
+ul.CuminPageLinks li {
+ display: inline;
+}
+
+ul.CuminPageLinks li {
+ display: inline;
+}
+
+ul.CuminPageLinks li:after {
+ content: " | ";
+}
+
+ul.CuminPageLinks li:after,
+span.separator {
+ color: #ccc;
+}
+
+ul.CuminPageLinks li:last-child:after {
+ content: ""
+}
+
+ul.CuminPageLinks li.selected,
+ul.CuminPageLinks li.selected a {
+ color: black;
+}
+
[CuminHeartBeat.css]
#updateStatus {
float:right;
padding: 0.25em;
font-size: 0.8em;
}
+
#updateStatus button {
display: none;
margin-left:0.5em;
@@ -143,33 +218,6 @@
<button id="shock">Resume Updates</button>
</div>
-[CuminMainView.html]
-<div id="head">
- <div id="user">
- Hi, {user_name}
- <strong>·</strong>
- <a id="account" onclick="wooly.clearUpdates()"
href="{account_href}">Your Account</a>
- <strong>·</strong>
- <a id="logout" onclick="wooly.clearUpdates()"
href="{logout_href}">Log Out</a>
- </div>
-
- <img id="logo" src="resource?name=mrg-logo-32.png"/>
-
- <ul id="tabs">{tabs}</ul>
-</div>
-
-<div id="body">
- {tasks}
-
- <div id="messages" style="display: {action_display};"><p
title="close"
onclick="cumin.hideActions()">x</p>{actions}</div>
-
- {heartbeat}
-
- {content}
-</div>
-
-<div id="foot"/>
-
[CuminView.css]
ul.context {
list-style: none;
Modified: mgmt/trunk/wooly/python/wooly/parameters.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/parameters.py 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/wooly/python/wooly/parameters.py 2009-09-21 21:44:47 UTC (rev 3637)
@@ -81,8 +81,8 @@
return string
class BooleanParameter(Parameter):
- def __init__(self, model, name):
- Parameter.__init__(self, model, name)
+ def __init__(self, app, name):
+ Parameter.__init__(self, app, name)
self.default = False
@@ -103,3 +103,13 @@
session.set(key, None)
else:
session.unset(key)
+
+class PageParameter(Parameter):
+ def __init__(self, app, name):
+ super(PageParameter, self).__init__(app, name)
+
+ def do_unmarshal(self, string):
+ return self.app.pages_by_name.get(string)
+
+ def do_marshal(self, page):
+ return page.name
Modified: mgmt/trunk/wooly/python/wooly/widgets.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/widgets.py 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/wooly/python/wooly/widgets.py 2009-09-21 21:44:47 UTC (rev 3637)
@@ -208,6 +208,23 @@
return None
+class SelectionItemSet(ItemSet):
+ def __init__(self, app, name, selection):
+ super(SelectionItemSet, self).__init__(app, name)
+
+ self.selection = selection
+
+ def init(self):
+ super(SelectionItemSet, self).init()
+
+ assert isinstance(self.selection, Parameter)
+
+ def render_item_class(self, session, item):
+ if self.selection.get(session) is item:
+ return "selected"
+ else:
+ return "_"
+
class RenderingItemSet(Widget):
def __init__(self, app, name, item_renderer):
super(RenderingItemSet, self).__init__(app, name)
Modified: mgmt/trunk/wooly/python/wooly/widgets.strings
===================================================================
--- mgmt/trunk/wooly/python/wooly/widgets.strings 2009-09-15 21:39:08 UTC (rev 3636)
+++ mgmt/trunk/wooly/python/wooly/widgets.strings 2009-09-21 21:44:47 UTC (rev 3637)
@@ -77,11 +77,16 @@
[Toggle.html]
<a href="{href}" class="Toggle {state}">{content}</a>
+[ItemSet.css]
+ul.ItemSet li.selected {
+ color: black;
+}
+
[ItemSet.html]
<ul id="{id}" class="{class}">{items}</ul>
[ItemSet.item_html]
-<li>{item_content}</li>
+<li class="{item_class}">{item_content}</li>
[ItemTree.html]
<ul class="ItemTree">{items}</ul>