Compare commits
38
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df194dcb65 | ||
|
|
fcb1e535ca | ||
|
|
e71800bd1d | ||
|
|
256349d23e | ||
|
|
bb1e64218a | ||
|
|
731d6cf55b | ||
|
|
a2c5e1f394 | ||
|
|
2d80fcf447 | ||
|
|
d027002cb9 | ||
|
|
4625067352 | ||
|
|
5a8f93e376 | ||
|
|
6e902b91fd | ||
|
|
7471a37220 | ||
|
|
9b0cb2582e | ||
|
|
43cd6a85b1 | ||
|
|
47f4e3e6c8 | ||
|
|
dfb1190e7b | ||
|
|
6292a64d82 | ||
|
|
e397ee3b2d | ||
|
|
9690401dad | ||
|
|
63f894f526 | ||
|
|
345be1aa23 | ||
|
|
e14b0c0214 | ||
|
|
d073a2e804 | ||
|
|
8f41a39a6e | ||
|
|
df6ba88040 | ||
|
|
0b34b37aaf | ||
|
|
694e610ebb | ||
|
|
3503fd90ab | ||
|
|
0c21f7b772 | ||
|
|
53ed4eea07 | ||
|
|
605398505a | ||
|
|
4f728a3514 | ||
|
|
7f4e13c5e0 | ||
|
|
f39f27efee | ||
|
|
bd43063230 | ||
|
|
7d10993b66 | ||
|
|
fd270d27da |
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
|
||||
+62
-3
@@ -72,7 +72,17 @@ bz-select > div.options-container{
|
||||
transition: max-height 0.4s ease;
|
||||
}
|
||||
bz-select > div.options-container.open{ pointer-events: auto; max-height: 10em;}
|
||||
bz-select option{
|
||||
div.options-container.portaled{
|
||||
pointer-events: none;
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
max-height: 0;
|
||||
overflow: auto;
|
||||
transition: max-height 0.4s ease;
|
||||
}
|
||||
div.options-container.portaled.open{ pointer-events: auto; max-height: 10em;}
|
||||
bz-select option,
|
||||
div.options-container option{
|
||||
background-color: #DDD;
|
||||
border: 1px solid black;
|
||||
color: #000;
|
||||
@@ -88,12 +98,14 @@ bz-select option{
|
||||
margin-top 0.3s ease,
|
||||
opacity 0.3s ease;
|
||||
}
|
||||
bz-select option.open{
|
||||
bz-select option.open,
|
||||
div.options-container option.open{
|
||||
margin: 0;
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
bz-select option:hover{
|
||||
bz-select option:hover,
|
||||
div.options-container option:hover{
|
||||
background-color: #44F;
|
||||
color: #FFF;
|
||||
}
|
||||
@@ -359,3 +371,50 @@ bz-grafloweditor .inner-console section .cols-2 input{
|
||||
max-height: 2em;
|
||||
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;
|
||||
}
|
||||
+107
-13
@@ -135,7 +135,7 @@ class BZselect extends Buildoz {
|
||||
if(!this.optionscontainer) this.optionscontainer = document.createElement('div')
|
||||
this.optionscontainer.classList.add('options-container')
|
||||
this.append(this.optionscontainer)
|
||||
this.options = this.querySelectorAll('option')
|
||||
this.syncOptions()
|
||||
if(this.#fillFromMarkup){ //can only do it once and only if fillOptions was not already called !!
|
||||
for(const opt of this.options){
|
||||
this.optionscontainer.append(opt) // Will move is to the right parent
|
||||
@@ -147,6 +147,15 @@ class BZselect extends Buildoz {
|
||||
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
if(this.open || this._closing) this.closeDropdown(true)
|
||||
}
|
||||
|
||||
syncOptions() {
|
||||
if(this.optionscontainer) this.options = this.optionscontainer.querySelectorAll('option')
|
||||
else this.options = []
|
||||
}
|
||||
|
||||
// static get observedAttributes(){ // Only if you want actions on attr change
|
||||
// return([...super.observedAttributes, 'disabled'])
|
||||
// }
|
||||
@@ -172,19 +181,104 @@ class BZselect extends Buildoz {
|
||||
}
|
||||
|
||||
toggle(){
|
||||
for(const opt of this.options){
|
||||
if(this.open) {
|
||||
opt.classList.remove('open')
|
||||
this.optionscontainer.classList.remove('open')
|
||||
} else {
|
||||
if(this.open) this.closeDropdown()
|
||||
else this.openDropdown()
|
||||
}
|
||||
|
||||
openDropdown() {
|
||||
document.querySelectorAll('bz-select').forEach((sel) => {
|
||||
if((sel!==this) && sel.open) sel.toggle()
|
||||
if((sel!==this) && sel.open) sel.closeDropdown(true)
|
||||
})
|
||||
opt.classList.add('open')
|
||||
this.optionscontainer.classList.add('portaled')
|
||||
document.body.appendChild(this.optionscontainer)
|
||||
this.positionPortal()
|
||||
this.bindPortalListeners()
|
||||
this.open = true
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => {
|
||||
if(!this.open) return
|
||||
this.optionscontainer.classList.add('open')
|
||||
for(const opt of this.options) opt.classList.add('open')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
closeDropdown(immediate = false) {
|
||||
if(!this.open) return
|
||||
this.unbindPortalListeners()
|
||||
for(const opt of this.options) opt.classList.remove('open')
|
||||
this.optionscontainer.classList.remove('open')
|
||||
if(immediate) {
|
||||
this.clearCloseTransition()
|
||||
this.finishCloseDropdown()
|
||||
return
|
||||
}
|
||||
this._closing = true
|
||||
this._onTransitionEnd = (evt) => {
|
||||
if(evt.target !== this.optionscontainer) return
|
||||
if(evt.propertyName !== 'max-height') return
|
||||
this.finishCloseDropdownAfterTransition()
|
||||
}
|
||||
this.optionscontainer.addEventListener('transitionend', this._onTransitionEnd)
|
||||
this._closeTimer = setTimeout(() => this.finishCloseDropdownAfterTransition(), 450)
|
||||
}
|
||||
|
||||
finishCloseDropdownAfterTransition() {
|
||||
if(!this._closing) return
|
||||
this.clearCloseTransition()
|
||||
this.finishCloseDropdown()
|
||||
}
|
||||
|
||||
clearCloseTransition() {
|
||||
this._closing = false
|
||||
if(this._closeTimer) clearTimeout(this._closeTimer)
|
||||
this._closeTimer = null
|
||||
if(this._onTransitionEnd) {
|
||||
this.optionscontainer.removeEventListener('transitionend', this._onTransitionEnd)
|
||||
this._onTransitionEnd = null
|
||||
}
|
||||
}
|
||||
this.open = !this.open
|
||||
|
||||
finishCloseDropdown() {
|
||||
this.optionscontainer.classList.remove('portaled')
|
||||
this.clearPortalStyles()
|
||||
if(this.optionscontainer.parentElement !== this) this.append(this.optionscontainer)
|
||||
this.open = false
|
||||
}
|
||||
|
||||
positionPortal() {
|
||||
const rect = this.button.getBoundingClientRect()
|
||||
this.optionscontainer.style.top = `${rect.bottom}px`
|
||||
this.optionscontainer.style.left = `${rect.left}px`
|
||||
this.optionscontainer.style.width = `${rect.width}px`
|
||||
}
|
||||
|
||||
clearPortalStyles() {
|
||||
this.optionscontainer.style.top = ''
|
||||
this.optionscontainer.style.left = ''
|
||||
this.optionscontainer.style.width = ''
|
||||
}
|
||||
|
||||
bindPortalListeners() {
|
||||
this._repositionBound = this.positionPortal.bind(this)
|
||||
window.addEventListener('scroll', this._repositionBound, true)
|
||||
window.addEventListener('resize', this._repositionBound)
|
||||
this._outsideClickBound = (evt) => {
|
||||
if(this.open && !this.contains(evt.target) && !this.optionscontainer.contains(evt.target)) {
|
||||
this.closeDropdown()
|
||||
}
|
||||
}
|
||||
this._outsideClickTimer = setTimeout(() => {
|
||||
document.addEventListener('click', this._outsideClickBound, true)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
unbindPortalListeners() {
|
||||
if(this._repositionBound) window.removeEventListener('scroll', this._repositionBound, true)
|
||||
if(this._repositionBound) window.removeEventListener('resize', this._repositionBound)
|
||||
if(this._outsideClickBound) document.removeEventListener('click', this._outsideClickBound, true)
|
||||
if(this._outsideClickTimer) clearTimeout(this._outsideClickTimer)
|
||||
this._outsideClickTimer = null
|
||||
}
|
||||
|
||||
onClick(evt){
|
||||
@@ -196,7 +290,7 @@ class BZselect extends Buildoz {
|
||||
onOption(value, silent=false){
|
||||
if(this.getAttribute('disabled') !== null) return
|
||||
this.value = value
|
||||
if(!silent) this.toggle()
|
||||
if(!silent && this.open) this.closeDropdown()
|
||||
}
|
||||
|
||||
addOption(value, markup){
|
||||
@@ -207,16 +301,16 @@ class BZselect extends Buildoz {
|
||||
opt.addEventListener('click',this.onClick.bind(this))
|
||||
if(!this.optionscontainer) this.optionscontainer = document.createElement('div')
|
||||
this.optionscontainer.append(opt)
|
||||
this.options = this.querySelectorAll('option')
|
||||
this.syncOptions()
|
||||
this.#fillFromMarkup = false
|
||||
}
|
||||
|
||||
fillOptions(opts, erase = true){
|
||||
// Caution: you cannot count on connectedCallback to have run already, because one might fill before adding to the DOM
|
||||
if(erase){
|
||||
this.options = this.querySelectorAll('option')
|
||||
this.syncOptions()
|
||||
this.options.forEach(node => { node.remove() })
|
||||
this.options = this.querySelectorAll('option')
|
||||
this.syncOptions()
|
||||
this.onOption('', true) // unselect last
|
||||
}
|
||||
for(const opt of opts) this.addOption(opt.value, opt.markup)
|
||||
|
||||
+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(){
|
||||
super()
|
||||
this.defaultAttrs = { }
|
||||
window.debugEditor = this
|
||||
}
|
||||
|
||||
async connectedCallback() {
|
||||
|
||||
+172
-60
@@ -30,6 +30,7 @@ class BZgraflow extends Buildoz{
|
||||
this.stagedNodes = { }
|
||||
this.stagedWires = { }
|
||||
this.arrowDefs = null
|
||||
this.arrowMarkerId = `arrow-${crypto.randomUUID()}`
|
||||
this.currentOrientation = null
|
||||
}
|
||||
|
||||
@@ -98,6 +99,28 @@ class BZgraflow extends Buildoz{
|
||||
else this.initFlow()
|
||||
}
|
||||
|
||||
static get observedAttributes(){
|
||||
return([...super.observedAttributes, 'disabled'])
|
||||
}
|
||||
|
||||
attributeChangedCallback(name, oldValue, newValue) {
|
||||
super.attributeChangedCallback(name, oldValue, newValue)
|
||||
if(name == 'disabled'){
|
||||
if(newValue === null) {
|
||||
this.disabled = false
|
||||
this.style.opacity = 1
|
||||
this.style.pointerEvents = 'auto'
|
||||
} else {
|
||||
this.disabled = true
|
||||
this.style.opacity = 0.5
|
||||
this.style.pointerEvents = 'none'
|
||||
}
|
||||
this.querySelectorAll('.bzgf-zoom-in, .bzgf-zoom-out').forEach((btn) => {
|
||||
btn.disabled = this.disabled
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
error(msg, err){
|
||||
this.querySelector('.graflow-error')?.remove()
|
||||
const errorEl = document.createElement('div')
|
||||
@@ -162,6 +185,8 @@ class BZgraflow extends Buildoz{
|
||||
for(const tpl of doc.querySelectorAll('template')){
|
||||
if(tpl.id=='svg-arrows'){
|
||||
this.arrowDefs = tpl.querySelector('defs').cloneNode(true)
|
||||
const defaultArrow = this.arrowDefs.querySelector('#arrow')
|
||||
if(defaultArrow) defaultArrow.id = this.arrowMarkerId
|
||||
this.wiresContainer.appendChild(this.arrowDefs)
|
||||
} else {
|
||||
const rootEl = tpl.content.querySelector('.bzgf-node')
|
||||
@@ -205,8 +230,8 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
if(typeof(node.data)=='object') Object.assign(this.stagedNodes[id].dataset, node.data)
|
||||
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.top = (node.coords && node.coords.y) ? `${node.coords.y}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 != null) ? `${node.coords.y}px` : '10%'
|
||||
this.stagedNodes[id].dataset.id = id
|
||||
this.stagedNodes[id].ports = Object.fromEntries(Array.from(portEls).map(item => ([item.dataset.id, { ...item.dataset, el:item }])))
|
||||
if(node.subflow) {
|
||||
@@ -227,6 +252,7 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
|
||||
enterSubflow(id){
|
||||
if(this.disabled || this.hasAttribute('disabled')) return
|
||||
const nodeEl = this.stagedNodes[id]
|
||||
if(!nodeEl) return
|
||||
|
||||
@@ -406,7 +432,9 @@ class BZgraflow extends Buildoz{
|
||||
this.hostContainer.style.opacity = '1'
|
||||
this.hostContainer.style.visibility = 'visible'
|
||||
childEl.style.willChange = ''
|
||||
this.fireEvent('subflowExited', { subflow: childEl })
|
||||
this.fireEvent('subflowExited', {
|
||||
component: this
|
||||
})
|
||||
}, { once:true })
|
||||
}
|
||||
|
||||
@@ -438,8 +466,8 @@ class BZgraflow extends Buildoz{
|
||||
this.stagedWires[id] = document.createElementNS('http://www.w3.org/2000/svg', 'path')
|
||||
this.stagedWires[id].setAttribute('d', path)
|
||||
this.stagedWires[id].setAttribute('fill', 'none')
|
||||
if(this.arrowDefs && link.endArrow) this.stagedWires[id].setAttribute('marker-end','url(#arrow)')
|
||||
if(this.arrowDefs && link.startArrow) this.stagedWires[id].setAttribute('marker-start','url(#arrow)')
|
||||
if(this.arrowDefs && link.endArrow) this.stagedWires[id].setAttribute('marker-end',`url(#${this.arrowMarkerId})`)
|
||||
if(this.arrowDefs && link.startArrow) this.stagedWires[id].setAttribute('marker-start',`url(#${this.arrowMarkerId})`)
|
||||
this.stagedWires[id].classList.add('bzgf-wire')
|
||||
this.stagedWires[id].dataset.id = id
|
||||
this.stagedWires[id].link = link
|
||||
@@ -462,7 +490,7 @@ class BZgraflow extends Buildoz{
|
||||
this.clear()
|
||||
let forceAutoplace = false
|
||||
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)
|
||||
}
|
||||
for(const link of this.flow.links){
|
||||
@@ -477,16 +505,98 @@ class BZgraflow extends Buildoz{
|
||||
else this.currentOrientation = 'vertical'
|
||||
}
|
||||
}
|
||||
if(forceAutoplace) this.autoPlace(this.currentOrientation, parseInt(this.getBZAttribute('gapx')) || 80, parseInt(this.getBZAttribute('gapy')) || 80)
|
||||
const gapx = parseInt(this.getBZAttribute('gapx')) || 80
|
||||
const gapy = parseInt(this.getBZAttribute('gapy')) || 80
|
||||
const finishRefresh = () => {
|
||||
this.fireEvent('refreshed', { })
|
||||
if(this.hasAttribute('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)
|
||||
: undefined
|
||||
this.autofit(autofitPercent)
|
||||
if(this._canRunAutoPlace()) this.autofit(autofitPerc)
|
||||
else this._scheduleLayoutWhenReady(() => this.autofit(autofitPerc))
|
||||
}
|
||||
}
|
||||
const onLayoutComplete = () => {
|
||||
this.fireEvent('layoutComplete', { })
|
||||
finishRefresh()
|
||||
}
|
||||
if(forceAutoplace) this._scheduleAutoPlaceWhenReady(this.currentOrientation, gapx, gapy, onLayoutComplete)
|
||||
else onLayoutComplete()
|
||||
}
|
||||
|
||||
disconnectedCallback(){
|
||||
this._disconnectLayoutObserver()
|
||||
super.disconnectedCallback?.()
|
||||
}
|
||||
|
||||
_disconnectLayoutObserver(){
|
||||
if(this._layoutObserver) {
|
||||
this._layoutObserver.disconnect()
|
||||
this._layoutObserver = null
|
||||
}
|
||||
}
|
||||
|
||||
_canRunAutoPlace(){
|
||||
let nodesHaveLayoutSize = false
|
||||
const ids = Object.keys(this.stagedNodes || {})
|
||||
if(ids.length === 0) return(true)
|
||||
for(const nid of ids){
|
||||
if(nid.startsWith('longLinkPlaceHolder_')) continue
|
||||
const el = this.stagedNodes[nid]
|
||||
if(el && (el.offsetWidth > 0 || el.offsetHeight > 0)) {
|
||||
nodesHaveLayoutSize=true
|
||||
break
|
||||
}
|
||||
}
|
||||
return((this.clientWidth > 0 && this.clientHeight > 0) && nodesHaveLayoutSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* autoPlace uses offsetWidth/offsetHeight; when the host is hidden (display:none / off-screen view)
|
||||
* those are 0 and layout is wrong. Defer until the element is measurable.
|
||||
*/
|
||||
_scheduleLayoutWhenReady(callback){
|
||||
this._layoutScheduleToken = (this._layoutScheduleToken || 0) + 1
|
||||
const token = this._layoutScheduleToken
|
||||
this._disconnectLayoutObserver()
|
||||
|
||||
const attempt = () => {
|
||||
if(token !== this._layoutScheduleToken) return(true)
|
||||
if(!this._canRunAutoPlace()) return(false)
|
||||
this._disconnectLayoutObserver()
|
||||
callback()
|
||||
return(true)
|
||||
}
|
||||
|
||||
if(attempt()) return
|
||||
|
||||
this._layoutObserver = new ResizeObserver(() => { attempt() })
|
||||
this._layoutObserver.observe(this)
|
||||
|
||||
let frames = 0
|
||||
const rafPoll = () => {
|
||||
if(token !== this._layoutScheduleToken) return
|
||||
if(attempt()) return
|
||||
if(++frames < 12) requestAnimationFrame(rafPoll)
|
||||
}
|
||||
requestAnimationFrame(rafPoll)
|
||||
}
|
||||
|
||||
_scheduleAutoPlaceWhenReady(orientation, gapx, gapy, onLayoutComplete){
|
||||
this._scheduleLayoutWhenReady(() => {
|
||||
this.autoPlace(orientation, gapx, gapy, null, null, onLayoutComplete)
|
||||
})
|
||||
}
|
||||
|
||||
_maybeFireLayoutComplete(){
|
||||
if(this._layoutMovePending > 0) return
|
||||
if(!this._layoutCompleteHandler) return
|
||||
const fn = this._layoutCompleteHandler
|
||||
this._layoutCompleteHandler = null
|
||||
fn()
|
||||
}
|
||||
|
||||
// Convert viewport (client) coordinates to this instance's SVG local coordinates.
|
||||
// Required when the whole graflow is CSS-transformed (scale/translate), otherwise wire paths
|
||||
@@ -675,7 +785,7 @@ class BZgraflow extends Buildoz{
|
||||
return(path)
|
||||
}
|
||||
|
||||
autoPlace(orientation = null, gapx = null, gapy = null, tween = null, align = null){
|
||||
autoPlace(orientation = null, gapx = null, gapy = null, tween = null, align = null, onLayoutComplete = null){
|
||||
if(orientation == null) orientation = this.getBZAttribute('orientation') || this.currentOrientation || 'horizontal'
|
||||
if(gapx == null) gapx = parseInt(this.getBZAttribute('gapx')) || 80
|
||||
if(gapy == null) gapy = parseInt(this.getBZAttribute('gapy')) || 80
|
||||
@@ -687,6 +797,9 @@ class BZgraflow extends Buildoz{
|
||||
// moveNode() checks this token each frame and will no-op if superseded.
|
||||
this._autoPlaceToken = (this._autoPlaceToken || 0) + 1
|
||||
const token = this._autoPlaceToken
|
||||
this._layoutMovePending = 0
|
||||
this._layoutCompleteToken = token
|
||||
this._layoutCompleteHandler = (typeof onLayoutComplete === 'function') ? onLayoutComplete : null
|
||||
|
||||
// Cleanup placeholders from previous autoPlace() runs.
|
||||
// Each run creates new longLinkPlaceHolder_* IDs; without cleanup they accumulate in the DOM.
|
||||
@@ -810,7 +923,7 @@ class BZgraflow extends Buildoz{
|
||||
y = Math.max(parentsY[parents[nid][0]], y) //TODO handle multiple parents with avg
|
||||
}
|
||||
placedY = y
|
||||
this.moveNode(nid, x, y, orientation, tween, null, token)
|
||||
this.moveNode(nid, x, y, orientation, tween, token)
|
||||
if((align == 'parent') && (nid in parents) && (parents[nid][0] in parentsY)) {
|
||||
parentsY[parents[nid][0]] += gapy + nodeHeight
|
||||
} else {
|
||||
@@ -823,7 +936,7 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
placedY = y
|
||||
this.addFakeNode(nid, x, y, wMax*0.75, fakeNodeHeight)
|
||||
this.moveNode(nid, x, y, orientation, tween, null, token)
|
||||
this.moveNode(nid, x, y, orientation, tween, token)
|
||||
// Never increment parentsY for fake nodes: they're placeholders and must not disalign real children
|
||||
y = Math.max(y, placedY + gapy + fakeNodeHeight)
|
||||
}
|
||||
@@ -844,7 +957,7 @@ class BZgraflow extends Buildoz{
|
||||
!nid.startsWith('longLinkPlaceHolder_') && nid in parents && parents[nid][0] === pid
|
||||
)
|
||||
if(firstRealChild && nodeY[pid] !== nodeY[firstRealChild]){
|
||||
this.moveNode(pid, nodeX[pid], nodeY[firstRealChild], orientation, tween, null, token)
|
||||
this.moveNode(pid, nodeX[pid], nodeY[firstRealChild], orientation, tween, token)
|
||||
nodeY[pid] = nodeY[firstRealChild]
|
||||
}
|
||||
}
|
||||
@@ -873,17 +986,18 @@ class BZgraflow extends Buildoz{
|
||||
for(const nid of layer){
|
||||
if(!nid.startsWith('longLinkPlaceHolder_')){
|
||||
const bb = this.stagedNodes[nid].getBoundingClientRect()
|
||||
this.moveNode(nid, x, y, orientation, tween, null, token)
|
||||
this.moveNode(nid, x, y, orientation, tween, token)
|
||||
x += gapx + (this.stagedNodes[nid].offsetWidth || bb.width)
|
||||
} else {
|
||||
this.addFakeNode(nid, x, y, fakeNodeWidth, hMax*0.75)
|
||||
this.moveNode(nid, x, y, orientation, tween, null, token)
|
||||
this.moveNode(nid, x, y, orientation, tween, token)
|
||||
x += gapx + fakeNodeWidth
|
||||
}
|
||||
}
|
||||
y += hMax + gapy
|
||||
}
|
||||
}
|
||||
this._maybeFireLayoutComplete()
|
||||
}
|
||||
|
||||
clearFakeNodes(){
|
||||
@@ -1003,17 +1117,34 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
|
||||
moveNode(nid, destx, desty, orientation, duration = 200, autoPlaceToken = null) {
|
||||
const t0 = performance.now()
|
||||
const el0 = this.stagedNodes?.[nid]
|
||||
if(!el0) return
|
||||
let layoutTracked = false
|
||||
if(autoPlaceToken != null && autoPlaceToken === this._layoutCompleteToken) {
|
||||
layoutTracked = true
|
||||
this._layoutMovePending++
|
||||
}
|
||||
const finishLayoutMove = () => {
|
||||
if(!layoutTracked) return
|
||||
layoutTracked = false
|
||||
this._layoutMovePending = Math.max(0, this._layoutMovePending - 1)
|
||||
this._maybeFireLayoutComplete()
|
||||
}
|
||||
const t0 = performance.now()
|
||||
const bb = el0.getBoundingClientRect()
|
||||
const parentbb = el0.parentElement.getBoundingClientRect()
|
||||
const x0=bb.x - parentbb.x
|
||||
const y0 = bb.y - parentbb.y
|
||||
function frame(t) {
|
||||
if(autoPlaceToken && autoPlaceToken !== this._autoPlaceToken) return
|
||||
if(autoPlaceToken && autoPlaceToken !== this._autoPlaceToken) {
|
||||
finishLayoutMove()
|
||||
return
|
||||
}
|
||||
const el = this.stagedNodes?.[nid]
|
||||
if(!el) return
|
||||
if(!el) {
|
||||
finishLayoutMove()
|
||||
return
|
||||
}
|
||||
const p = Math.min((t - t0) / duration, 1)
|
||||
const k = p * p * (3 - 2 * p) // smoothstep
|
||||
const x = x0 + (destx - x0) * k
|
||||
@@ -1031,6 +1162,7 @@ class BZgraflow extends Buildoz{
|
||||
flowNode.coords.y = y
|
||||
}
|
||||
this.fireEvent('nodeMoved', { nid, x, y })
|
||||
finishLayoutMove()
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(frame.bind(this))
|
||||
@@ -1201,50 +1333,30 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
|
||||
autofit(percent=100){
|
||||
if(!this.parentElement) return
|
||||
|
||||
const prevTransformOrigin = this.style.transformOrigin
|
||||
this.style.transform = 'none'
|
||||
this.style.transformOrigin = 'top left'
|
||||
|
||||
// Measure real content by unioning viewport-space bounding boxes.
|
||||
// This is robust with overflow:auto and absolute-positioned layers.
|
||||
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)
|
||||
const outwidth = Math.max(this.clientWidth, 1)
|
||||
const outheight = Math.max(this.clientHeight, 1)
|
||||
let inwidth = this.nodesContainer.scrollWidth
|
||||
let inheight = this.nodesContainer.scrollHeight
|
||||
try { // SVG scrollWidth ignores overflowing paths; getBBox() covers wire extent.
|
||||
const wireBB = this.wiresContainer.getBBox()
|
||||
if(wireBB.width > 0 || wireBB.height > 0){
|
||||
inwidth = Math.max(inwidth, wireBB.x + wireBB.width)
|
||||
inheight = Math.max(inheight, wireBB.y + wireBB.height)
|
||||
}
|
||||
|
||||
this.nodesContainer?.querySelectorAll?.('.bzgf-node').forEach(nodeEl => includeBB(nodeEl.getBoundingClientRect()))
|
||||
this.wiresContainer?.querySelectorAll?.('path.bzgf-wire').forEach(path => includeBB(path.getBoundingClientRect()))
|
||||
|
||||
const parentBB = this.parentElement.getBoundingClientRect()
|
||||
const gapx = parseInt(this.getBZAttribute('gapx')) || 80
|
||||
const gapy = parseInt(this.getBZAttribute('gapy')) || 80
|
||||
const rawW = Number.isFinite(left) && Number.isFinite(right) ? Math.max(right - left, 1) : Math.max(this.mainContainer?.clientWidth || this.offsetWidth || 1, 1)
|
||||
const rawH = Number.isFinite(top) && Number.isFinite(bottom) ? Math.max(bottom - top, 1) : Math.max(this.mainContainer?.clientHeight || this.offsetHeight || 1, 1)
|
||||
const contentW = rawW + (2 * gapx)
|
||||
const contentH = rawH + (2 * gapy)
|
||||
const sx = parentBB.width / contentW
|
||||
const sy = parentBB.height / contentH
|
||||
const scale = Math.min(sx, sy)*(percent/100) // uniform scale to fit inside parent
|
||||
const tx = Number.isFinite(left) ? (-left + gapx) : gapx
|
||||
const ty = Number.isFinite(top) ? (-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
|
||||
} catch(_){ // getBBox throws if SVG not rendered yet, but should not happen as we have _canRunAutoPlace() / _scheduleLayoutWhenReady()
|
||||
return
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -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></td>
|
||||
</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>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
</head>
|
||||
|
||||
<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 -->
|
||||
<button data-trigger="onAutoplace2H">Auto-place Horizontal</button>
|
||||
<button data-trigger="onAutoplace2V">Auto-place Vertical</button>
|
||||
|
||||
@@ -45,19 +45,25 @@
|
||||
font-size: 1em;
|
||||
}
|
||||
bz-graflow{
|
||||
overflow: scroll;
|
||||
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 {
|
||||
resize: both;
|
||||
overflow: auto; /* required in practice */
|
||||
min-width: 800px;
|
||||
min-height: 300px;
|
||||
border: 1px solid #999;
|
||||
overflow: hidden;
|
||||
width: 90vw;
|
||||
height: 80vh;
|
||||
min-width: 400px;
|
||||
min-height: 240px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
border:2px solid #A00
|
||||
border: 2px solid #A00;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.container::after {
|
||||
content: "";
|
||||
@@ -102,7 +108,6 @@
|
||||
)
|
||||
|
||||
const el = document.querySelector('.container')
|
||||
let timer = null // debounce
|
||||
const ro = new ResizeObserver(([entry]) => {
|
||||
const grfl = entry.target.querySelector('bz-graflow')
|
||||
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