graflow: loadNodes is triple modes now: url, blob or object
This commit is contained in:
+18
-11
@@ -109,24 +109,32 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
|
||||
async loadFlow(source){
|
||||
let buf
|
||||
let buf, flowObj
|
||||
if(source instanceof Blob){
|
||||
buf = await source.text()
|
||||
} else {
|
||||
const url = source
|
||||
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
|
||||
? (url + '?' + crypto.randomUUID())
|
||||
: url
|
||||
const res = await fetch(fetchUrl)
|
||||
buf = await res.text()
|
||||
}
|
||||
let flowObj
|
||||
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 fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
|
||||
? (url + '?' + crypto.randomUUID())
|
||||
: url
|
||||
const res = await fetch(fetchUrl)
|
||||
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
|
||||
}
|
||||
|
||||
if(!flowObj.nodesFile){
|
||||
this.error('No nodesFile in JSON!?')
|
||||
return
|
||||
@@ -450,7 +458,6 @@ class BZgraflow extends Buildoz{
|
||||
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)
|
||||
this.fireEvent('refreshed', { })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user