Skip to content

Commit 100b944

Browse files
committed
Merge branch 'TraceLab-WebService' of https://github.com/CoEST/TraceLab into TraceLab-WebService
# Conflicts: # Main/WebService/Bin/TraceLabWeb.dll # Main/WebService/Bin/TraceLabWeb.pdb # Main/WebService/TraceLabWeb/TraceLabApplicationWebConsole.cs # Main/WebService/TraceLabWeb/WebConsoleUI.cs # Main/WebService/TraceLabWeb/bin/Debug/TraceLabWeb.dll # Main/WebService/TraceLabWeb/bin/Debug/TraceLabWeb.pdb # Main/WebService/TraceLabWeb/obj/Debug/TraceLabWeb.dll # Main/WebService/TraceLabWeb/obj/Debug/TraceLabWeb.pdb
2 parents c0a8a9f + c8835bd commit 100b944

File tree

5 files changed

+186
-137
lines changed

5 files changed

+186
-137
lines changed

Main/WebService/GraphBuilder.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var connections = [];
6262
var text = [];
6363
var ID = [];
6464
var elementIDindex = [];
65+
var indexSelected = -1;
6566

6667
var selectNode = function () {
6768
for (var i = shapes.length; i--;)
@@ -89,16 +90,55 @@ var move = function (dx, dy) {
8990
}
9091
for (var i = shapes.length; i--;)
9192
{
92-
if (this.id == elementIDindex[i])
93+
if (this.id == shapes[i].id)
9394
{
94-
95+
var attText = { x: this.attr("x")+(this.attr("width")/2), y: this.attr("y")+(this.attr("height")/2) };
96+
text[i].attr(attText);
97+
indexSelected = i;
9598
}
9699
}
97100
}
98101
up = function () {
102+
103+
99104
this.animate({ "fill-opacity": 0 }, 500);
105+
for (var i = shapes.length; i--;) {
106+
if (this.id == shapes[i].id) {
107+
indexSelected = i;
108+
}
109+
}
110+
111+
112+
var ob = { x: this.attr("x"), y: this.attr("y"), nodeID: ID[indexSelected] };
113+
var data = JSON.stringify(ob);
114+
jQuery.ajax({
115+
type: "POST", dataType: "json", contentType: "application/json; charset=utf-8",
116+
url: "TraceLab_UI.aspx/MoveNode", data: data,
117+
success: function (retValue)
118+
{
119+
// alert("boop");
120+
},
121+
error: function (jqXHR, exception) {
122+
var msg = '';
123+
if (jqXHR.status === 0) {
124+
msg = 'Not connect.\n Verify Network.';
125+
} else if (jqXHR.status == 404) {
126+
msg = 'Requested page not found. [404]';
127+
} else if (jqXHR.status == 500) {
128+
msg = 'Internal Server Error [500].';
129+
} else if (exception === 'parsererror') {
130+
msg = 'Requested JSON parse failed.';
131+
} else if (exception === 'timeout') {
132+
msg = 'Time out error.';
133+
} else if (exception === 'abort') {
134+
msg = 'Ajax request aborted.';
135+
} else {
136+
msg = 'Uncaught Error.\n' + jqXHR.responseText;
137+
}
138+
$('#post').html(msg);
139+
} });
100140
}
101-
function LoadExperiment(x) {
141+
function LoadExperiment() {
102142
rpaper = Raphael("holder", 1000, 800),
103143
shapes = [],
104144
connections = [],
@@ -149,6 +189,6 @@ function resetNodeHandlers() {
149189
for (var i = 0, ii = shapes.length; i < ii; i++) {
150190
shapes[i].attr({ "stroke-width": 2, cursor: "move" });
151191
shapes[i].drag(move, dragger, up);
152-
shapes[i].click(selectNode);
192+
shapes[i].dblclick(selectNode);
153193
}
154194
}

Main/WebService/TraceLabWeb/TraceLabApplicationWebConsole.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,18 @@ public DataTable GetNodesForDropdown()
8989
return WebConsoleUI.GetNodesForDropdown(); // TODO WebConsoleUI.GetNodes
9090
}
9191

92+
<<<<<<< HEAD
9293
public Dictionary<string, object> OpenExperiment(string path)
94+
=======
95+
public void newExperiment(string fpath)
96+
{
97+
//"C:\\Program Files (x86)\\COEST\\TraceLab\\Tutorials\\First experiment\\VectorSpaceStandardExperiment.teml"
98+
WebConsoleUI.NewExperiment(fpath);
99+
}
100+
101+
102+
public void OpenExperiment(string path)
103+
>>>>>>> c8835bdb0302cfa82198a4fef61fb3fd6474daa5
93104
{
94105
//"C:\\Program Files (x86)\\COEST\\TraceLab\\Tutorials\\First experiment\\VectorSpaceStandardExperiment.teml"
95106
return WebConsoleUI.OpenExperiment(path);
@@ -132,6 +143,11 @@ public void Delete_Node(string nodeID)
132143
WebConsoleUI.Delete_Node(nodeID);
133144
}
134145

146+
public void MoveNode(int x,int y, string nodeID)
147+
{
148+
WebConsoleUI.MoveNode(x, y, nodeID);
149+
}
150+
135151
public void RunExperiment()
136152
{
137153
//"C:\\Program Files (x86)\\COEST\\TraceLab\\Tutorials\\First experiment\\VectorSpaceStandardExperiment.teml"

Main/WebService/TraceLabWeb/WebConsoleUI.cs

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,16 @@ internal static DataTable GetComponentsForDropDown()
120120

121121
internal static DataTable GetComponentInfo(string selectedID)
122122
{
123+
123124
string compConfInfo = "";
124125
DataTable dt = new DataTable() ;
125126
dt.Columns.Add("Type");
126127
dt.Columns.Add("Value");
127128
dt.Columns.Add("Name");
128129
dt.Columns.Add("Section");
129130

131+
try
132+
{
130133
ComponentNode node =(ComponentNode) ConsoleInstance.Application.Experiment.GetNode(selectedID);
131134
ComponentMetadata meta = (ComponentMetadata)node.Data.Metadata;
132135

@@ -177,7 +180,11 @@ internal static DataTable GetComponentInfo(string selectedID)
177180
dt.Rows.Add(dr);
178181
}
179182
}
183+
}
184+
catch(Exception ex)
185+
{
180186

187+
}
181188
return dt;// compConfInfo.Substring (0,compConfInfo.Length -1) ;
182189
}
183190

