Skip to content

Commit

Permalink
[#18] added a bunch of code to webUi and also fixed some a bug in nod…
Browse files Browse the repository at this point in the history
…e and one in master
  • Loading branch information
Saetch committed Jun 3, 2024
1 parent ee78a48 commit 64ce17c
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 107 deletions.
29 changes: 26 additions & 3 deletions Cluster/Master/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static async Task<String> AddValue(XYValues value){
return responseBody;
}

static async Task<XYValues?> GetValueAutoInc(double x, double y, int minNodesToEachSide){
static async Task<AutoIncResponse> GetValueAutoInc(double x, double y, int minNodesToEachSide){
using HttpClient httpClient = new HttpClient();
List<Tuple<int, int>> positions = new List<Tuple<int, int>>();
//Todo! Add more sophisticated method of generating relevant data points for the current position
Expand All @@ -208,7 +208,7 @@ static async Task<String> AddValue(XYValues value){

List<WanderingPosition> wanderingPositions = await QueryNodesForPositions(nodeNames, positionsWithHashes, httpClient);
//run UpdateDistributedMapData(wanderingPositions, httpClient) in the background on a separate thread
var t = UpdateDistributedMapData(new List<WanderingPosition>(wanderingPositions), httpClient);
var t = UpdateDistributedMapData(wanderingPositions, httpClient);


double x_double = x;
Expand All @@ -221,7 +221,18 @@ static async Task<String> AddValue(XYValues value){
Console.WriteLine("Response code from distributing map data: " + t.Result);
String result_value = await get_value_from_node(node_name, x, y , httpClient);
XYValues? result = JsonSerializer.Deserialize<XYValues>(result_value, AppJsonSerializerContext.Default.XYValues);
return result;
List<RawPos> addedCorners = new List<RawPos>();
foreach(WanderingPosition pos in wanderingPositions){
addedCorners.Add(new RawPos{
x = pos.x,
y = pos.y
});
}
AutoIncResponse response = new AutoIncResponse{
value = result!,
addedCorners = addedCorners
};
return response;
}

static async Task<List<XYValues>> GetAllValuesFromNode(NodeResponse node, HttpClient httpClient){
Expand Down Expand Up @@ -469,7 +480,16 @@ class Position{
public int hash { get; set; }
}

class RawPos{
public int x { get; set; }
public int y { get; set; }
}

class AutoIncResponse{
public XYValues value { get; set; }
public List<RawPos> addedCorners { get; set; }

}

[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(XYValues[]))]
Expand All @@ -484,6 +504,9 @@ class Position{
[JsonSerializable(typeof(List<Position>))]
[JsonSerializable(typeof(WanderingPosition))]
[JsonSerializable(typeof(List<WanderingPosition>))]
[JsonSerializable(typeof(RawPos))]
[JsonSerializable(typeof(List<RawPos>))]
[JsonSerializable(typeof(AutoIncResponse))]

internal partial class AppJsonSerializerContext : JsonSerializerContext
{
Expand Down
3 changes: 3 additions & 0 deletions Cluster/Node_cs/NodeBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ internal static async Task<List<XYValues>> DeleteSavedValuesBelow(string hash, A


private static async Task<List<HashedPosition>> QueryHasherForPoints(List<Point> positions){
if (positions.Count == 0){
return [];
}
Console.WriteLine("Querying hasher service for points ... ");
var options = new JsonSerializerOptions
{
Expand Down
34 changes: 34 additions & 0 deletions Cluster/vueWebUI/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
22 changes: 22 additions & 0 deletions Cluster/vueWebUI/README.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Building and running your application

When you're ready, start your application by running:
`docker compose up --build`.

Your application will be available at http://localhost:5173.

### Deploying your application to the cloud

First, build your image, e.g.: `docker build -t myapp .`.
If your cloud uses a different CPU architecture than your development
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
you'll want to build the image for that platform, e.g.:
`docker build --platform=linux/amd64 -t myapp .`.

Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.

Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
docs for more detail on building and pushing.

### References
* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)
38 changes: 36 additions & 2 deletions Cluster/vueWebUI/src/components/ResultDisplaySidebar.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<!-- src/components/Sidebar.vue -->
<template>
<div class="sidebar">
<div class="sidebar" >
<p class="active">CurrentValues:</p>
<p class="x_val" >X: {{x_rounded}} </p>
<p class="y_val" >Y: {{y_rounded}} </p>
<p class="z_val" >Z: {{z_rounded}} </p>
<svg width="100%" height="50%" viewBox="0 0 100 100">
<line key="bar" x1="50%" y1="0%" x2="50%" y2="100%" stroke="black" stroke-width="2%" />
<line key="barTop" x1="30%" y1="0%" x2="70%" y2="0%" stroke="black" stroke-width="2%" />
<line key="barBottom" x1="30%" y1="100%" x2="70%" y2="100%" stroke="black" stroke-width="2%" />
<line key="barMiddle" x1="40%" y1="50%" x2="60%" y2="50%" stroke="black" stroke-width="1%" />
<polygon :points="arrowHeadPoints" style="fill:lime;stroke:black;stroke-width:2" />
</svg>
<div>
<div class="display">StepSize: <span id="stepSizeDisplay">{{stepSize}}</span></div>
<input type="range" id="stepSizeSlider" class="slider" min="0.001" max="1.0" step="0.001" :value="stepSize" @input="updateStepSize">
</div>
</div>
</template>

Expand All @@ -21,6 +32,9 @@
x_rounded: this.x,
y_rounded: this.y,
z_rounded: this.z,
arrowY: 0,
arrowHeadPoints: "50,50 75,60 75,40",
stepSize: 0.05
}
},
watch: {
Expand All @@ -32,8 +46,18 @@
},
z: function (newVal) {
this.z_rounded = newVal.toFixed(3);
const hundredPercent = 10.0;
this.arrowY = (( 100.0 * newVal ) / hundredPercent )* (0.5 );
this.arrowHeadPoints = `51,${50 - this.arrowY} 75,${60 - this.arrowY} 75,${40 - this.arrowY}`;
}
}
},
methods: {
updateStepSize(event) {
const newStepSize = event.target.value;
this.stepSize = Number(newStepSize);
this.$emit('update-stepSize', this.stepSize);
}
},


}
Expand All @@ -55,6 +79,11 @@ div.sidebar {
height: 100%;
overflow: auto;
}
.display {
padding: 10px;
text-align: center;
color: black;
}

/* Sidebar links */
.sidebar p {
Expand All @@ -64,6 +93,11 @@ div.sidebar {
text-decoration: none;
}

#stepSizeSlider {
width: 80%;
position: relative;
left: 10%!important;
}
/* Active/current link */
.sidebar p.active {
background-color: #04AA6D;
Expand Down
Loading

0 comments on commit 64ce17c

Please sign in to comment.