Skip to content

Commit

Permalink
manual fix of a newly added field error check
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Jul 12, 2024
2 parents 2a9a80f + 7d19331 commit 70b3f82
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 208 deletions.
15 changes: 12 additions & 3 deletions build_eagle.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
COMPOSE="docker-compose"

# Check if the user has a different docker compose setup
if ! command -v $COMPOSE
then
COMPOSE="docker compose"
fi


case "$1" in
"dep")
export VCS_TAG=`git describe --tags --abbrev=0|sed s/v//`
echo "Building EAGLE version ${VCS_TAG}"
python updateVersion.py
docker-compose -f ./docker/docker-compose.dep.yml build
$COMPOSE -f ./docker/docker-compose.dep.yml build
echo "Build finished!"
exit 1 ;;
"dev")
export VCS_TAG=`git rev-parse --abbrev-ref HEAD`
echo "Building EAGLE development version"
python updateVersion.py
docker-compose -f ./docker/docker-compose.dev.yml build
$COMPOSE -f ./docker/docker-compose.dev.yml build
echo "Build finished!"
exit 1;;
"slim")
export VCS_TAG=`git describe --tags --abbrev=0|sed s/v//`
echo "Building EAGLE slim version ${VCS_TAG}"
python updateVersion.py
docker-compose -f ./docker/docker-compose.dep.yml build
$COMPOSE -f ./docker/docker-compose.dep.yml build
echo "Build finished! Slimming the image now"
echo "This requires to interact with the intermediate server."
echo "Please open the EAGLE settings and put the gitHub and gitLab API keys in"
Expand Down
41 changes: 0 additions & 41 deletions src/Colors.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/Config.ts

This file was deleted.

6 changes: 6 additions & 0 deletions src/Daliuge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import { Category } from './Category';
import { Field } from './Field';
import { Node } from './Node';

