MoMA.master: Remove the login header link, add a 'login' page to the non-logged-in state and a 'my account' page to the logged-in state.

MoMA.css: Remove the login header style as it's no longer needed.  Add style for detailsview controls.

MyAccount.aspx, MyAccount.aspx.cs:  New page showing submissions from the current user, and giving password change and logout options.

Password.aspx, Password.aspx.cs:  Split out from the Login page.

Login.aspx, Login.aspx.cs: Split out password changing.  Override the ReturnURL for the Verify page only.

svn path=/trunk/moma-tool/; revision=121586
This commit is contained in:
Dick Porter 2008-12-16 11:47:21 +00:00
Родитель 5cdbe1fa31
Коммит ba8b42634d
8 изменённых файлов: 306 добавлений и 15 удалений

Просмотреть файл

@ -20,8 +20,7 @@
</div> </div>
</AnonymousTemplate> </AnonymousTemplate>
<LoggedInTemplate> <LoggedInTemplate>
<asp:ChangePassword ID="ChangePassword1" runat="server"> You are already logged in!
</asp:ChangePassword>
</LoggedInTemplate> </LoggedInTemplate>
</asp:LoginView> </asp:LoginView>
</asp:Content> </asp:Content>

Просмотреть файл

@ -43,9 +43,12 @@ public partial class Login : System.Web.UI.Page
} }
protected void Login1_LoggedIn(object sender, EventArgs e) protected void Login1_LoggedIn(object sender, EventArgs e)
{ {
/* Override the ReturnURL. When I figure out how to disable it /* Override the ReturnURL for specific pages like Verify.
* for specific pages like Verify, it can be restored for the others.
*/ */
Response.Redirect("~/Overview.aspx"); string return_url = Request.QueryString["ReturnUrl"];
if (return_url == null || return_url.Contains("Verify.aspx"))
{
Response.Redirect("~/Overview.aspx");
}
} }
} }

Просмотреть файл

