graflow: loadNodes is triple modes now: url, blob or object
This commit is contained in:
+17
-10
@@ -109,24 +109,32 @@ class BZgraflow extends Buildoz{
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadFlow(source){
|
async loadFlow(source){
|
||||||
let buf
|
let buf, flowObj
|
||||||
if(source instanceof Blob){
|
if(source instanceof Blob){
|
||||||
buf = await source.text()
|
buf = await source.text()
|
||||||
} else {
|
try{
|
||||||
|
flowObj = JSON.parse(buf)
|
||||||
|
} catch(err){
|
||||||
|
this.error('Could not parse flow JSON!?', err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if(typeof source == 'string') {
|
||||||
const url = source
|
const url = source
|
||||||
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
|
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
|
||||||
? (url + '?' + crypto.randomUUID())
|
? (url + '?' + crypto.randomUUID())
|
||||||
: url
|
: url
|
||||||
const res = await fetch(fetchUrl)
|
const res = await fetch(fetchUrl)
|
||||||
buf = await res.text()
|
buf = await res.text()
|
||||||
|
try{
|
||||||
|
flowObj = JSON.parse(buf)
|
||||||
|
} catch(err){
|
||||||
|
this.error('Could not parse flow JSON!?', err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if(typeof source == 'object') {
|
||||||
|
flowObj = source
|
||||||
}
|
}
|
||||||
let flowObj
|
|
||||||
try{
|
|
||||||
flowObj = JSON.parse(buf)
|
|
||||||
} catch(err){
|
|
||||||
this.error('Could not parse flow JSON!?', err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(!flowObj.nodesFile){
|
if(!flowObj.nodesFile){
|
||||||
this.error('No nodesFile in JSON!?')
|
this.error('No nodesFile in JSON!?')
|
||||||
return
|
return
|
||||||
@@ -450,7 +458,6 @@ class BZgraflow extends Buildoz{
|
|||||||
else this.currentOrientation = 'vertical'
|
else this.currentOrientation = 'vertical'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('forceAutoplace', forceAutoplace, this.currentOrientation)
|
|
||||||
if(forceAutoplace) this.autoPlace(this.currentOrientation, parseInt(this.getBZAttribute('gapx')) || 80, parseInt(this.getBZAttribute('gapy')) || 80)
|
if(forceAutoplace) this.autoPlace(this.currentOrientation, parseInt(this.getBZAttribute('gapx')) || 80, parseInt(this.getBZAttribute('gapy')) || 80)
|
||||||
this.fireEvent('refreshed', { })
|
this.fireEvent('refreshed', { })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user