mirror of
https://github.com/philipredstone/relnet.git
synced 2025-07-09 23:26:41 +02:00
Compare commits
7 Commits
dev
...
c31b5c5b14
Author | SHA1 | Date | |
---|---|---|---|
c31b5c5b14 | |||
0333d37aae | |||
3da29516ec | |||
00e7294f41 | |||
b054d55018 | |||
bbb3645d99 | |||
9ce80b4c59 |
@ -44,6 +44,12 @@ LABEL "org.opencontainers.image.version"="1.0.0"
|
|||||||
LABEL "VERSION"="1.0.0"
|
LABEL "VERSION"="1.0.0"
|
||||||
LABEL maintainer="Tobias Hopp and Philip Rothstein"
|
LABEL maintainer="Tobias Hopp and Philip Rothstein"
|
||||||
|
|
||||||
|
# Install curl for healthcheck
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -qq -y install curl && \
|
||||||
|
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { RELATIONSHIP_TYPES } from '../types/RelationShipTypes';
|
||||||
|
import { Relationship } from '../interfaces/IRelationship';
|
||||||
|
|
||||||
const protocol = window.location.protocol;
|
const protocol = window.location.protocol;
|
||||||
const hostname = window.location.hostname;
|
const hostname = window.location.hostname;
|
||||||
@ -6,27 +8,15 @@ const port = window.location.port;
|
|||||||
|
|
||||||
const API_URL = protocol + '//' + hostname + (port ? ':' + port : '') + '/api';
|
const API_URL = protocol + '//' + hostname + (port ? ':' + port : '') + '/api';
|
||||||
|
|
||||||
// Types
|
|
||||||
export interface Relationship {
|
|
||||||
_id: string;
|
|
||||||
source: string;
|
|
||||||
target: string;
|
|
||||||
type: 'freund' | 'partner' | 'familie' | 'arbeitskolleg' | 'custom';
|
|
||||||
customType?: string;
|
|
||||||
network: string;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CreateRelationshipData {
|
export interface CreateRelationshipData {
|
||||||
source: string;
|
source: string;
|
||||||
target: string;
|
target: string;
|
||||||
type: 'freund' | 'partner' | 'familie' | 'arbeitskolleg' | 'custom';
|
type: RELATIONSHIP_TYPES;
|
||||||
customType?: string;
|
customType?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateRelationshipData {
|
export interface UpdateRelationshipData {
|
||||||
type?: 'freund' | 'partner' | 'familie' | 'arbeitskolleg' | 'custom';
|
type?: RELATIONSHIP_TYPES;
|
||||||
customType?: string;
|
customType?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ interface CanvasGraphProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Physics constants
|
// Physics constants
|
||||||
const NODE_RADIUS = 30; // Node radius in pixels
|
const NODE_RADIUS = 45; // Node radius in pixels
|
||||||
const MIN_DISTANCE = 100; // Minimum distance between any two nodes
|
const MIN_DISTANCE = 110; // Minimum distance between any two nodes
|
||||||
const MAX_DISTANCE = 300; // Maximum distance between connected nodes
|
const MAX_DISTANCE = 500; // Maximum distance between connected nodes
|
||||||
const REPULSION_STRENGTH = 500; // How strongly nodes repel each other when too close
|
const REPULSION_STRENGTH = 500; // How strongly nodes repel each other when too close
|
||||||
const ATTRACTION_STRENGTH = 0.1; // Default attraction between connected nodes
|
const ATTRACTION_STRENGTH = 0.1; // Default attraction between connected nodes
|
||||||
const CONSTRAINT_STRENGTH = 0.2; // Strength of distance constraints
|
const CONSTRAINT_STRENGTH = 0.2; // Strength of distance constraints
|
||||||
@ -573,9 +573,9 @@ const CanvasGraph: React.FC<CanvasGraphProps> = ({ data, width, height, zoomLeve
|
|||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
|
|
||||||
// Draw initials
|
// Draw initials
|
||||||
const initials = `${node.firstName.charAt(0)}${node.lastName.charAt(0)}`;
|
const initials = `${node.firstName} ${node.lastName.charAt(0)}.`;
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = 'white';
|
||||||
ctx.font = 'bold 16px sans-serif';
|
ctx.font = 'bold 13px sans-serif';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
ctx.fillText(initials, pos.x, pos.y);
|
ctx.fillText(initials, pos.x, pos.y);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,10 +3,11 @@ import { addPerson, getPeople, Person, removePerson, updatePerson } from '../api
|
|||||||
import {
|
import {
|
||||||
addRelationship,
|
addRelationship,
|
||||||
getRelationships,
|
getRelationships,
|
||||||
Relationship,
|
|
||||||
removeRelationship,
|
removeRelationship,
|
||||||
updateRelationship,
|
updateRelationship,
|
||||||
} from '../api/relationships';
|
} from '../api/relationships';
|
||||||
|
import { Relationship } from '../interfaces/IRelationship';
|
||||||
|
import { RELATIONSHIP_TYPES } from '../types/RelationShipTypes';
|
||||||
|
|
||||||
interface PersonNode extends Person {
|
interface PersonNode extends Person {
|
||||||
// Additional properties needed for the visualization
|
// Additional properties needed for the visualization
|
||||||
@ -314,7 +315,7 @@ export const useFriendshipNetwork = (
|
|||||||
const createRelationship = async (relationshipData: {
|
const createRelationship = async (relationshipData: {
|
||||||
source: string;
|
source: string;
|
||||||
target: string;
|
target: string;
|
||||||
type: 'freund' | 'partner' | 'familie' | 'arbeitskolleg' | 'custom';
|
type: RELATIONSHIP_TYPES;
|
||||||
customType?: string;
|
customType?: string;
|
||||||
}): Promise<RelationshipEdge> => {
|
}): Promise<RelationshipEdge> => {
|
||||||
if (!networkId) throw new Error('No network selected');
|
if (!networkId) throw new Error('No network selected');
|
||||||
@ -342,7 +343,7 @@ export const useFriendshipNetwork = (
|
|||||||
const updateRelationshipData = async (
|
const updateRelationshipData = async (
|
||||||
relationshipId: string,
|
relationshipId: string,
|
||||||
relationshipData: {
|
relationshipData: {
|
||||||
type?: 'freund' | 'partner' | 'familie' | 'arbeitskolleg' | 'custom';
|
type?: RELATIONSHIP_TYPES;
|
||||||
customType?: string;
|
customType?: string;
|
||||||
},
|
},
|
||||||
): Promise<RelationshipEdge> => {
|
): Promise<RelationshipEdge> => {
|
||||||
|
15
frontend/src/interfaces/IPersonNode.tsx
Normal file
15
frontend/src/interfaces/IPersonNode.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export interface PersonNode {
|
||||||
|
_id: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
birthday?: Date | string | null;
|
||||||
|
notes?: string;
|
||||||
|
position?: {
|
||||||
|
x: number; y: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type for form errors
|
||||||
|
export interface FormErrors {
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
13
frontend/src/interfaces/IRelationship.ts
Normal file
13
frontend/src/interfaces/IRelationship.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Types
|
||||||
|
import { RELATIONSHIP_TYPES } from '../types/RelationShipTypes';
|
||||||
|
|
||||||
|
export interface Relationship {
|
||||||
|
_id: string;
|
||||||
|
source: string;
|
||||||
|
target: string;
|
||||||
|
type: RELATIONSHIP_TYPES;
|
||||||
|
customType?: string;
|
||||||
|
network: string;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
15
frontend/src/types/RelationShipTypes.ts
Normal file
15
frontend/src/types/RelationShipTypes.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export type RELATIONSHIP_TYPES = 'acquaintance' | 'friend' | 'partner' | 'family' | 'secondDegree' | 'colleague' | 'teacher' | 'exPartner' | 'custom';
|
||||||
|
|
||||||
|
export const RELATIONSHIPS: Record<RELATIONSHIP_TYPES, { label: string; color: string }> = {
|
||||||
|
acquaintance: { label: 'Bekannter', color: '#60A5FA' }, // Light blue
|
||||||
|
friend: { label: 'Freund', color: '#60A5FA' }, // Light blue
|
||||||
|
partner: { label: 'Partner', color: '#F472B6' }, // Pink
|
||||||
|
family: { label: 'Familie', color: '#34D399' }, // Green
|
||||||
|
secondDegree: { label: 'Verwandter', color: '#34D399' }, // Green
|
||||||
|
colleague: { label: 'Kollege/Klassenkamerad', color: '#FBBF24' }, // Yellow
|
||||||
|
teacher: { label: 'Lehrer', color: '#FBBF24' }, // Yellow
|
||||||
|
exPartner: { label: 'Ex-Partner', color: '#ce8c13' }, // Orange
|
||||||
|
custom: { label: 'Benutzerdefiniert', color: '#9CA3AF' }, // Gray
|
||||||
|
};
|
||||||
|
export const getRelationshipLabel = (type: RELATIONSHIP_TYPES): string => RELATIONSHIPS[type].label;
|
||||||
|
export const getRelationshipColor = (type: RELATIONSHIP_TYPES): string => RELATIONSHIPS[type].color;
|
@ -217,12 +217,12 @@ const createSampleDemoNetwork = async (userId: mongoose.Types.ObjectId | string)
|
|||||||
|
|
||||||
// Create relationships between people
|
// Create relationships between people
|
||||||
const relationships = [
|
const relationships = [
|
||||||
{ source: 'JohnSmith', target: 'EmmaJohnson', type: 'freund' },
|
{ source: 'JohnSmith', target: 'EmmaJohnson', type: 'friend' },
|
||||||
{ source: 'EmmaJohnson', target: 'MichaelWilliams', type: 'familie' },
|
{ source: 'EmmaJohnson', target: 'MichaelWilliams', type: 'family' },
|
||||||
{ source: 'MichaelWilliams', target: 'SarahBrown', type: 'arbeitskolleg' },
|
{ source: 'MichaelWilliams', target: 'SarahBrown', type: 'colleague' },
|
||||||
{ source: 'SarahBrown', target: 'DavidJones', type: 'freund' },
|
{ source: 'SarahBrown', target: 'DavidJones', type: 'friend' },
|
||||||
{ source: 'DavidJones', target: 'LisaGarcia', type: 'partner' },
|
{ source: 'DavidJones', target: 'LisaGarcia', type: 'partner' },
|
||||||
{ source: 'JohnSmith', target: 'DavidJones', type: 'arbeitskolleg' },
|
{ source: 'JohnSmith', target: 'DavidJones', type: 'colleague' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Create each relationship
|
// Create each relationship
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import mongoose, { Document, Schema } from 'mongoose';
|
||||||
|
|
||||||
|
|
||||||
|
export const RELATIONSHIP_TYPES = [
|
||||||
|
'acquaintance', 'friend', 'partner', 'family', 'secondDegree', 'colleague', 'teacher', 'exPartner', 'custom',
|
||||||
|
];
|
||||||
|
|
||||||
export interface IRelationship extends Document {
|
export interface IRelationship extends Document {
|
||||||
_id: string;
|
_id: string;
|
||||||
source: mongoose.Types.ObjectId;
|
source: mongoose.Types.ObjectId;
|
||||||
@ -24,7 +29,7 @@ const RelationshipSchema = new Schema(
|
|||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
required: [true, 'Relationship type is required'],
|
required: [true, 'Relationship type is required'],
|
||||||
enum: ['freund', 'partner', 'familie', 'arbeitskolleg', 'custom'],
|
enum: RELATIONSHIP_TYPES,
|
||||||
},
|
},
|
||||||
customType: {
|
customType: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -36,7 +41,7 @@ const RelationshipSchema = new Schema(
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create compound index to ensure unique relationships in a network
|
// Create compound index to ensure unique relationships in a network
|
||||||
|
@ -3,6 +3,8 @@ import { check } from 'express-validator';
|
|||||||
import * as relationshipController from '../controllers/relationship.controller';
|
import * as relationshipController from '../controllers/relationship.controller';
|
||||||
import { auth } from '../middleware/auth.middleware';
|
import { auth } from '../middleware/auth.middleware';
|
||||||
import { checkNetworkAccess } from '../middleware/network-access.middleware';
|
import { checkNetworkAccess } from '../middleware/network-access.middleware';
|
||||||
|
import { RELATIONSHIP_TYPES } from '../models/relationship.model';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@ -22,13 +24,7 @@ router.post(
|
|||||||
[
|
[
|
||||||
check('source', 'Source person ID is required').not().isEmpty().isMongoId(),
|
check('source', 'Source person ID is required').not().isEmpty().isMongoId(),
|
||||||
check('target', 'Target person ID is required').not().isEmpty().isMongoId(),
|
check('target', 'Target person ID is required').not().isEmpty().isMongoId(),
|
||||||
check('type', 'Relationship type is required').isIn([
|
check('type', 'Relationship type is required').isIn(RELATIONSHIP_TYPES),
|
||||||
'freund',
|
|
||||||
'partner',
|
|
||||||
'familie',
|
|
||||||
'arbeitskolleg',
|
|
||||||
'custom',
|
|
||||||
]),
|
|
||||||
check('customType', 'Custom type is required when type is custom')
|
check('customType', 'Custom type is required when type is custom')
|
||||||
.if(check('type').equals('custom'))
|
.if(check('type').equals('custom'))
|
||||||
.not()
|
.not()
|
||||||
@ -45,7 +41,7 @@ router.put(
|
|||||||
[
|
[
|
||||||
check('type', 'Relationship type must be valid if provided')
|
check('type', 'Relationship type must be valid if provided')
|
||||||
.optional()
|
.optional()
|
||||||
.isIn(['freund', 'partner', 'familie', 'arbeitskolleg', 'custom']),
|
.isIn(RELATIONSHIP_TYPES),
|
||||||
check('customType', 'Custom type is required when type is custom')
|
check('customType', 'Custom type is required when type is custom')
|
||||||
.if(check('type').equals('custom'))
|
.if(check('type').equals('custom'))
|
||||||
.not()
|
.not()
|
||||||
|
Reference in New Issue
Block a user