@ -2,12 +2,6 @@
{ {
} }
#header .login
{
float: right;
color: #a1bfe2;
}
.content .content
{ {
/* Make this the context box for the main body content */ /* Make this the context box for the main body content */
@ -70,3 +64,28 @@
{ {
background-color: #e5e5e5; background-color: #e5e5e5;
} }
.dv_field_header
{
background-color: #e5e5e5;
height: 23px;
}
.dv_field_header th
{
border: 1px solid #bbbbbb;
padding-left: 5px;
text-align: left;
white-space: nowrap;
}
.dv_field_header a
{
color: Black;
display: block; /* allow click anywhere in the header, not just the link text */
}
.dv_row_alternating
{
background-color: #f9f9f9;
}

Просмотреть файл

@ -35,22 +35,22 @@
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableScriptLocalization="True" /> <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableScriptLocalization="True" />
<div id="header"> <div id="header">
<h1>MoMA Studio</h1> <h1>MoMA Studio</h1>
<div class="login">
<asp:LoginName ID="LoginName1" runat="server" />
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</div>
<asp:LoginView ID="LoginView1" runat="server"> <asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate> <AnonymousTemplate>
<ul> <ul>
<li id="menu-overview"><a href="Overview.aspx">Overview</a></li> <li id="menu-overview"><a href="Overview.aspx">Overview</a></li>
<!--<li id="menu-issueview"><a href="IssueView.aspx">Issue</a></li>-->
<li id="menu-login"><a href="Login.aspx">Login</a></li>
</ul> </ul>
</AnonymousTemplate> </AnonymousTemplate>
<LoggedInTemplate> <LoggedInTemplate>
<ul> <ul>
<li id="menu-overview"><a href="Overview.aspx">Overview</a></li> <li id="menu-overview"><a href="Overview.aspx">Overview</a></li>
<!--<li id="menu-issueview"><a href="IssueView.aspx">Issue</a></li>-->
<li id="menu-reportview"><a href="ReportView.aspx">Individual Report</a></li> <li id="menu-reportview"><a href="ReportView.aspx">Individual Report</a></li>
<li id="menu-apireport"><a href="APIReport.aspx">API Report</a></li> <li id="menu-apireport"><a href="APIReport.aspx">API Report</a></li>
<li id="menu-submissions"><a href="Submissions.aspx">Submissions Report</a></li> <li id="menu-submissions"><a href="Submissions.aspx">Submissions Report</a></li>
<li id="menu-myaccount"><a href="MyAccount.aspx">My Account</a></li>
</ul> </ul>
</LoggedInTemplate> </LoggedInTemplate>
</asp:LoginView> </asp:LoginView>

103
web_service/MyAccount.aspx Normal file
Просмотреть файл

@ -0,0 +1,103 @@
<%@ Page Language="C#" MasterPageFile="~/MoMA.master" AutoEventWireup="true" CodeFile="MyAccount.aspx.cs" Inherits="MyAccount" Title="MoMA Studio - My Account" %>
<asp:Content ID="ContentHeaderContent" ContentPlaceHolderID="ContentHeaderPlaceholder" Runat="Server">
View account details
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyContentPlaceHolder" Runat="Server">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
This view is only available to logged-in users.
</AnonymousTemplate>
<LoggedInTemplate>
<asp:SqlDataSource ID="MyReportsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MomaDB %>"
ProviderName="<%$ ConnectionStrings:MomaDB.ProviderName %>" SelectCommand="SELECT rep.id, rep.report_date, meta.importance, meta.application_name, rep.reporter_name, rep.reporter_email, rep.reporter_homepage, def.display_name, rep.application_type, rep.miss, rep.niex, rep.pinv, rep.todo, rep.total, curmiss.miss AS curmiss, curniex.niex AS curniex, curtodo.todo AS curtodo, curtotal.total AS curtotal FROM report_metadata meta, moma_definition def, report rep LEFT JOIN (SELECT issue_report.report_id, COUNT(issue_report.report_id) AS miss FROM issue_report, issue, issue_type WHERE issue.issue_type_id = issue_type.id AND issue_type.lookup_name = 'MISS' AND issue_report.issue_id = issue.id AND issue.is_latest_definition = true GROUP BY report_id) AS curmiss ON rep.id = curmiss.report_id LEFT JOIN (SELECT issue_report.report_id, COUNT(issue_report.report_id) AS niex FROM issue_report, issue, issue_type WHERE issue.issue_type_id = issue_type.id AND issue_type.lookup_name = 'NIEX' AND issue_report.issue_id = issue.id AND issue.is_latest_definition = true GROUP BY report_id) AS curniex ON rep.id = curniex.report_id LEFT JOIN (SELECT issue_report.report_id, COUNT(issue_report.report_id) AS todo FROM issue_report, issue, issue_type WHERE issue.issue_type_id = issue_type.id AND issue_type.lookup_name = 'TODO' AND issue_report.issue_id = issue.id AND issue.is_latest_definition = true GROUP BY report_id) AS curtodo ON rep.id = curtodo.report_id LEFT JOIN (SELECT issue_report.report_id, COUNT(issue_report.report_id) AS total FROM issue_report, issue WHERE issue_report.issue_id = issue.id AND issue.is_latest_definition = true GROUP BY report_id) AS curtotal ON rep.id = curtotal.report_id WHERE meta.report_id = rep.id AND rep.moma_definition_id = def.id AND rep.reporter_email = @email;">
<SelectParameters>
<asp:Parameter DefaultValue="" Name="email" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<div id="sidebar">
<asp:Label runat="server" Text="<h3>Logged in as:"></asp:Label>
<asp:LoginName ID="LoginName1" runat="server" />
<asp:Label runat="server" Text="</h3>"></asp:Label>
<br />
<asp:Label runat="server" Text="<h3>User Options:</h3>"></asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Password.aspx">Change Password</asp:HyperLink>
<br />
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="~/Overview.aspx" LogoutAction="Redirect" />
</div>
<asp:Label runat="server" Text="<h3>Submitted Reports:</h3>"></asp:Label>
<asp:GridView ID="MyReportsGridView" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" OnRowDataBound="ReportsGridView_RowDataBound"
PageSize="10" onprerender="MyReportsGridView_PreRender">
<AlternatingRowStyle CssClass="gv_col_alternating" />
<HeaderStyle CssClass="gv_header" />
<PagerStyle CssClass="gv_pager" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="~/ReportView.aspx?ReportID={0}"
HeaderText="ID" Text=">>" SortExpression="id" />
<asp:TemplateField HeaderText="Date" SortExpression="report_date">
<ItemTemplate>
<%-- Shorten the date, otherwise it's too wide --%>
<asp:Label ID="Label1" runat="server" Text='<%# ((DateTime)Eval("report_date")).ToShortDateString () %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%-- The &nbsp; header text means it can still be clicked on for sorting --%>
<asp:BoundField DataField="application_name" HeaderText="App Name" SortExpression="application_name" />
<asp:BoundField DataField="application_type" HeaderText="App Type" SortExpression="application_type" />
<asp:BoundField DataField="display_name" HeaderText="Profile" SortExpression="display_name" />
<%-- %><asp:BoundField DataField="curmiss" HeaderText="Current MISS" SortExpression="curmiss" />
<asp:BoundField DataField="curniex" HeaderText="Current NIEX" SortExpression="curniex" />
<asp:BoundField DataField="curtodo" HeaderText="Current TODO" SortExpression="curtodo" />
<asp:BoundField DataField="curtotal" HeaderText="Current Total" SortExpression="curtotal" />--%>
<asp:TemplateField HeaderText="MISS" SortExpression="miss">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# FormatIssueCount (Eval("curmiss").ToString()) + " (" + Eval("miss") + ")" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NIEX" SortExpression="niex">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# FormatIssueCount (Eval("curniex").ToString()) + " (" + Eval("niex") + ")" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PINV" SortExpression="pinv">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# "(" + Eval("pinv") + ")" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TODO" SortExpression="todo">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# FormatIssueCount (Eval("curtodo").ToString()) + " (" + Eval("todo") + ")" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total" SortExpression="total">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# FormatIssueCount (Eval("curtotal").ToString()) + " (" + Eval("total") + ")" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerTemplate>
<asp:Label ID="PagerRowsLabel" runat="server" Text="Show rows:" />
<asp:DropDownList ID="PagerPageSizeDropDownList" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="PagerPageSizeDropDownList_SelectedIndexChanged">
<asp:ListItem Value="10"></asp:ListItem>
<asp:ListItem Value="20"></asp:ListItem>
<asp:ListItem Value="30"></asp:ListItem>
</asp:DropDownList>
Page
<asp:TextBox ID="PagerGotoTextBox" runat="server" AutoPostBack="true" OnTextChanged="PagerGotoTextBox_TextChanged"
MaxLength="5" Columns="5"></asp:TextBox>
of
<asp:Label ID="PagerCountLabel" runat="server"></asp:Label>
<asp:Button ID="Novell_PagerPrevButton" runat="server" CommandName="Page" CommandArgument="Prev"
Text="Prev" />
<asp:Button ID="Novell_PagerNextButton" runat="server" CommandName="Page" CommandArgument="Next"
Text="Next" />
</PagerTemplate>
<EmptyDataTemplate>
No rows to show
</EmptyDataTemplate>
</asp:GridView>
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>

Просмотреть файл

@ -0,0 +1,130 @@
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class MyAccount : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Npgsql.NpgsqlEventLog.Level = Npgsql.LogLevel.Debug;
//Npgsql.NpgsqlEventLog.LogName = "c:\\cygwin\\tmp\\npgsql-debug-log";
// Content only available to logged-in users
if (Page.User.Identity.IsAuthenticated)
{
SqlDataSource ds = (SqlDataSource)LoginView1.FindControl("MyReportsSqlDataSource");
MembershipUser user = Membership.GetUser(Page.User.Identity.Name);
ds.SelectParameters["email"].DefaultValue = user.Email;
DataView reports_data = (DataView)ds.Select(DataSourceSelectArguments.Empty);
GridView reports_gv = (GridView)LoginView1.FindControl("MyReportsGridView");
reports_gv.DataSource = ds;
reports_gv.DataBind();
}
}
protected void PagerPageSizeDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
if (Page.User.Identity.IsAuthenticated)
{
GridView gv = (GridView)LoginView1.FindControl("MyReportsGridView");
gv.PageSize = int.Parse(ddl.SelectedValue);
}
}
protected void PagerGotoTextBox_TextChanged(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
if (Page.User.Identity.IsAuthenticated)
{
GridView gv = (GridView)LoginView1.FindControl("MyReportsGridView");
int pagenum;
if (int.TryParse(tb.Text.Trim(), out pagenum) &&
pagenum > 0 &&
pagenum <= gv.PageCount)
{
gv.PageIndex = pagenum - 1;
}
else
{
gv.PageIndex = 0;
}
}
}
protected void ReportsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView gv = (GridView)sender;
if (gv.SortExpression.Length > 0)
{
int cellIndex = -1;
foreach (DataControlField field in gv.Columns)
{
if (field.SortExpression == gv.SortExpression)
{
cellIndex = gv.Columns.IndexOf(field);
break;
}
}
if (cellIndex > -1)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Set alternating row style
e.Row.Cells[cellIndex].CssClass = e.Row.RowIndex % 2 == 0 ? "gv_col_sort_alternating" : "gv_col_sort";
}
}
}
if (e.Row.RowType == DataControlRowType.Pager)
{
Label pager_count_label = (Label)e.Row.FindControl("PagerCountLabel");
pager_count_label.Text = gv.PageCount.ToString();
TextBox pager_goto_textbox = (TextBox)e.Row.FindControl("PagerGotoTextBox");
pager_goto_textbox.Text = (gv.PageIndex + 1).ToString();
DropDownList pager_page_size_ddl = (DropDownList)e.Row.FindControl("PagerPageSizeDropDownList");
pager_page_size_ddl.SelectedValue = gv.PageSize.ToString();
}
}
public string FormatIssueCount(string count)
{
/* count should be either blank (representing zero) or hold an integer */
if (count == "")
{
return "0";
}
else
{
return count;
}
}
protected void MyReportsGridView_PreRender(object sender, EventArgs e)
{
GridView grid = (GridView)sender;
if (grid != null)
{
GridViewRow pagerRow = (GridViewRow)grid.BottomPagerRow;
if (pagerRow != null)
{
pagerRow.Visible = true;
}
}
}
}

17
web_service/Password.aspx Normal file
Просмотреть файл

@ -0,0 +1,17 @@
<%@ Page Language="C#" MasterPageFile="~/MoMA.master" AutoEventWireup="true" CodeFile="Password.aspx.cs" Inherits="Password" Title="MoMA Studio - Change Password" %>
<asp:Content ID="ContentHeaderContent" ContentPlaceHolderID="ContentHeaderPlaceholder" Runat="Server">
Change Password
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyContentPlaceHolder" Runat="Server">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
You must be logged in to change your password!
</AnonymousTemplate>
<LoggedInTemplate>
<asp:ChangePassword ID="ChangePassword1" runat="server" CancelDestinationPageUrl="~/MyAccount.aspx" ContinueDestinationPageUrl="~/MyAccount.aspx">
</asp:ChangePassword>
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>

Просмотреть файл

@ -0,0 +1,20 @@
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Password : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}