Skip to content
This repository was archived by the owner on Nov 10, 2017. It is now read-only.

Commit 32712f6

Browse files
committed
Updated the Log Viewer application with SXP 8.1 changes.
1 parent c78f98f commit 32712f6

5 files changed

Lines changed: 134 additions & 118 deletions

File tree

src/Sitecore.Azure.Diagnostics.UI/sitecore/Shell/Applications/Blobs/BlobLister/BlobLister.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
<CodeBeside Type="Sitecore.Azure.Diagnostics.UI.Shell.Applications.Blobs.BlobLister.BlobListerForm, Sitecore.Azure.Diagnostics.UI"/>
88

9-
<Border Background="white" Border="1px inset" Height="100%">
9+
<Border Background="white" Height="100%">
1010
<Listview ID="FileLister" DblClick="OnFileListerDblClick" View="Details">
1111
<ListviewHeader>
1212
<ListviewHeaderItem Name="name" Header="Name"/>
1313
<ListviewHeaderItem Name="size" Header="Size"/>
14-
<ListviewHeaderItem Name="modified" Header="Last Modified"/>
14+
<ListviewHeaderItem Name="modified" Header="Date modified"/>
1515
</ListviewHeader>
1616
</Listview>
1717
</Border>

src/Sitecore.Azure.Diagnostics.UI/sitecore/Shell/Applications/Blobs/BlobLister/BlobListerForm.cs

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Sitecore.Azure.Diagnostics.UI.Shell.Applications.Blobs.BlobLister
1717
/// </summary>
1818
public class BlobListerForm : DialogForm
1919
{
20-
#region Fields
20+
#region Protected fields
2121

2222
/// <summary>
2323
/// The dialog.
@@ -28,11 +28,70 @@ public class BlobListerForm : DialogForm
2828
/// The file lister.
2929
/// </summary>
3030
protected Listview FileLister;
31-
32-
#endregion
31+
32+
#endregion Protected fields
3333

3434
#region Protected methods
3535

36+
/// <summary>
37+
/// Checks the security.
38+
/// </summary>
39+
/// <exception cref="AccessDeniedException">
40+
/// Application access denied.
41+
/// </exception>
42+
protected virtual void CheckSecurity()
43+
{
44+
ShellPage.IsLoggedIn();
45+
46+
var user = Context.User;
47+
48+
if (user.IsAdministrator)
49+
{
50+
return;
51+
}
52+
53+
var isDeveloping = user.IsInRole("sitecore\\Sitecore Client Developing");
54+
var isMaintaining = user.IsInRole("sitecore\\Sitecore Client Maintaining");
55+
var isAccessDenied = !isDeveloping && !isMaintaining;
56+
57+
if (isAccessDenied)
58+
{
59+
throw new AccessDeniedException("Application access denied.");
60+
}
61+
}
62+
63+
/// <summary>
64+
/// Executes the OK event.
65+
/// </summary>
66+
protected void DoOk()
67+
{
68+
var selected = this.FileLister.SelectedItems;
69+
70+
if (selected.Length == 0)
71+
{
72+
SheerResponse.Alert(Texts.PLEASE_SELECT_A_FILE);
73+
return;
74+
}
75+
76+
if (selected.Length > 1)
77+
{
78+
SheerResponse.Alert(Texts.PLEASE_SELECT_A_SINGLE_FILE);
79+
return;
80+
}
81+
82+
var result = selected[0].ServerProperties["Blob"] as string;
83+
SheerResponse.SetDialogValue(result);
84+
SheerResponse.CloseWindow();
85+
}
86+
87+
/// <summary>
88+
/// Called when the file lister DBL has click.
89+
/// </summary>
90+
protected void OnFileListerDblClick()
91+
{
92+
this.DoOk();
93+
}
94+
3695
/// <summary>
3796
/// Raises the load event.
3897
/// </summary>
@@ -63,24 +122,28 @@ protected override void OnLoad([NotNull] EventArgs e)
63122
var urlHandle = UrlHandle.Get();
64123

65124
var icon = urlHandle["ic"];
125+
66126
if (!string.IsNullOrEmpty(icon))
67127
{
68128
this.Dialog["Icon"] = icon;
69129
}
70130

71131
var header = WebUtil.SafeEncode(urlHandle["he"]);
132+
72133
if (header.Length > 0)
73134
{
74135
this.Dialog["Header"] = header;
75136
}
76137

77138
var text = WebUtil.SafeEncode(urlHandle["txt"]);
139+
78140
if (text.Length > 0)
79141
{
80142
this.Dialog["Text"] = text;
81143
}
82144

83145
var button = WebUtil.SafeEncode(urlHandle["btn"]);
146+
84147
if (button.Length > 0)
85148
{
86149
this.Dialog["OKButton"] = button;
@@ -93,7 +156,6 @@ protected override void OnLoad([NotNull] EventArgs e)
93156
{
94157
var item = new ListviewItem();
95158
this.FileLister.Controls.Add(item);
96-
97159
item.ID = Control.GetUniqueID("I");
98160
item.Header = blob.Uri.Segments.Last();
99161
item.Icon = "Applications/16x16/document.png";
@@ -103,65 +165,6 @@ protected override void OnLoad([NotNull] EventArgs e)
103165
}
104166
}
105167

106-
/// <summary>
107-
/// Checks the security.
108-
/// </summary>
109-
/// <exception cref="AccessDeniedException">
110-
/// Application access denied.
111-
/// </exception>
112-
protected virtual void CheckSecurity()
113-
{
114-
ShellPage.IsLoggedIn();
115-
116-
var user = Context.User;
117-
118-
if (user.IsAdministrator)
119-
{
120-
return;
121-
}
122-
123-
var isDeveloping = user.IsInRole("sitecore\\Sitecore Client Developing");
124-
var isMaintaining = user.IsInRole("sitecore\\Sitecore Client Maintaining");
125-
var isAccessDenied = !isDeveloping && !isMaintaining;
126-
127-
if (isAccessDenied)
128-
{
129-
throw new AccessDeniedException("Application access denied.");
130-
}
131-
}
132-
133-
/// <summary>
134-
/// Executes the OK event.
135-
/// </summary>
136-
protected void DoOk()
137-
{
138-
var selected = this.FileLister.SelectedItems;
139-
140-
if (selected.Length == 0)
141-
{
142-
SheerResponse.Alert(Texts.PLEASE_SELECT_A_FILE);
143-
return;
144-
}
145-
146-
if (selected.Length > 1)
147-
{
148-
SheerResponse.Alert(Texts.PLEASE_SELECT_A_SINGLE_FILE);
149-
return;
150-
}
151-
152-
var result = selected[0].ServerProperties["Blob"] as string;
153-
SheerResponse.SetDialogValue(result);
154-
SheerResponse.CloseWindow();
155-
}
156-
157-
/// <summary>
158-
/// Called when the file lister DBL has click.
159-
/// </summary>
160-
protected void OnFileListerDblClick()
161-
{
162-
this.DoOk();
163-
}
164-
165168
/// <summary>
166169
/// Handles a click on the OK button.
167170
/// </summary>
@@ -182,7 +185,7 @@ protected override void OnOK([NotNull] object sender, [NotNull] EventArgs args)
182185

183186
this.DoOk();
184187
}
185-
188+
186189
#endregion Protected methods
187190
}
188191
}

