Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
e31aa601
Commit
e31aa601
authored
Jun 18, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed Set & exists api to async
parent
0968ae82
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
12 deletions
+33
-12
file-explorer.js
apps/remix-ide/src/app/files/file-explorer.js
+7
-4
fileProvider.js
apps/remix-ide/src/app/files/fileProvider.js
+2
-0
remixDProvider.js
apps/remix-ide/src/app/files/remixDProvider.js
+23
-8
TreeView.js
apps/remix-ide/src/app/ui/TreeView.js
+1
-0
No files found.
apps/remix-ide/src/app/files/file-explorer.js
View file @
e31aa601
...
...
@@ -102,9 +102,9 @@ function fileExplorer (localRegistry, files, menuItems) {
function
fileAdded
(
filepath
)
{
self
.
ensureRoot
(()
=>
{
var
folderpath
=
filepath
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
const
folderpath
=
filepath
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
const
currentTree
=
self
.
treeView
.
nodeAt
(
folderpath
)
var
currentTree
=
self
.
treeView
.
nodeAt
(
folderpath
)
if
(
currentTree
&&
self
.
treeView
.
isExpanded
(
folderpath
))
{
self
.
files
.
resolveDirectory
(
folderpath
,
(
error
,
fileTree
)
=>
{
if
(
error
)
console
.
error
(
error
)
...
...
@@ -130,8 +130,11 @@ function fileExplorer (localRegistry, files, menuItems) {
function
folderAdded
(
folderpath
)
{
self
.
ensureRoot
(()
=>
{
console
.
log
(
'called: ensureRoot'
)
folderpath
=
folderpath
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
console
.
log
(
'folderpath: '
,
folderpath
)
self
.
files
.
resolveDirectory
(
folderpath
,
(
error
,
fileTree
)
=>
{
console
.
log
(
'fileTree: '
,
fileTree
)
if
(
error
)
console
.
error
(
error
)
if
(
!
fileTree
)
return
fileTree
=
normalize
(
folderpath
,
fileTree
)
...
...
@@ -435,12 +438,12 @@ fileExplorer.prototype.uploadFile = function (event) {
let
files
=
this
.
files
function
loadFile
()
{
var
fileReader
=
new
FileReader
()
fileReader
.
onload
=
function
(
event
)
{
fileReader
.
onload
=
async
function
(
event
)
{
if
(
helper
.
checkSpecialChars
(
file
.
name
))
{
modalDialogCustom
.
alert
(
'Special characters are not allowed'
)
return
}
var
success
=
files
.
set
(
name
,
event
.
target
.
result
)
var
success
=
await
files
.
set
(
name
,
event
.
target
.
result
)
if
(
!
success
)
{
modalDialogCustom
.
alert
(
'Failed to create file '
+
name
)
}
else
{
...
...
apps/remix-ide/src/app/files/fileProvider.js
View file @
e31aa601
...
...
@@ -221,6 +221,8 @@ class FileProvider {
window
.
remixFileSystem
.
readdir
(
path
,
(
error
,
files
)
=>
{
var
ret
=
{}
console
.
log
(
'files: '
,
files
)
if
(
files
)
{
files
.
forEach
(
element
=>
{
const
absPath
=
(
path
===
'/'
?
''
:
path
)
+
'/'
+
element
...
...
apps/remix-ide/src/app/files/remixDProvider.js
View file @
e31aa601
...
...
@@ -77,9 +77,11 @@ module.exports = class RemixDProvider {
return
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
})
.
then
((
result
)
=>
{
return
cb
(
null
,
result
)
if
(
cb
)
return
cb
(
null
,
result
)
return
result
}).
catch
((
error
)
=>
{
return
cb
(
error
)
if
(
cb
)
return
cb
(
error
)
throw
new
Error
(
error
)
})
}
...
...
@@ -106,15 +108,26 @@ module.exports = class RemixDProvider {
})
}
set
(
path
,
content
,
cb
)
{
async
set
(
path
,
content
,
cb
)
{
const
unprefixedpath
=
this
.
removePrefix
(
path
)
this
.
_appManager
.
call
(
'remixd'
,
'set'
,
{
path
:
unprefixedpath
,
content
:
content
}).
then
((
result
)
=>
{
if
(
cb
)
return
cb
(
null
,
result
)
const
exists
=
await
this
.
exists
(
path
)
return
this
.
_appManager
.
call
(
'remixd'
,
'set'
,
{
path
:
unprefixedpath
,
content
:
content
}).
then
(
async
(
result
)
=>
{
const
path
=
this
.
type
+
'/'
+
unprefixedpath
if
(
!
exists
)
{
const
isDirectory
=
await
this
.
isDirectory
(
path
)
if
(
isDirectory
)
this
.
event
.
trigger
(
'folderAdded'
,
[
path
])
else
this
.
event
.
trigger
(
'fileAdded'
,
[
path
])
}
else
{
this
.
event
.
trigger
(
'fileChanged'
,
[
path
])
}
if
(
cb
)
return
cb
(
null
,
result
)
}).
catch
((
error
)
=>
{
if
(
cb
)
cb
(
error
)
if
(
cb
)
return
cb
(
error
)
throw
new
Error
(
error
)
})
}
...
...
@@ -127,7 +140,6 @@ module.exports = class RemixDProvider {
const
unprefixedpath
=
this
.
removePrefix
(
path
)
this
.
_appManager
.
call
(
'remixd'
,
'remove'
,
{
path
:
unprefixedpath
})
.
then
(
result
=>
{
console
.
log
(
'result: '
,
result
)
const
path
=
this
.
type
+
'/'
+
unprefixedpath
delete
this
.
filesContent
[
path
]
...
...
@@ -179,7 +191,10 @@ module.exports = class RemixDProvider {
if
(
path
[
0
]
===
'/'
)
path
=
path
.
substring
(
1
)
if
(
!
path
)
return
callback
(
null
,
{
[
self
.
type
]:
{
}
})
const
unprefixedpath
=
this
.
removePrefix
(
path
)
this
.
_appManager
.
call
(
'remixd'
,
'resolveDirectory'
,
{
path
:
unprefixedpath
}).
then
((
result
)
=>
callback
(
null
,
result
)).
catch
(
callback
)
this
.
_appManager
.
call
(
'remixd'
,
'resolveDirectory'
,
{
path
:
unprefixedpath
}).
then
((
result
)
=>
{
console
.
log
(
'result: '
,
result
)
callback
(
null
,
result
)
}).
catch
(
callback
)
}
async
isDirectory
(
path
)
{
...
...
apps/remix-ide/src/app/ui/TreeView.js
View file @
e31aa601
...
...
@@ -152,6 +152,7 @@ class TreeView {
}
nodeAt
(
path
)
{
console
.
log
(
'nodeAt path: '
,
path
)
return
this
.
view
.
querySelector
(
`ul[key="
${
path
}
"]`
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment