Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df194dcb65 | ||
|
|
fcb1e535ca | ||
|
|
e71800bd1d | ||
|
|
256349d23e | ||
|
|
bb1e64218a | ||
|
|
731d6cf55b | ||
|
|
a2c5e1f394 | ||
|
|
2d80fcf447 | ||
|
|
d027002cb9 | ||
|
|
4625067352 | ||
|
|
5a8f93e376 | ||
|
|
6e902b91fd | ||
|
|
7471a37220 | ||
|
|
9b0cb2582e | ||
|
|
43cd6a85b1 | ||
|
|
47f4e3e6c8 | ||
|
|
dfb1190e7b | ||
|
|
6292a64d82 |
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
.well-known
|
||||||
|
/brol
|
||||||
|
/ui/app/config/config.json
|
||||||
|
log2mail.php
|
||||||
|
/ui/log2mail.php
|
||||||
|
/ui/*.sh
|
||||||
|
/ui/s3sync*.*
|
||||||
|
/ui/s3sync*
|
||||||
|
*.sh
|
||||||
|
.sparcStudio
|
||||||
|
.~lock*
|
||||||
|
/ui/squeezed/*
|
||||||
|
/ui/app/assets/videos/*
|
||||||
|
/AGENTS.md
|
||||||
|
/CLAUDE.md
|
||||||
|
.vscode
|
||||||
|
.cursor
|
||||||
+47
@@ -371,3 +371,50 @@ bz-grafloweditor .inner-console section .cols-2 input{
|
|||||||
max-height: 2em;
|
max-height: 2em;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bz-gantt{
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
--row: 25px;
|
||||||
|
--bar-gap: 4px; /* space above & below each bar inside its row */
|
||||||
|
--chart-left: calc(var(--tasks-width, 7em) + 1em); /* where the chart area starts */
|
||||||
|
}
|
||||||
|
bz-gantt ul.tasks{
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
bz-gantt ul.tasks li{
|
||||||
|
box-sizing: border-box;
|
||||||
|
text-wrap: nowrap;
|
||||||
|
height: var(--row);
|
||||||
|
line-height: calc(var(--row) - 1px);
|
||||||
|
border-bottom: 1px dotted #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
bz-gantt.gantt bz-graflow{
|
||||||
|
position: absolute;
|
||||||
|
left: var(--chart-left);
|
||||||
|
top: calc(var(--chart-top, var(--row)) + var(--bar-gap)); /* first task row, measured in refresh(), plus bar centering gap */
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: auto; /* cancel the global bz-graflow 100vw/100vh defaults, */
|
||||||
|
height: auto; /* so the box stretches between its anchored edges */
|
||||||
|
}
|
||||||
|
bz-gantt li.header div.day:first-of-type{ border-left: 1px dotted #555; }
|
||||||
|
bz-gantt li.header div.day{
|
||||||
|
position: absolute;
|
||||||
|
/* anchored to bz-gantt (nearest positioned ancestor): spans all rows */
|
||||||
|
top: var(--bar-gap);
|
||||||
|
bottom: 0;
|
||||||
|
border-right: 1px dotted #555;
|
||||||
|
font-size: .8em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
bz-gantt li.header div.day.today{
|
||||||
|
background: #AD8;
|
||||||
|
z-index: 999;
|
||||||
|
opacity: .3;
|
||||||
|
}
|
||||||
+236
@@ -0,0 +1,236 @@
|
|||||||
|
/**
|
||||||
|
* _ ___ Another
|
||||||
|
* / |/ (_)______ __ _____
|
||||||
|
* / / / __(_-</ // (_-<
|
||||||
|
* /_/|_/_/\__/___/\_, /___/
|
||||||
|
* /___/
|
||||||
|
* production !
|
||||||
|
*
|
||||||
|
* Licensed under the MIT License:
|
||||||
|
* This code is free to use and modify,
|
||||||
|
* as long as the copyright notice and license are kept.
|
||||||
|
*/
|
||||||
|
class BZgantt extends Buildoz {
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
super()
|
||||||
|
this.defaultAttrs = { }
|
||||||
|
}
|
||||||
|
|
||||||
|
async connectedCallback(){
|
||||||
|
await customElements.whenDefined('bz-graflow')
|
||||||
|
super.connectedCallback()
|
||||||
|
this.rowHeight = parseFloat(getComputedStyle(this).getPropertyValue('--row')) || 30
|
||||||
|
|
||||||
|
this.ul = document.createElement('ul')
|
||||||
|
this.ul.classList.add('tasks')
|
||||||
|
this.append(this.ul)
|
||||||
|
this.graflow = document.createElement('bz-graflow')
|
||||||
|
this._syncAttributesToGraflow()
|
||||||
|
this.append(this.graflow)
|
||||||
|
|
||||||
|
this.fireEvent('domConnected', { gantt: this })
|
||||||
|
this.dayWidth = this.getBZAttribute('daywidth') || 20
|
||||||
|
this.dayWidthPadding = 10
|
||||||
|
if(this.getBZAttribute('nodesfile')) this.nodesfile = this.getBZAttribute('nodesfile')
|
||||||
|
else this.initGantt()
|
||||||
|
const dataSrc = this.getBZAttribute('src')
|
||||||
|
if(dataSrc) this.loadData(dataSrc)
|
||||||
|
else this.gantt = { "tasks": [] }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_syncAttributesToGraflow(){
|
||||||
|
for(const attr of this.attributes){
|
||||||
|
if(attr.name === 'flow') continue
|
||||||
|
this.graflow.setAttribute(attr.name, attr.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadData(dataSrc){
|
||||||
|
let buf, ganttObj
|
||||||
|
if(dataSrc instanceof Blob){
|
||||||
|
buf = await dataSrc.text()
|
||||||
|
try{
|
||||||
|
ganttObj = JSON.parse(buf)
|
||||||
|
} catch(err){
|
||||||
|
this.error('Could not parse gantt data JSON!?', err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if(typeof dataSrc == 'string') {
|
||||||
|
const url = dataSrc
|
||||||
|
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
|
||||||
|
? (url + '?' + crypto.randomUUID())
|
||||||
|
: url
|
||||||
|
const res = await fetch(fetchUrl)
|
||||||
|
buf = await res.text()
|
||||||
|
try{
|
||||||
|
ganttObj = JSON.parse(buf)
|
||||||
|
} catch(err){
|
||||||
|
this.error('Could not parse gantt data JSON!?', err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if(typeof dataSrc == 'object') {
|
||||||
|
ganttObj = structuredClone(dataSrc)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ganttObj.nodesFile){
|
||||||
|
if(this.getBZAttribute('nodesfile')) ganttObj.nodesFile = this.getBZAttribute('nodesfile')
|
||||||
|
else {
|
||||||
|
this.error('No nodesFile in JSON!?')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tasks = ganttObj.tasks
|
||||||
|
this.reorder_tasks()
|
||||||
|
await this.graflow.loadNodes(ganttObj.nodesFile)
|
||||||
|
this.refresh()
|
||||||
|
this.fireEvent('ganttDataLoaded', {
|
||||||
|
component: this,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
reorder_tasks(){
|
||||||
|
const byId = new Map(this.tasks.map(t => [t.id, t]))
|
||||||
|
const children = new Map(this.tasks.map(t => [t.id, []]))
|
||||||
|
for(const task of this.tasks){
|
||||||
|
for(const dep of task.dependsOn ?? []){
|
||||||
|
if(children.has(dep)) children.get(dep).push(task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtree weight: number of (unique) descendants of a task
|
||||||
|
const descendants = new Map()
|
||||||
|
const countDescendants = (task, seen) => {
|
||||||
|
for(const child of children.get(task.id)){
|
||||||
|
if(seen.has(child.id)) continue
|
||||||
|
seen.add(child.id)
|
||||||
|
countDescendants(child, seen)
|
||||||
|
}
|
||||||
|
return(seen.size)
|
||||||
|
}
|
||||||
|
for(const task of this.tasks) descendants.set(task.id, countDescendants(task, new Set()))
|
||||||
|
const byWeight = (a, b) => descendants.get(a.id) - descendants.get(b.id)
|
||||||
|
|
||||||
|
// Depth-first walk, a task is placed once all its dependencies are placed
|
||||||
|
const ordered = []
|
||||||
|
const placed = new Set()
|
||||||
|
const ready = task => (task.dependsOn ?? []).every(dep => placed.has(dep) || !byId.has(dep))
|
||||||
|
const visit = task => {
|
||||||
|
if(placed.has(task.id) || !ready(task)) return
|
||||||
|
placed.add(task.id)
|
||||||
|
ordered.push(task)
|
||||||
|
for(const child of [...children.get(task.id)].sort(byWeight)) visit(child)
|
||||||
|
}
|
||||||
|
const roots = this.tasks.filter(t => !(t.dependsOn?.length)).sort(byWeight)
|
||||||
|
for(const root of roots) visit(root)
|
||||||
|
|
||||||
|
// Leftovers (circular dependencies) keep their original order
|
||||||
|
for(const task of this.tasks) if(!placed.has(task.id)) ordered.push(task)
|
||||||
|
this.tasks = ordered
|
||||||
|
}
|
||||||
|
|
||||||
|
getDayIndex(firstDate, date){
|
||||||
|
return Math.ceil((date-firstDate)/86400000)
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFlow(){
|
||||||
|
let firstDate = new Date(this.tasks[0].start)
|
||||||
|
let lastDate = new Date(this.tasks[0].end)
|
||||||
|
for(const task of this.tasks){
|
||||||
|
const startDate = new Date(task.start)
|
||||||
|
const endDate = new Date(task.end)
|
||||||
|
if(startDate < firstDate) firstDate = startDate
|
||||||
|
if(endDate > lastDate) lastDate = endDate
|
||||||
|
}
|
||||||
|
|
||||||
|
const flow = { "nodes": [], "links": [] }
|
||||||
|
let curY = 0
|
||||||
|
const endIdx = this.getDayIndex(firstDate, lastDate)
|
||||||
|
for(const task of this.tasks){
|
||||||
|
const startIdx = this.getDayIndex(firstDate, new Date(task.start))
|
||||||
|
const taskEndIdx = this.getDayIndex(firstDate, new Date(task.end))
|
||||||
|
const markup = {}
|
||||||
|
for(const [key, value] of Object.entries(task)){
|
||||||
|
if(value == null || typeof value === 'object') continue
|
||||||
|
markup[`task.${key}`] = value
|
||||||
|
}
|
||||||
|
if(!markup['task.color']) markup['task.color'] = '#CCC'
|
||||||
|
markup.width = (startIdx<taskEndIdx) ? (taskEndIdx-startIdx) * this.dayWidth : this.dayWidth
|
||||||
|
flow.nodes.push({
|
||||||
|
"nodeType": "bar",
|
||||||
|
"id": task.id,
|
||||||
|
"coords": {
|
||||||
|
"x": (startIdx * this.dayWidth) + (startIdx > 0 ? this.dayWidthPadding : 0),
|
||||||
|
"y": curY,
|
||||||
|
},
|
||||||
|
"markup": markup
|
||||||
|
})
|
||||||
|
for(const dep of task.dependsOn ?? []){
|
||||||
|
flow.links.push({ "from": [dep, "out1"], "to": [task.id, "inp1"] })
|
||||||
|
}
|
||||||
|
curY += this.rowHeight
|
||||||
|
}
|
||||||
|
return([flow, firstDate, endIdx])
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh(){
|
||||||
|
this.ul.innerHTML = ''
|
||||||
|
this.headerLi = document.createElement('li')
|
||||||
|
this.headerLi.classList.add('header')
|
||||||
|
this.ul.appendChild(this.headerLi)
|
||||||
|
|
||||||
|
for(const task of this.tasks){
|
||||||
|
const li = document.createElement('li')
|
||||||
|
li.textContent = task.name
|
||||||
|
li.setAttribute('data-id', task.id)
|
||||||
|
this.ul.appendChild(li)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Publish the widest label width, used by CSS to place the graflow
|
||||||
|
const range = document.createRange()
|
||||||
|
let maxWidth = 0
|
||||||
|
for(const li of this.ul.children){
|
||||||
|
range.selectNodeContents(li)
|
||||||
|
maxWidth = Math.max(maxWidth, range.getBoundingClientRect().width)
|
||||||
|
}
|
||||||
|
this.style.setProperty('--tasks-width', Math.ceil(maxWidth) + 'px')
|
||||||
|
|
||||||
|
const taskLis = [...this.ul.children].slice(1)
|
||||||
|
const row = parseFloat(getComputedStyle(this).getPropertyValue('--row')) || this.rowHeight || 25
|
||||||
|
if(taskLis[0] && taskLis[0].offsetHeight){
|
||||||
|
this.rowHeight = taskLis[1] ? (taskLis[1].offsetTop - taskLis[0].offsetTop) : taskLis[0].offsetHeight
|
||||||
|
this.style.setProperty('--chart-top', `${taskLis[0].offsetTop}px`)
|
||||||
|
} else {
|
||||||
|
this.rowHeight = row
|
||||||
|
this.style.setProperty('--chart-top', `${row}px`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const [flow, firstDate, endIdx] = this.buildFlow()
|
||||||
|
|
||||||
|
let dayDate = new Date(firstDate)
|
||||||
|
for(let idx=0; idx<=endIdx; idx++){
|
||||||
|
const dayDiv = document.createElement('div')
|
||||||
|
dayDiv.classList.add('day')
|
||||||
|
dayDiv.style.left = `calc(var(--chart-left) + ${idx * (this.dayWidth + this.dayWidthPadding)}px)`
|
||||||
|
dayDiv.style.width = (this.dayWidth + this.dayWidthPadding) + 'px'
|
||||||
|
dayDiv.innerHTML = ' ' + dayDate.getDate()
|
||||||
|
if(dayDate.toISOString().substring(0,10) == (new Date()).toISOString().substring(0,10)) dayDiv.classList.add('today')
|
||||||
|
dayDiv.setAttribute('title', new Intl.DateTimeFormat('fr-FR', {
|
||||||
|
timeZone: 'Europe/Paris',
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: '2-digit'
|
||||||
|
}).format(dayDate))
|
||||||
|
dayDate.setDate(dayDate.getDate() + 1)
|
||||||
|
this.headerLi.appendChild(dayDiv)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.graflow.loadFlow({
|
||||||
|
"nodesFile": this.nodesfile,
|
||||||
|
"flow": flow
|
||||||
|
})
|
||||||
|
this.graflow.refresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Buildoz.define('gantt', BZgantt)
|
||||||
@@ -14,7 +14,6 @@ class BZgrafloweditor extends Buildoz{
|
|||||||
constructor(){
|
constructor(){
|
||||||
super()
|
super()
|
||||||
this.defaultAttrs = { }
|
this.defaultAttrs = { }
|
||||||
window.debugEditor = this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async connectedCallback() {
|
async connectedCallback() {
|
||||||
|
|||||||
+29
-67
@@ -230,8 +230,8 @@ class BZgraflow extends Buildoz{
|
|||||||
}
|
}
|
||||||
if(typeof(node.data)=='object') Object.assign(this.stagedNodes[id].dataset, node.data)
|
if(typeof(node.data)=='object') Object.assign(this.stagedNodes[id].dataset, node.data)
|
||||||
const portEls = this.stagedNodes[id].querySelectorAll('.port')
|
const portEls = this.stagedNodes[id].querySelectorAll('.port')
|
||||||
this.stagedNodes[id].style.left = (node.coords && node.coords.x) ? `${node.coords.x}px` : '10%'
|
this.stagedNodes[id].style.left = (node.coords && node.coords.x != null) ? `${node.coords.x}px` : '10%'
|
||||||
this.stagedNodes[id].style.top = (node.coords && node.coords.y) ? `${node.coords.y}px` : '10%'
|
this.stagedNodes[id].style.top = (node.coords && node.coords.y != null) ? `${node.coords.y}px` : '10%'
|
||||||
this.stagedNodes[id].dataset.id = id
|
this.stagedNodes[id].dataset.id = id
|
||||||
this.stagedNodes[id].ports = Object.fromEntries(Array.from(portEls).map(item => ([item.dataset.id, { ...item.dataset, el:item }])))
|
this.stagedNodes[id].ports = Object.fromEntries(Array.from(portEls).map(item => ([item.dataset.id, { ...item.dataset, el:item }])))
|
||||||
if(node.subflow) {
|
if(node.subflow) {
|
||||||
@@ -490,7 +490,7 @@ class BZgraflow extends Buildoz{
|
|||||||
this.clear()
|
this.clear()
|
||||||
let forceAutoplace = false
|
let forceAutoplace = false
|
||||||
for(const node of this.flow.nodes){
|
for(const node of this.flow.nodes){
|
||||||
if((!node.coords) || (!node.coords.x) ||(!node.coords.y)) forceAutoplace=true
|
if((!node.coords) || (node.coords.x == null) || (node.coords.y == null)) forceAutoplace=true
|
||||||
this.addNode(node)
|
this.addNode(node)
|
||||||
}
|
}
|
||||||
for(const link of this.flow.links){
|
for(const link of this.flow.links){
|
||||||
@@ -511,11 +511,11 @@ class BZgraflow extends Buildoz{
|
|||||||
this.fireEvent('refreshed', { })
|
this.fireEvent('refreshed', { })
|
||||||
if(this.hasAttribute('autofit')){
|
if(this.hasAttribute('autofit')){
|
||||||
const autofitAttr = this.getAttribute('autofit')
|
const autofitAttr = this.getAttribute('autofit')
|
||||||
const autofitPercent = (autofitAttr !== null && autofitAttr !== '' && !Number.isNaN(parseFloat(autofitAttr)))
|
const autofitPerc = (autofitAttr !== null && autofitAttr !== '' && !Number.isNaN(parseFloat(autofitAttr)))
|
||||||
? parseFloat(autofitAttr)
|
? parseFloat(autofitAttr)
|
||||||
: undefined
|
: undefined
|
||||||
if(this._canRunAutoPlace()) this.autofit(autofitPercent)
|
if(this._canRunAutoPlace()) this.autofit(autofitPerc)
|
||||||
else this._scheduleLayoutWhenReady(() => this.autofit(autofitPercent))
|
else this._scheduleLayoutWhenReady(() => this.autofit(autofitPerc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const onLayoutComplete = () => {
|
const onLayoutComplete = () => {
|
||||||
@@ -1332,69 +1332,31 @@ class BZgraflow extends Buildoz{
|
|||||||
return(crossLayerLinks)
|
return(crossLayerLinks)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Union bounding boxes of nodes and wires (viewport coords).
|
|
||||||
* Same measurement strategy as autofit(). Call with transform cleared for stable sizes.
|
|
||||||
*/
|
|
||||||
getContentSize(){
|
|
||||||
let left = Infinity
|
|
||||||
let top = Infinity
|
|
||||||
let right = -Infinity
|
|
||||||
let bottom = -Infinity
|
|
||||||
|
|
||||||
const includeBB = (bb) => {
|
|
||||||
if(!bb) return
|
|
||||||
left = Math.min(left, bb.left)
|
|
||||||
top = Math.min(top, bb.top)
|
|
||||||
right = Math.max(right, bb.right)
|
|
||||||
bottom = Math.max(bottom, bb.bottom)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.nodesContainer?.querySelectorAll?.('.bzgf-node').forEach(nodeEl => includeBB(nodeEl.getBoundingClientRect()))
|
|
||||||
this.wiresContainer?.querySelectorAll?.('path.bzgf-wire').forEach(path => includeBB(path.getBoundingClientRect()))
|
|
||||||
|
|
||||||
const gapx = parseInt(this.getBZAttribute('gapx')) || 80
|
|
||||||
const gapy = parseInt(this.getBZAttribute('gapy')) || 80
|
|
||||||
const hasBounds = Number.isFinite(left) && Number.isFinite(right) && Number.isFinite(top) && Number.isFinite(bottom)
|
|
||||||
const rawWidth = hasBounds ? Math.max(right - left, 1) : Math.max(this.mainContainer?.clientWidth || this.offsetWidth || 1, 1)
|
|
||||||
const rawHeight = hasBounds ? Math.max(bottom - top, 1) : Math.max(this.mainContainer?.clientHeight || this.offsetHeight || 1, 1)
|
|
||||||
|
|
||||||
return({
|
|
||||||
left: hasBounds ? left : null,
|
|
||||||
top: hasBounds ? top : null,
|
|
||||||
right: hasBounds ? right : null,
|
|
||||||
bottom: hasBounds ? bottom : null,
|
|
||||||
rawWidth,
|
|
||||||
rawHeight,
|
|
||||||
width: rawWidth + (2 * gapx),
|
|
||||||
height: rawHeight + (2 * gapy),
|
|
||||||
gapx,
|
|
||||||
gapy,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
autofit(percent=100){
|
autofit(percent=100){
|
||||||
if(!this.parentElement) return
|
const outwidth = Math.max(this.clientWidth, 1)
|
||||||
|
const outheight = Math.max(this.clientHeight, 1)
|
||||||
const prevTransformOrigin = this.style.transformOrigin
|
let inwidth = this.nodesContainer.scrollWidth
|
||||||
this.style.transform = 'none'
|
let inheight = this.nodesContainer.scrollHeight
|
||||||
this.style.transformOrigin = 'top left'
|
try { // SVG scrollWidth ignores overflowing paths; getBBox() covers wire extent.
|
||||||
|
const wireBB = this.wiresContainer.getBBox()
|
||||||
const { left, top, width: contentW, height: contentH, gapx, gapy } = this.getContentSize()
|
if(wireBB.width > 0 || wireBB.height > 0){
|
||||||
const parentBB = this.parentElement.getBoundingClientRect()
|
inwidth = Math.max(inwidth, wireBB.x + wireBB.width)
|
||||||
const sx = parentBB.width / contentW
|
inheight = Math.max(inheight, wireBB.y + wireBB.height)
|
||||||
const sy = parentBB.height / contentH
|
}
|
||||||
const scale = Math.min(sx, sy)*(percent/100) // uniform scale to fit inside parent
|
} catch(_){ // getBBox throws if SVG not rendered yet, but should not happen as we have _canRunAutoPlace() / _scheduleLayoutWhenReady()
|
||||||
const tx = left != null ? (-left + gapx) : gapx
|
return
|
||||||
const ty = top != null ? (-top + gapy) : gapy
|
|
||||||
if(!this.isSubflow) {
|
|
||||||
this.style.transformOrigin = prevTransformOrigin || 'top left'
|
|
||||||
this.style.transform = `scale(${scale}) translate(${tx}px, ${ty}px)`
|
|
||||||
} else {
|
|
||||||
this.style.transform = `scale(${scale})`
|
|
||||||
this.style.width = `calc(100% / ${scale})` // means 100% of the parent node DESPITE the scaling
|
|
||||||
this.style.height = `calc(100% / ${scale})` // means 100% of the parent node DESPITE the scaling
|
|
||||||
}
|
}
|
||||||
|
const ratio = Math.min( (outwidth / inwidth), (outheight / inheight) ) * (percent / 100)
|
||||||
|
const tween = parseInt(this.getBZAttribute('tween')) || 0
|
||||||
|
if(tween > 0){
|
||||||
|
const transition = `scale ${tween}ms ease-in-out`
|
||||||
|
this.nodesContainer.style.transition = transition
|
||||||
|
this.wiresContainer.style.transition = transition
|
||||||
|
}
|
||||||
|
this.nodesContainer.style.scale = ratio
|
||||||
|
this.wiresContainer.style.scale = ratio
|
||||||
|
this.nodesContainer.style.transformOrigin = 'top left'
|
||||||
|
this.wiresContainer.style.transformOrigin = 'top left'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Buildoz.define('graflow', BZgraflow)
|
Buildoz.define('graflow', BZgraflow)
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"nodesFile": "./nodesLib/nodesGantt.html",
|
||||||
|
"flow": {
|
||||||
|
"nodes":[
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t1",
|
||||||
|
"coords": { "x": 20, "y": 0},
|
||||||
|
"markup": { "task": "Task 1", "color": "#0F0", "width": 160 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t2",
|
||||||
|
"coords": { "x": 510, "y": 180},
|
||||||
|
"markup": { "task": "Task 2", "color": "#CCF", "width": 60 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t3",
|
||||||
|
"coords": { "x": 570, "y": 240},
|
||||||
|
"markup": { "task": "Task 3", "color": "#FFC", "width": 100 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t4",
|
||||||
|
"coords": { "x": 20, "y": 60},
|
||||||
|
"markup": { "task": "Task 4", "color": "#FCF", "width": 260 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t5",
|
||||||
|
"coords": { "x": 280, "y": 90},
|
||||||
|
"markup": { "task": "Task 5", "color": "#CFF", "width": 30 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t6",
|
||||||
|
"coords": { "x": 310, "y": 120},
|
||||||
|
"markup": { "task": "Task 6", "color": "#FFC", "width": 40 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t7",
|
||||||
|
"coords": { "x": 180, "y": 30},
|
||||||
|
"markup": { "task": "Task 7", "color": "#FCF", "width": 80 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t8",
|
||||||
|
"coords": { "x": 350, "y": 150},
|
||||||
|
"markup": { "task": "Task 8", "color": "#CFF", "width": 160 }
|
||||||
|
},
|
||||||
|
{ "nodeType": "bar",
|
||||||
|
"id": "t9",
|
||||||
|
"coords": { "x": 510, "y": 210},
|
||||||
|
"markup": { "task": "Task 9", "color": "#FFC", "width": 60 }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"links": [
|
||||||
|
{ "from": ["t1", "out1"], "to": ["t7", "inp1"] },
|
||||||
|
{ "from": ["t7", "out1"], "to": ["t5", "inp1"] },
|
||||||
|
{ "from": ["t8", "out1"], "to": ["t2", "inp1"] },
|
||||||
|
{ "from": ["t9", "out1"], "to": ["t3", "inp1"] },
|
||||||
|
{ "from": ["t4", "out1"], "to": ["t5", "inp1"] },
|
||||||
|
{ "from": ["t5", "out1"], "to": ["t6", "inp1"] },
|
||||||
|
{ "from": ["t6", "out1"], "to": ["t8", "inp1"] },
|
||||||
|
{ "from": ["t8", "out1"], "to": ["t9", "inp1"] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<style>
|
||||||
|
.bzgf-node {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
color: black;
|
||||||
|
text-align: center;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bzgf-node .body{
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
height: calc(var(--row, 30px) - 2 * var(--bar-gap, 8px));
|
||||||
|
line-height: calc(var(--row, 30px) - 2 * var(--bar-gap, 8px));
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-size: .9em;
|
||||||
|
padding: 0 2px 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bzgf-node .port{
|
||||||
|
position: absolute;
|
||||||
|
height: 1px;
|
||||||
|
width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bzgf-node [data-direction="w"]{ left: -4px; top: 50%; }
|
||||||
|
.bzgf-node [data-direction="e"]{ right: -4px; top: 50%; }
|
||||||
|
|
||||||
|
.bzgf-wire{ stroke: #AAA; stroke-width: 1; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="bzgf-node" data-nodetype="bar">
|
||||||
|
<div class="port" data-type="in" data-id="inp1" data-direction="w"></div>
|
||||||
|
<div class="port" data-type="out" data-id="out1" data-direction="e"></div>
|
||||||
|
<div class="body" style="background-color:{color};width:{width}px;" title="{task}">{task}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -126,6 +126,18 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a target="test6" href="./test7.html">test7</a></td>
|
||||||
|
<td>Gantt chart 1</td>
|
||||||
|
<td>YES</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>Bezier</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<bz-graflow class="eic" flow="./flows/testFlowEic.json" tension="60">
|
<bz-graflow class="eic" flow="./flows/testFlowEic.json" tension="60" autofit="500">
|
||||||
<div class="demooptions"> <!-- just for demo purposes -->
|
<div class="demooptions"> <!-- just for demo purposes -->
|
||||||
<button data-trigger="onAutoplace2H">Auto-place Horizontal</button>
|
<button data-trigger="onAutoplace2H">Auto-place Horizontal</button>
|
||||||
<button data-trigger="onAutoplace2V">Auto-place Vertical</button>
|
<button data-trigger="onAutoplace2V">Auto-place Vertical</button>
|
||||||
|
|||||||
@@ -45,19 +45,25 @@
|
|||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
bz-graflow{
|
bz-graflow{
|
||||||
overflow: scroll;
|
|
||||||
border: 2px solid black;
|
border: 2px solid black;
|
||||||
}
|
}
|
||||||
bz-graflow.icmp{ grid-column: 1 / -1; width: 100vw; height: 80vh; background: var(--eicui-base-color-grey-10); }
|
/* Fill the demo frame — autofit sizes to the graflow box, not the parent */
|
||||||
|
bz-graflow.icmp{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--eicui-base-color-grey-10);
|
||||||
|
}
|
||||||
.container {
|
.container {
|
||||||
resize: both;
|
resize: both;
|
||||||
overflow: auto; /* required in practice */
|
overflow: hidden;
|
||||||
min-width: 800px;
|
width: 90vw;
|
||||||
min-height: 300px;
|
height: 80vh;
|
||||||
border: 1px solid #999;
|
min-width: 400px;
|
||||||
|
min-height: 240px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
border:2px solid #A00
|
border: 2px solid #A00;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.container::after {
|
.container::after {
|
||||||
content: "";
|
content: "";
|
||||||
@@ -102,7 +108,6 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
const el = document.querySelector('.container')
|
const el = document.querySelector('.container')
|
||||||
let timer = null // debounce
|
|
||||||
const ro = new ResizeObserver(([entry]) => {
|
const ro = new ResizeObserver(([entry]) => {
|
||||||
const grfl = entry.target.querySelector('bz-graflow')
|
const grfl = entry.target.querySelector('bz-graflow')
|
||||||
grfl.autofit()
|
grfl.autofit()
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>graflow</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../buildoz.css">
|
||||||
|
<script src="../buildoz.js"></script>
|
||||||
|
<script src="../bzGraflow.js"></script>
|
||||||
|
<style>
|
||||||
|
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
|
||||||
|
font-family: 'glyphs';
|
||||||
|
src: url('/assets/styles/fonts/glyphs.eot');
|
||||||
|
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
|
||||||
|
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
|
||||||
|
url('/assets/styles/fonts/glyphs.woff') format('woff'),
|
||||||
|
url('/assets/styles/fonts/glyphs.svg') format('svg');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: block;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
background:#888;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.gantt-wrap{
|
||||||
|
position: relative;
|
||||||
|
--row: 30px;
|
||||||
|
}
|
||||||
|
ul.tasks{
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
ul.tasks li{
|
||||||
|
box-sizing: border-box;
|
||||||
|
text-wrap: nowrap;
|
||||||
|
height: var(--row);
|
||||||
|
line-height: calc(var(--row) - 1px);
|
||||||
|
border-bottom: 1px dotted #555;
|
||||||
|
}
|
||||||
|
bz-graflow.gantt{
|
||||||
|
position: absolute;
|
||||||
|
left: 10em;
|
||||||
|
top: 6px;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load',()=>{
|
||||||
|
let grflw1 = document.querySelector('bz-graflow.gantt')
|
||||||
|
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="gantt-wrap">
|
||||||
|
<ul class="tasks">
|
||||||
|
<li>Task 1</li>
|
||||||
|
<li>Task 7</li>
|
||||||
|
<li>Task 4</li>
|
||||||
|
<li>Task 5</li>
|
||||||
|
<li>Task 6</li>
|
||||||
|
<li>Task 8</li>
|
||||||
|
<li>Task 2</li>
|
||||||
|
<li>Task 9</li>
|
||||||
|
<li>Task 3</li>
|
||||||
|
</ul>
|
||||||
|
<bz-graflow class="gantt" flow="./flows/gantt.json" tension="60" isolated></bz-graflow>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>graflow</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../../eicui/eicui-2.0.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../buildoz.css">
|
||||||
|
<script src="../buildoz.js"></script>
|
||||||
|
<script src="../bzGraflow.js"></script>
|
||||||
|
<script src="../bzGantt.js"></script>
|
||||||
|
<style>
|
||||||
|
@font-face { /*FF does not indirectly load if inside a shawdow-dom */
|
||||||
|
font-family: 'glyphs';
|
||||||
|
src: url('/assets/styles/fonts/glyphs.eot');
|
||||||
|
src: url('/assets/styles/fonts/glyphs.eot') format('embedded-opentype'),
|
||||||
|
url('/assets/styles/fonts/glyphs.ttf') format('truetype'),
|
||||||
|
url('/assets/styles/fonts/glyphs.woff') format('woff'),
|
||||||
|
url('/assets/styles/fonts/glyphs.svg') format('svg');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: block;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
background:#888;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
const ganttData = {
|
||||||
|
"tasks": [
|
||||||
|
{ "id": "t1", "name": "Task 1", "start": "2026-08-25", "end":"2026-08-29", "color": "#8F8" },
|
||||||
|
{ "id": "t2", "name": "Task 2", "start": "2026-09-08", "end":"2026-09-13", "color": "#F8F", "dependsOn": ["t8"] },
|
||||||
|
{ "id": "t3", "name": "Task 3", "start": "2026-09-13", "end":"2026-09-18", "color": "#FF8", "dependsOn": ["t9"] },
|
||||||
|
{ "id": "t4", "name": "Task 4", "start": "2026-08-25", "end":"2026-09-03", "color": "#F88" },
|
||||||
|
{ "id": "t5", "name": "Task 5", "start": "2026-08-29", "end":"2026-08-31", "color": "#88F", "dependsOn": ["t4", "t7"] },
|
||||||
|
{ "id": "t6", "name": "Task 6", "start": "2026-08-31", "end":"2026-09-01", "color": "#8F8", "dependsOn": ["t5"] },
|
||||||
|
{ "id": "t7", "name": "Task 7", "start": "2026-08-29", "end":"2026-09-01", "color": "#88F", "dependsOn": ["t1"] },
|
||||||
|
{ "id": "t8", "name": "Task 8 which is quite long", "start": "2026-09-01", "end":"2026-09-08", "color": "#8F8", "dependsOn": ["t6"] },
|
||||||
|
{ "id": "t9", "name": "Task 9", "start": "2026-09-08", "end":"2026-09-11", "color": "#F8F", "dependsOn": ["t8"] },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load',()=>{
|
||||||
|
let gantt = document.querySelector('bz-gantt.gantt')
|
||||||
|
gantt.loadData(ganttData)
|
||||||
|
gantt.refresh()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<bz-gantt class="gantt" nodesfile="./nodesLib/nodesGantt.html" tension="60" isolated></bz-gantt>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in new issue
Block a user