Skip to content

Commit 37340dc

Browse files
monitorv2 and datastream and tokens and bug fixes
Fixed #35 metrics v2 now supported Fixed #37 metric tags on dashboards Fixed #38 ref tables Fixed #39 datastreams and tokens, also #34 with data retention is also added, also #27 is closed Updates to latest in net8 framework Updates to latest all the dependencies Fixed #40 copy and paste in all grids
1 parent 45e419d commit 37340dc

File tree

72 files changed

+4442
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+4442
-407
lines changed

Connection/ObserveConnection.cs

Lines changed: 722 additions & 10 deletions
Large diffs are not rendered by default.

Controllers/CommonControllerMethods.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ public List<AuthenticatedUser> GetAllUsers()
4242
{
4343
List<AuthenticatedUser> allUsers = new List<AuthenticatedUser>();
4444

45-
// Load AuthenticatedUser from cookie if it exists
4645
try
4746
{
48-
//string serializedData = this.Controller.Request.Cookies["Observe.EntityExplorer.AllUsers"];
4947
string authCacheFilePath = Path.Combine(authCacheFolderPath, "observe-entity-explorer.auth-cache.json");
5048
if (Path.Exists(authCacheFilePath) == true)
5149
{
@@ -70,10 +68,6 @@ public void SaveAllUsers(List<AuthenticatedUser> allUsers)
7068
Directory.CreateDirectory(authCacheFolderPath);
7169
string authCacheFilePath = Path.Combine(authCacheFolderPath, "observe-entity-explorer.auth-cache.json");
7270
File.WriteAllText(authCacheFilePath, JsonConvert.SerializeObject(allUsers, Formatting.Indented), Encoding.UTF8);
73-
// Save all users into cookie
74-
// CookieOptions cookieOptions = new CookieOptions();
75-
// cookieOptions.Expires = DateTimeOffset.Now.AddDays(28);
76-
// this.Controller.HttpContext.Response.Cookies.Append("Observe.EntityExplorer.AllUsers", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(allUsers))), cookieOptions);
7771
}
7872

7973
public ObserveEnvironment GetObserveEnvironment(AuthenticatedUser currentUser)
@@ -126,15 +120,13 @@ public void RemoveObserveEnvironment(AuthenticatedUser currentUser)
126120

127121
public void enrichTrace(AuthenticatedUser currentUser)
128122
{
129-
//Activity.Current.AddTag("currentUser", currentUser.ToString());
130123
Activity.Current.AddTag("currentUser", currentUser.UserName);
131124
Activity.Current.AddTag("currentUserID", currentUser.UserID);
132125
Activity.Current.AddTag("currentUserAuthenticatedOn", currentUser.AuthenticatedOn.ToString("u"));
133126
}
134127

135128
public void enrichTrace(ObserveEnvironment observeEnvironment)
136129
{
137-
//Activity.Current.AddTag("observeEnvironment", observeEnvironment.ToString());
138130
Activity.Current.AddTag("observeEnvironmentName", observeEnvironment.CustomerName);
139131
Activity.Current.AddTag("observeEnvironmentLabel", observeEnvironment.CustomerLabel);
140132
Activity.Current.AddTag("observeEnvironmentUrl", observeEnvironment.CustomerEnvironmentUrl);
@@ -151,6 +143,11 @@ public void enrichTrace(ObsMonitor thisObject)
151143
Activity.Current.AddTag("currentObject", thisObject.ToString());
152144
}
153145

146+
public void enrichTrace(ObsMonitor2 thisObject)
147+
{
148+
Activity.Current.AddTag("currentObject", thisObject.ToString());
149+
}
150+
154151
public void enrichTrace(ObsDashboard thisObject)
155152
{
156153
Activity.Current.AddTag("currentObject", thisObject.ToString());

Controllers/ConnectionController.cs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -143,56 +143,6 @@ public IActionResult Connect()
143143
}
144144
}
145145

146-
// public IActionResult SSO()
147-
// {
148-
// Stopwatch stopWatch = new Stopwatch();
149-
// stopWatch.Start();
150-
151-
// try
152-
// {
153-
// ConnectionSSOViewModel viewModel = new ConnectionSSOViewModel(null);
154-
// viewModel.Environment = HttpContext.Request.Query["environment"];
155-
// viewModel.Username = HttpContext.Request.Query["username"];
156-
// viewModel.DelegateURL = HttpContext.Request.Query["deletegateurl"];
157-
158-
// switch (HttpContext.Request.Method)
159-
// {
160-
// case "GET":
161-
// AuthenticatedUser currentUser = getAuthenticatedUserEnvironment(viewModel.Environment, viewModel.Username);
162-
// if (authenticateUserSSOComplete(currentUser, HttpContext.Request.Query["deletegatetoken"]) == true)
163-
// {
164-
// getAuthenticatedUserDetails(currentUser);
165-
// // complete authentication
166-
167-
// throw new NotImplementedException("autheticated here! good job! finish this daniel");
168-
// }
169-
170-
// break;
171-
172-
// case "POST":
173-
// break;
174-
// }
175-
176-
// return View(viewModel);
177-
// }
178-
// catch (Exception ex)
179-
// {
180-
// logger.Error(ex);
181-
// loggerConsole.Error(ex);
182-
183-
// ViewData["ErrorMessage"] = ex.Message;
184-
185-
// return View(new ConnectionSSOViewModel(null));
186-
// }
187-
// finally
188-
// {
189-
// stopWatch.Stop();
190-
191-
// logger.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
192-
// loggerConsole.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
193-
// }
194-
// }
195-
196146
private AuthenticatedUser getAuthenticatedUserEnvironment(string environment, string userName)
197147
{
198148
AuthenticatedUser currentUser = new AuthenticatedUser();

Controllers/DetailsController.cs

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,69 @@ public IActionResult Dataset(
9292
}
9393
}
9494

95+
public IActionResult DatasetOpalExplorer(
96+
string userid,
97+
string id)
98+
{
99+
Stopwatch stopWatch = new Stopwatch();
100+
stopWatch.Start();
101+
102+
try
103+
{
104+
AuthenticatedUser currentUser = this.CommonControllerMethods.GetUser(userid);
105+
if (currentUser == null)
106+
{
107+
return RedirectToAction("Connect", "Connection");
108+
}
109+
ObserveEnvironment observeEnvironment = this.CommonControllerMethods.GetObserveEnvironment(currentUser);
110+
if (observeEnvironment == null)
111+
{
112+
throw new Exception("Unable to retrieve the Observe Environment from cache or server");
113+
}
114+
DetailsDatasetViewModel viewModel = new DetailsDatasetViewModel(currentUser, observeEnvironment);
115+
116+
CommonControllerMethods.enrichTrace(currentUser);
117+
CommonControllerMethods.enrichTrace(observeEnvironment);
118+
119+
switch (HttpContext.Request.Method)
120+
{
121+
case "GET":
122+
ObsDataset thisDataset = null;
123+
if (observeEnvironment.AllDatasetsDict.TryGetValue(id, out thisDataset) == false)
124+
{
125+
throw new KeyNotFoundException(String.Format("Unable to retrieve the Observe Dataset {0} from Observe Environment", id));
126+
}
127+
observeEnvironment.PopulateDatasetStages(currentUser, thisDataset);
128+
viewModel.CurrentDataset = thisDataset;
129+
130+
break;
131+
132+
case "POST":
133+
break;
134+
}
135+
136+
CommonControllerMethods.enrichTrace(viewModel.CurrentDataset);
137+
138+
return View(viewModel);
139+
}
140+
catch (Exception ex)
141+
{
142+
logger.Error(ex, ex.Message);
143+
loggerConsole.Error(ex, ex.Message);
144+
145+
ViewData["ErrorMessage"] = ex.Message;
146+
147+
return View(new DetailsDatasetViewModel(null, null));
148+
}
149+
finally
150+
{
151+
stopWatch.Stop();
152+
153+
logger.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
154+
loggerConsole.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
155+
}
156+
}
157+
95158
public IActionResult Monitor(
96159
string userid,
97160
string id)
@@ -143,7 +206,69 @@ public IActionResult Monitor(
143206

144207
ViewData["ErrorMessage"] = ex.Message;
145208

146-
return View(new DetailsDashboardViewModel(null, null));
209+
return View(new DetailsMonitorViewModel(null, null));
210+
}
211+
finally
212+
{
213+
stopWatch.Stop();
214+
215+
logger.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
216+
loggerConsole.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
217+
}
218+
}
219+
220+
public IActionResult Monitor2(
221+
string userid,
222+
string id)
223+
{
224+
Stopwatch stopWatch = new Stopwatch();
225+
stopWatch.Start();
226+
227+
try
228+
{
229+
AuthenticatedUser currentUser = this.CommonControllerMethods.GetUser(userid);
230+
if (currentUser == null)
231+
{
232+
return RedirectToAction("Connect", "Connection");
233+
}
234+
ObserveEnvironment observeEnvironment = this.CommonControllerMethods.GetObserveEnvironment(currentUser);
235+
if (observeEnvironment == null)
236+
{
237+
throw new Exception("Unable to retrieve the Observe Environment from cache or server");
238+
}
239+
DetailsMonitor2ViewModel viewModel = new DetailsMonitor2ViewModel(currentUser, observeEnvironment);
240+
241+
CommonControllerMethods.enrichTrace(currentUser);
242+
CommonControllerMethods.enrichTrace(observeEnvironment);
243+
244+
switch (HttpContext.Request.Method)
245+
{
246+
case "GET":
247+
ObsMonitor2 thisMonitor = null;
248+
if (observeEnvironment.AllMonitors2Dict.TryGetValue(id, out thisMonitor) == false)
249+
{
250+
throw new KeyNotFoundException(String.Format("Unable to retrieve the Observe Monitor {0} from Observe Environment", id));
251+
}
252+
viewModel.CurrentMonitor = thisMonitor;
253+
254+
break;
255+
256+
case "POST":
257+
break;
258+
}
259+
260+
CommonControllerMethods.enrichTrace(viewModel.CurrentMonitor);
261+
262+
return View(viewModel);
263+
}
264+
catch (Exception ex)
265+
{
266+
logger.Error(ex, ex.Message);
267+
loggerConsole.Error(ex, ex.Message);
268+
269+
ViewData["ErrorMessage"] = ex.Message;
270+
271+
return View(new DetailsMonitor2ViewModel(null, null));
147272
}
148273
finally
149274
{

Controllers/SearchController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public IActionResult Results(
8080
viewModel.SearchResults.AddRange(entity.Stages.Where(s => StringMatches(s.pipeline, query) == true).ToList());
8181
}
8282

83+
foreach (ObsMonitor2 entity in observeEnvironment.AllMonitors2Dict.Values)
84+
{
85+
viewModel.SearchResults.AddRange(entity.Stages.Where(s => StringMatches(s.pipeline, query) == true).ToList());
86+
}
87+
8388
foreach (ObsWorksheet entity in observeEnvironment.AllWorksheetsDict.Values)
8489
{
8590
viewModel.SearchResults.AddRange(entity.Stages.Where(s => StringMatches(s.pipeline, query) == true).ToList());

Controllers/SelectController.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,48 @@ public IActionResult Monitor(
113113
}
114114
}
115115

116+
public IActionResult Monitor2(
117+
string userid)
118+
{
119+
Stopwatch stopWatch = new Stopwatch();
120+
stopWatch.Start();
121+
122+
try
123+
{
124+
AuthenticatedUser currentUser = this.CommonControllerMethods.GetUser(userid);
125+
if (currentUser == null)
126+
{
127+
return RedirectToAction("Connect", "Connection");
128+
}
129+
ObserveEnvironment observeEnvironment = this.CommonControllerMethods.GetObserveEnvironment(currentUser);
130+
if (observeEnvironment == null)
131+
{
132+
ViewData["ErrorMessage"] = "Unable to retrieve the Observe Environment from cache or server";
133+
}
134+
135+
CommonControllerMethods.enrichTrace(currentUser);
136+
CommonControllerMethods.enrichTrace(observeEnvironment);
137+
138+
return View(new BaseViewModel(currentUser, observeEnvironment));
139+
}
140+
catch (Exception ex)
141+
{
142+
logger.Error(ex);
143+
loggerConsole.Error(ex);
144+
145+
ViewData["ErrorMessage"] = ex.Message;
146+
147+
return View(new BaseViewModel(null, null));
148+
}
149+
finally
150+
{
151+
stopWatch.Stop();
152+
153+
logger.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
154+
loggerConsole.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
155+
}
156+
}
157+
116158
public IActionResult Dashboard(
117159
string userid)
118160
{
@@ -280,6 +322,47 @@ public IActionResult RBAC(
280322
}
281323
}
282324

325+
public IActionResult Datastream(
326+
string userid)
327+
{
328+
Stopwatch stopWatch = new Stopwatch();
329+
stopWatch.Start();
330+
331+
try
332+
{
333+
AuthenticatedUser currentUser = this.CommonControllerMethods.GetUser(userid);
334+
if (currentUser == null)
335+
{
336+
return RedirectToAction("Connect", "Connection");
337+
}
338+
ObserveEnvironment observeEnvironment = this.CommonControllerMethods.GetObserveEnvironment(currentUser);
339+
if (observeEnvironment == null)
340+
{
341+
ViewData["ErrorMessage"] = "Unable to retrieve the Observe Environment from cache or server";
342+
}
343+
344+
CommonControllerMethods.enrichTrace(currentUser);
345+
CommonControllerMethods.enrichTrace(observeEnvironment);
346+
347+
return View(new BaseViewModel(currentUser, observeEnvironment));
348+
}
349+
catch (Exception ex)
350+
{
351+
logger.Error(ex);
352+
loggerConsole.Error(ex);
353+
354+
ViewData["ErrorMessage"] = ex.Message;
355+
356+
return View(new BaseViewModel(null, null));
357+
}
358+
finally
359+
{
360+
stopWatch.Stop();
361+
362+
logger.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
363+
loggerConsole.Trace("{0}:{1}/{2}: total duration {3:c} ({4} ms)", HttpContext.Request.Method, this.ControllerContext.RouteData.Values["controller"], this.ControllerContext.RouteData.Values["action"], stopWatch.Elapsed, stopWatch.ElapsedMilliseconds);
364+
}
365+
}
283366

284367
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
285368
public IActionResult Error()

DataObjects/ObsDashboard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public override string ToString()
103103

104104
public ObsDashboard () {}
105105

106-
public ObsDashboard(JObject entityObject, AuthenticatedUser currentUser) : base (entityObject)
106+
public ObsDashboard(JObject entityObject) : base (entityObject)
107107
{
108108
this._raw = entityObject;
109109

0 commit comments

Comments
 (0)