src/Sitecore.Azure.Diagnostics.UI/sitecore/Shell/Applications/Reports/LogViewer/LogViewerDetailsForm.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace Sitecore.Azure.Diagnostics.UI.Shell.Applications.Reports.LogViewer
1616
/// </summary>
1717
public class LogViewerDetailsForm : BaseForm
1818
{
19+
#region Protected fields
20+
1921
/// <summary>
2022
/// The log viewer.
2123
/// </summary>
@@ -25,18 +27,22 @@ public class LogViewerDetailsForm : BaseForm
2527
/// The text panel.
2628
/// </summary>
2729
protected Border TextPanel;
28-
30+
31+
#endregion Protected fields
32+
33+
#region Protected methods
34+
2935
/// <summary>
3036
/// Raises the load event.
3137
/// </summary>
32-
/// <param name="e">The <see cref="T:System.EventArgs" /> instance containing the event data.</param>
38+
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
3339
/// <contract>
34-
/// <requires name="e" condition="not null" />
35-
/// </contract>
36-
protected override void OnLoad(EventArgs e)
40+
/// <requires name="e" condition="not null"/>
41+
/// </contract>
42+
protected override void OnLoad([NotNull] EventArgs e)
3743
{
3844
Assert.ArgumentNotNull(e, "e");
39-
Assert.CanRunApplication("/sitecore/content/Applications/Control Panel/Reports/Log Viewer");
45+
Assert.CanRunApplication("/sitecore/content/Applications/Tools/Log Viewer");
4046

4147
base.OnLoad(e);
4248

@@ -46,18 +52,18 @@ protected override void OnLoad(EventArgs e)
4652
}
4753

4854
string blobName = WebUtil.GetQueryString("blob");
55+
4956
if (string.IsNullOrEmpty(blobName))
5057
{
5158
return;
5259
}
53-
54-
this.TextPanel.Visible = false;
55-
60+
5661
var blob = LogStorageManager.GetBlob(blobName);
5762
var data = string.Empty;
5863

5964
if (blob.BlobType == BlobType.AppendBlob)
6065
{
66+
this.TextPanel.Visible = false;
6167
data = ((CloudAppendBlob)blob).DownloadText(LogStorageManager.DefaultTextEncoding);
6268
}
6369

@@ -70,5 +76,7 @@ protected override void OnLoad(EventArgs e)
7076
data = HttpUtility.HtmlEncode(data).Replace("\n", "<br/>");
7177
this.LogViewer.Controls.Add(new LiteralControl(data));
7278
}
79+
80+
#endregion
7381
}
7482
}