export class Daliuge {
// automatically loaded palettes
Expand All @@ -32,6 +33,11 @@ export class Daliuge {

// schemas
static readonly GRAPH_SCHEMA_URL : string = "https://raw.githubusercontent.com/ICRAR/daliuge/master/daliuge-translator/dlg/dropmake/lg.graph.schema";

// NOTE: eventually this can be replaced. Once we have added a new category for PythonInitialiser
static isPythonInitialiser(node: Node): boolean {
return node.getCategory() === Category.PythonMemberFunction && (node.getName().includes("__init__") || node.getName().includes("__class__"));
}
}

export namespace Daliuge {
Expand Down
8 changes: 3 additions & 5 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import { Category } from './Category';
import { ComponentUpdater } from './ComponentUpdater';
import { Daliuge } from './Daliuge';
import { DockerHubBrowser } from "./DockerHubBrowser";
import { EagleConfig } from "./EagleConfig";
import { Edge } from './Edge';
import { Errors } from './Errors';
import { ExplorePalettes } from './ExplorePalettes';
import { Field } from './Field';
import { FileInfo } from './FileInfo';
import { GitHub } from './GitHub';
import { GitLab } from './GitLab';
import { GraphConfig } from "./graphConfig";
import { GraphRenderer } from "./GraphRenderer";
import { Hierarchy } from './Hierarchy';
import { KeyboardShortcut } from './KeyboardShortcut';
Expand Down Expand Up @@ -998,8 +998,6 @@ export class Eagle {
}

createSubgraphFromSelection = () : void => {
console.log("createSubgraphFromSelection()");

const eagle = Eagle.getInstance()
if(eagle.selectedObjects().length === 0){
Utils.showNotification('Error','At least one node must be selected!', 'warning')
Expand Down Expand Up @@ -3561,7 +3559,7 @@ export class Eagle {

// if node is a construct, set width and height a little larger
if (node.isGroup()){
node.setRadius(GraphConfig.MINIMUM_CONSTRUCT_RADIUS);
node.setRadius(EagleConfig.MINIMUM_CONSTRUCT_RADIUS);
}

//if pos is 0 0 then we are not using drop location nor right click location. so we try to determine a logical place to put it
Expand Down Expand Up @@ -3597,7 +3595,7 @@ export class Eagle {
}

// determine whether we should also generate an object data drop along with this node
const generateObjectDataDrop: boolean = newNode.getCategory() === Category.PythonMemberFunction && (newNode.getName().includes("__init__") || newNode.getName().includes("__class__"));
const generateObjectDataDrop: boolean = Daliuge.isPythonInitialiser(newNode);

// optionally generate a new PythonObject node
if (generateObjectDataDrop){
Expand Down
45 changes: 38 additions & 7 deletions src/graphConfig.ts → src/EagleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const colors: { name: string; color: string; }[] = [
{
//node colours
//node colors
name: 'bodyBorder',
color: '#2e3192'
},{
Expand Down Expand Up @@ -38,7 +38,7 @@ const colors: { name: string; color: string; }[] = [
color: '#85b9ff94'
},{

//edge colours
//edge colors
name: 'edgeDefault',
color: '#58595b'
},{
Expand Down Expand Up @@ -80,10 +80,18 @@ const colors: { name: string; color: string; }[] = [
},{
name: 'edgeClosesLoopSelected',
color: '#4247df'
},{

// hierarchy colors
name: 'hierarchyEdgeSelectedColor',
color: '#2F16D5'
},{
name: 'hierarchyEdgeDefaultColor',
color: '#000000'
}
]

export class GraphConfig {
export class EagleConfig {

// graph behaviour
public static readonly NODE_SUGGESTION_RADIUS = 300
Expand All @@ -99,7 +107,7 @@ export class GraphConfig {

//edge settings
public static readonly EDGE_ARROW_SIZE : number = 8;
public static readonly EDGE_DISTANCE_ARROW_VISIBILITY : number = 100; //how loong does an edge have to be to show the direction arrows
public static readonly EDGE_DISTANCE_ARROW_VISIBILITY : number = 100; //how long does an edge have to be to show the direction arrows
public static readonly SWITCH_TO_STRAIGHT_EDGE_MULTIPLIER : number = 5 //this affect the cutoff distance between nodes required to switch between a straight and curved edge

// when creating a new construct to enclose a selection, or shrinking a node to enclose its children,
Expand All @@ -108,14 +116,37 @@ export class GraphConfig {
public static readonly CONSTRUCT_DRAG_OUT_DISTANCE: number = 200;

static getColor(name:string) : string {
let result = 'red'
let result: string = null;

for (const color of colors) {
if(color.name === name){
result = color.color
}else{
continue
break;
}
}

if (result === null){
console.warn("EagleConfig.getColor() could not find color with name", name);
result = 'red';
}

return result
}

static initCSS(){
//overwriting css variables using colors from EagleConfig. I am using this for simple styling to avoid excessive css data binds in the node html files
$("#logicalGraphParent").get(0).style.setProperty("--selectedBg", EagleConfig.getColor('selectBackground'));
$("#logicalGraphParent").get(0).style.setProperty("--selectedConstructBg", EagleConfig.getColor('selectConstructBackground'));
$("#logicalGraphParent").get(0).style.setProperty("--nodeBorder", EagleConfig.getColor('bodyBorder'));
$("#logicalGraphParent").get(0).style.setProperty("--nodeBg", EagleConfig.getColor('nodeBg'));
$("#logicalGraphParent").get(0).style.setProperty("--graphText", EagleConfig.getColor('graphText'));
$("#logicalGraphParent").get(0).style.setProperty("--branchBg", EagleConfig.getColor('branchBg'));
$("#logicalGraphParent").get(0).style.setProperty("--constructBg", EagleConfig.getColor('constructBg'));
$("#logicalGraphParent").get(0).style.setProperty("--embeddedApp", EagleConfig.getColor('embeddedApp'));
$("#logicalGraphParent").get(0).style.setProperty("--constructIcon", EagleConfig.getColor('constructIcon'));
$("#logicalGraphParent").get(0).style.setProperty("--commentEdgeColor", EagleConfig.getColor('commentEdge'));
$("#logicalGraphParent").get(0).style.setProperty("--matchingEdgeColor", EagleConfig.getColor('edgeAutoComplete'));
$("#logicalGraphParent").get(0).style.setProperty("--nodeOutputColor", EagleConfig.getColor('nodeOutputPort'));
$("#logicalGraphParent").get(0).style.setProperty("--nodeInputColor", EagleConfig.getColor('nodeInputPort'));
}
}
31 changes: 23 additions & 8 deletions src/Field.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as ko from "knockout";

import {Eagle} from './Eagle';
import {Utils} from './Utils';
import {Daliuge} from './Daliuge';
import { Errors } from './Errors';
import {Node} from './Node';
import { CategoryData } from './CategoryData';
import { Category } from './Category';
import { GraphConfig } from "./graphConfig";
import { Daliuge } from './Daliuge';
import { Eagle } from './Eagle';
import { EagleConfig } from "./EagleConfig";
import { Errors } from './Errors';
import { Node } from './Node';
import { Setting } from './Setting';
import { Utils } from './Utils';

export class Field {
private displayText : ko.Observable<string>; // user-facing name
Expand Down Expand Up @@ -892,7 +892,7 @@ export class Field {
// errorsWarnings.warnings.push(issue);
}

//chack that the field has a known type
// check that the field has a known type
if (!Utils.validateType(field.getType())) {
const issue: Errors.Issue = Errors.ShowFix("Node " + node.getKey() + " (" + node.getName() + ") has a component parameter (" + field.getDisplayText() + ") whose type (" + field.getType() + ") is unknown", function(){Utils.showField(eagle, node.getId(),field)}, function(){Utils.fixFieldType(eagle, field)}, "Prepend existing type (" + field.getType() + ") with 'Object.'");
field.issues().push({issue:issue,validity:Errors.Validity.Warning})
Expand All @@ -906,7 +906,7 @@ export class Field {
// errorsWarnings.errors.push(issue);
}

//check that the field has a unique display text on the node
// check that the field has a unique display text on the node
for (let j = 0 ; j < node.getFields().length ; j++){
const field1 = node.getFields()[j];
if(field === field1){
Expand All @@ -926,6 +926,21 @@ export class Field {
}
}

// check that PythonObject's self port is input for only one edge
if (node.getCategory() === Category.PythonObject && field.getDisplayText() === Daliuge.FieldName.SELF){
let numSelfPortConnections: number = 0;
for (const edge of eagle.logicalGraph().getEdges()){
if (edge.getDestPortId() === field.getId()){
numSelfPortConnections += 1;
}
}

if (numSelfPortConnections > 1){
const issue: Errors.Issue = Errors.Message("Port " + field.getDisplayText() + " on node " + node.getName() + " cannot have multiple inputs.")
field.issues().push({issue:issue,validity:Errors.Validity.Error})
}
}

// check that fields have parameter types that are suitable for this node
// skip the 'drop class' component parameter, those are always suitable for every node
if (field.getDisplayText() != Daliuge.FieldName.DROP_CLASS && field.getParameterType() != Daliuge.FieldType.ComponentParameter){
Expand Down
Loading

0 comments on commit 70b3f82

Please sign in to comment.