@@ -332,7 +339,43 @@ public static void DisplayHelp()
332339
log += ("\t?\t- This help message.<br />");
333340
}
334341

342+
<<<<<<< HEAD
335343
public static Dictionary<string, object> OpenExperiment(string value)
344+
=======
345+
346+
public static void NewExperiment(string fpath)
347+
{
348+
//log = "";
349+
try
350+
{
351+
var experiment = TraceLab.Core.Experiments.ExperimentManager.New();
352+
experiment.ExperimentInfo.FilePath = fpath;
353+
try
354+
{
355+
ExperimentManager.Save(experiment, fpath);
356+
}
357+
catch( Exception ex)
358+
{
359+
log += "failed to save experiment:" + ex.Message;
360+
}
361+
if (experiment != null)
362+
{
363+
ReloadApplicationViewModel(experiment);
364+
log += ("\tExperiment has been opened. <br/>");
365+
DisplayExperimentInfo(null);
366+
}
367+
}
368+
catch (Exception ex)
369+
{
370+
string msg = String.Format("Unable to generateExperiment . Error: {0}", ex.Message);
371+
log += msg;
372+
}
373+
}
374+
375+
376+
377+
public static void OpenExperiment(string value)
378+
>>>>>>> c8835bdb0302cfa82198a4fef61fb3fd6474daa5
336379
{
337380
//log = "";
338381
Dictionary<string, object> info;
@@ -514,6 +557,24 @@ public static void Delete_Node(string nodeID)
514557
}
515558
}
516559

560+
public static void MoveNode(int x, int y, string nodeID)
561+
{
562+
//cannot handle start and end nodes
563+
var experiment = ConsoleInstance.Application.Experiment;
564+
try
565+
{
566+
ExperimentNode node = ConsoleInstance.Application.Experiment.GetNode(nodeID);
567+
568+
node.Data.X = x;
569+
node.Data.Y = y;
570+
571+
}
572+
catch (Exception ex)
573+
{
574+
log += ex.Message;
575+
}
576+
}
577+
517578
public static void AddStartNode(string value) //TODO Uneccesary apparently
518579
{
519580
try
@@ -570,9 +631,9 @@ public static void AddStartNode(string value) //TODO Uneccesary apparently
570631

571632
}
572633

573-
catch
634+
catch (Exception ex)
574635
{
575-
log += "Failed to create node";
636+
log += "Failed to create node. Err:"+ex.Message ;
576637
}
577638

578639
}

Main/WebService/TraceLab_UI.aspx

Lines changed: 5 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<html xmlns="http://www.w3.org/1999/xhtml">
55
<head runat="server">
66
<title>TraceLab</title>
7-
7+
8+
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
89
<!-- Latest compiled and minified CSS -->
910
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"/>
1011