src/Sitecore.Azure.Diagnostics.UI/sitecore/Shell/Applications/Reports/LogViewer/LogViewerForm.cs

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,45 +41,13 @@ protected override void OnLoad([NotNull] EventArgs e)
4141

4242
base.OnLoad(e);
4343

44-
Assert.CanRunApplication("/sitecore/content/Applications/Control Panel/Reports/Log Viewer");
44+
Assert.CanRunApplication("/sitecore/content/Applications/Tools/Log Viewer");
4545
}
46-
46+
4747
#endregion
48-
48+
4949
#region Public methods
50-
51-
/// <summary>
52-
/// Opens the specified args.
53-
/// </summary>
54-
/// <param name="args">The arguments.</param>
55-
/// <contract>
56-
/// <requires name="args" condition="not null" />
57-
/// </contract>
58-
[HandleMessage("logviewer:open", true)]
59-
public void Open([NotNull] ClientPipelineArgs args)
60-
{
61-
Assert.ArgumentNotNull(args, "args");
62-
63-
if (args.IsPostBack)
64-
{
65-
if (args.Result.Length > 0 && args.Result != "undefined")
66-
{
67-
if (string.IsNullOrEmpty(args.Result))
68-
{
69-
SheerResponse.Alert(Texts.YOU_CAN_ONLY_OPEN_LOG_FILES);
70-
return;
71-
}
72-
73-
this.SetBlob(args.Result);
74-
}
75-
}
76-
else
77-
{
78-
Framework.Blobs.ListBlobs(Texts.OPEN_LOG_FILE, Texts.SELECT_A_LOG_FILE, "Software/32x32/text_code_colored.png", Texts.OPEN, "*log*.txt");
79-
args.WaitForPostBack();
80-
}
81-
}
82-
50+
8351
/// <summary>
8452
/// Deletes the specified args.
8553
/// </summary>
@@ -148,12 +116,12 @@ public void Download([NotNull] Message message)
148116
Assert.ArgumentNotNull(message, "message");
149117

150118
var blobName = StringUtil.GetString(Context.ClientPage.ServerProperties["Blob"]);
151-
if (blobName == null)
119+
if (string.IsNullOrEmpty(blobName))
152120
{
153121
Context.ClientPage.ClientResponse.Alert(Texts.YOU_MUST_OPEN_A_LOG_FILE_FIRST);
154122
return;
155123
}
156-
124+
157125
if (string.IsNullOrEmpty(blobName))
158126
{
159127
return;
@@ -162,6 +130,43 @@ public void Download([NotNull] Message message)
162130
Framework.Blobs.Download(blobName);
163131
}
164132

133+
/// <summary>
134+
/// Opens the specified args.
135+
/// </summary>
136+
/// <param name="args">The arguments.</param>
137+
/// <contract>
138+
/// <requires name="args" condition="not null" />
139+
/// </contract>
140+
[HandleMessage("logviewer:open", true)]
141+
public void Open([NotNull] ClientPipelineArgs args)
142+
{
143+
Assert.ArgumentNotNull(args, "args");
144+
145+
if (args.IsPostBack)
146+
{
147+
if (args.Result.Length > 0 && args.Result != "undefined")
148+
{
149+
if (string.IsNullOrEmpty(args.Result))
150+
{
151+
SheerResponse.Alert(Texts.YOU_CAN_ONLY_OPEN_LOG_FILES);
152+
return;
153+
}
154+
155+
this.SetBlob(args.Result);
156+
}
157+
}
158+
else
159+
{
160+
Framework.Blobs.ListBlobs(
161+
Texts.OPEN_LOG_FILE,
162+
" ",
163+
"Software/32x32/text_code_colored.png",
164+
Texts.OPEN,
165+
"*log*.txt");
166+
args.WaitForPostBack();
167+
}
168+
}
169+
165170
/// <summary>
166171
/// Refreshes the specified message.
167172
/// </summary>
@@ -182,9 +187,9 @@ public void Refresh([NotNull] Message message)
182187
#region Private methods
183188

184189
/// <summary>
185-
/// Sets the file.
190+
/// Sets the blob.
186191
/// </summary>
187-
/// <param name="blobName">The filename.</param>
192+
/// <param name="blobName">The blob name.</param>
188193
/// <contract>
189194
/// <requires name="filename" condition="none" />
190195
/// </contract>

0 commit comments

Comments
 (0)