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
937c64f0
Commit
937c64f0
authored
Jan 31, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix basicReadOnlyExplorer
parent
d51d6b8d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
37 deletions
+16
-37
basicReadOnlyExplorer.js
src/app/files/basicReadOnlyExplorer.js
+16
-37
No files found.
src/app/files/basicReadOnlyExplorer.js
View file @
937c64f0
...
@@ -5,7 +5,9 @@ class BasicReadOnlyExplorer {
...
@@ -5,7 +5,9 @@ class BasicReadOnlyExplorer {
constructor
(
type
)
{
constructor
(
type
)
{
this
.
event
=
new
EventManager
()
this
.
event
=
new
EventManager
()
this
.
files
=
{}
this
.
files
=
{}
this
.
paths
=
{}
this
.
normalizedNames
=
{}
// contains the raw url associated with the displayed path
this
.
normalizedNames
=
{}
// contains the raw url associated with the displayed path
this
.
paths
[
type
]
=
{}
this
.
type
=
type
this
.
type
=
type
this
.
readonly
=
true
this
.
readonly
=
true
}
}
...
@@ -46,6 +48,18 @@ class BasicReadOnlyExplorer {
...
@@ -46,6 +48,18 @@ class BasicReadOnlyExplorer {
try
{
// lazy try to format JSON
try
{
// lazy try to format JSON
content
=
JSON
.
stringify
(
JSON
.
parse
(
content
),
null
,
'
\
t'
)
content
=
JSON
.
stringify
(
JSON
.
parse
(
content
),
null
,
'
\
t'
)
}
catch
(
e
)
{}
}
catch
(
e
)
{}
var
split
=
path
var
folder
=
false
while
(
split
.
lastIndexOf
(
'/'
)
!==
-
1
)
{
var
subitem
=
split
.
substring
(
split
.
lastIndexOf
(
'/'
))
split
=
split
.
substring
(
0
,
split
.
lastIndexOf
(
'/'
))
if
(
!
this
.
paths
[
this
.
type
+
'/'
+
split
])
{
this
.
paths
[
this
.
type
+
'/'
+
split
]
=
{}
}
this
.
paths
[
this
.
type
+
'/'
+
split
][
split
+
subitem
]
=
{
isDirectory
:
folder
}
folder
=
true
}
this
.
paths
[
this
.
type
][
split
]
=
{
isDirectory
:
folder
}
this
.
files
[
this
.
type
+
'/'
+
unprefixedPath
]
=
content
this
.
files
[
this
.
type
+
'/'
+
unprefixedPath
]
=
content
this
.
normalizedNames
[
rawPath
]
=
path
this
.
normalizedNames
[
rawPath
]
=
path
this
.
event
.
trigger
(
'fileAdded'
,
[
this
.
type
+
'/'
+
unprefixedPath
,
true
])
this
.
event
.
trigger
(
'fileAdded'
,
[
this
.
type
+
'/'
+
unprefixedPath
,
true
])
...
@@ -68,46 +82,11 @@ class BasicReadOnlyExplorer {
...
@@ -68,46 +82,11 @@ class BasicReadOnlyExplorer {
return
this
.
files
return
this
.
files
}
}
//
resolveDirectory
(
path
,
callback
)
{
// Tree model for files
// {
// 'a': { }, // empty directory 'a'
// 'b': {
// 'c': {}, // empty directory 'b/c'
// 'd': { '/readonly': true, '/content': 'Hello World' } // files 'b/c/d'
// 'e': { '/readonly': false, '/path': 'b/c/d' } // symlink to 'b/c/d'
// 'f': { '/readonly': false, '/content': '<executable>', '/mode': 0755 }
// }
// }
//
resolveDirectory
(
path
,
callback
/* (error, filesList) => { } */
)
{
var
self
=
this
var
self
=
this
if
(
path
[
0
]
===
'/'
)
path
=
path
.
substring
(
1
)
if
(
path
[
0
]
===
'/'
)
path
=
path
.
substring
(
1
)
if
(
!
path
)
return
callback
(
null
,
{
[
self
.
type
]:
{
}
})
if
(
!
path
)
return
callback
(
null
,
{
[
self
.
type
]:
{
}
})
var
tree
=
{}
callback
(
null
,
this
.
paths
[
path
])
// This does not include '.remix.config', because it is filtered
// inside list().
Object
.
keys
(
this
.
list
()).
forEach
(
function
(
path
)
{
hashmapize
(
tree
,
path
,
{
'/readonly'
:
self
.
isReadOnly
(
path
),
'/content'
:
self
.
get
(
path
)
})
})
return
callback
(
null
,
tree
[
path
]
||
{})
function
hashmapize
(
obj
,
path
,
val
)
{
var
nodes
=
path
.
split
(
'/'
)
var
i
=
0
for
(;
i
<
nodes
.
length
-
1
;
i
++
)
{
var
node
=
nodes
[
i
]
if
(
obj
[
node
]
===
undefined
)
{
obj
[
node
]
=
{}
}
obj
=
obj
[
node
]
}
obj
[
nodes
[
i
]]
=
val
}
}
}
removePrefix
(
path
)
{
removePrefix
(
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