@@ -15,119 +16,9 @@
1516
<script type="text/javascript" src="GraphBuilder.js" charset ="utf-8" ></script>
1617
<script type ="text/javascript" >
1718
18-
var el;
19-
var rpaper;
20-
//window.onload = function () {
21-
// var dragger = function () {
22-
// this.ox = this.type == "rect" ? this.attr("x") : this.attr("cx");
23-
// this.oy = this.type == "rect" ? this.attr("y") : this.attr("cy");
24-
// this.animate({ "fill-opacity": .2 }, 500);
25-
// },
26-
// move = function (dx, dy) {
27-
// var att = this.type == "rect" ? { x: this.ox + dx, y: this.oy + dy } : { cx: this.ox + dx, cy: this.oy + dy };
28-
// this.attr(att);
29-
// for (var i = connections.length; i--;) {
30-
// paper.connection(connections[i]);
31-
// }
32-
// paper.safari();
33-
// },
34-
// up = function () {
35-
// this.animate({ "fill-opacity": 0 }, 500);
36-
// },
37-
// paper = Raphael("holder", 640, 480),
38-
// connections = [],
39-
// shapes = [];
40-
// paper.rect(0, 0, 640, 480, 10).attr({ fill: "#ddd", stroke: "none" });
19+
// var el;
20+
// var rpaper;
4121
42-
43-
// shapes.push(paper.rect(290, 80, 60, 40, 2));
44-
// shapes.push(paper.rect(290, 180, 60, 40, 2));
45-
// for (var i = 0, ii = shapes.length; i < ii; i++) {
46-
// var color = Raphael.getColor();
47-
// shapes[i].attr({ fill: color, stroke: color, "fill-opacity": 0, "stroke-width": 2, cursor: "move" });
48-
// shapes[i].drag(move, dragger, up);
49-
// }
50-
// // paper.text(290+30, 80+20, "Trace");
51-
// connections.push(paper.connection(shapes[0], shapes[1], "#000"));
52-
53-
//////};
54-
////var shapes = [];
55-
////var connections = [];
56-
////var text = [];
57-
////var ID = [];
58-
59-
//// var dragger = function () {
60-
//// this.ox = this.type == "rect" ? this.attr("x") : this.attr("cx");
61-
//// this.oy = this.type == "rect" ? this.attr("y") : this.attr("cy");
62-
63-
//// }
64-
//// move = function (dx, dy) {
65-
//// var att = this.type == "rect" ? { x: this.ox + dx, y: this.oy + dy } : { cx: this.ox + dx, cy: this.oy + dy };
66-
//// this.attr(att);
67-
//// for (var i = connections.length; i--;) {
68-
//// rpaper.connection(connections[i]);
69-
//// }
70-
//// }
71-
//// up = function () {
72-
73-
//// }
74-
////function LoadExperiment(x) {
75-
//// rpaper = Raphael("holder", 1000, 800),
76-
//// shapes=[],
77-
//// connections = [],
78-
//// text = [],
79-
//// ID = [];
80-
//// rpaper.clear();
81-
//// rpaper.rect(0, 0, 1000, 800, 10).attr({ fill: "#eee", stroke: "none" });
82-
83-
////};
84-
////function addNode(x, y, w, l,Text,Identifier) {
85-
//// shapes.push(rpaper.rect(x, y, w, l));
86-
//// ID.push(Identifier);
87-
//// text.push(rpaper.text(x + w / 2, y + l / 2, Text));
88-
89-
//// for (var i = 0, ii = shapes.length; i < ii; i++) {
90-
//// shapes[i].attr({"stroke-width": 2, cursor: "move" });
91-
//// shapes[i].drag(move, dragger, up);
92-
//// text[i].attr({cursor: "move"})
93-
//// text[i].drag(move, dragger, up);
94-
//// }
95-
////}
96-
////function addLink(targetID, sourceID)
97-
////{
98-
//// var i = 0;
99-
//// var j = 0;
100-
//// while (i < ID.length) {
101-
//// if (ID[i] == targetID) {
102-
//// break;
103-
//// }
104-
//// else {
105-
//// i++;
106-
//// }
107-
//// }
108-
//// while (j < ID.length) {
109-
//// if (ID[j] == sourceID) {
110-
//// break;
111-
//// }
112-
//// else {
113-
//// j++;
114-
//// }
115-
//// }
116-
117-
//// connections.push(rpaper.connection(shapes[i], shapes[j], "#000"));
118-
119-
////}
120-
121-
////function resetNodeHandlers()
122-
////{
123-
124-
//// for (var i = 0, ii = shapes.length; i < ii; i++) {
125-
//// shapes[i].attr({ "stroke-width": 2, cursor: "move" });
126-
//// shapes[i].drag(move, dragger, up);
127-
//// text[i].attr({ cursor: "move" })
128-
//// text[i].drag(move, dragger, up);
129-
//// }
130-
////}
13122
13223
</script>
13324
</head>
@@ -167,6 +58,7 @@
16758
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
16859

16960
<asp:Timer ID="runningTimer" runat="server" Interval="5" OnTick="running_refresh" Enabled ="False" />
61+
<asp:LinkButton ID="NewProj" CssClass="btn btn-primary btn-lg" runat="server" OnClick="NewProjButton_Click"><span class="glyphicon glyphicon-plus"></span></asp:LinkButton>
17062
<asp:LinkButton ID="Run" CssClass="btn btn-primary btn-lg" runat="server" OnClick="Run_Click"><span class="glyphicon glyphicon-play"></span></asp:LinkButton>
17163
<asp:LinkButton ID="Stop" CssClass="btn btn-primary btn-lg" runat="server" ><span class="glyphicon glyphicon-stop"></span></asp:LinkButton>
17264
<asp:LinkButton ID="ReloadLog" CssClass="btn btn-primary btn-lg" runat="server" OnClick="Log_Click"><span class="glyphicon glyphicon-refresh"></span></asp:LinkButton>

0 commit comments

Comments
 (0)