Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
0ecc1c89
Commit
0ecc1c89
authored
Mar 27, 2015
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #15254 from owncloud/fix-14853-master
Adding a pending indicator to the files summary
parents
4d57b7bb
2b0906cd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files/js/filesummary.js
+27
-11
27 additions, 11 deletions
apps/files/js/filesummary.js
apps/files/tests/js/filesummarySpec.js
+33
-0
33 additions, 0 deletions
apps/files/tests/js/filesummarySpec.js
with
60 additions
and
11 deletions
apps/files/js/filesummary.js
+
27
−
11
View file @
0ecc1c89
...
...
@@ -40,7 +40,8 @@
totalFiles
:
0
,
totalDirs
:
0
,
totalSize
:
0
,
filter
:
''
filter
:
''
,
sumIsPending
:
false
},
/**
...
...
@@ -58,7 +59,12 @@
else
{
this
.
summary
.
totalFiles
++
;
}
this
.
summary
.
totalSize
+=
parseInt
(
file
.
size
,
10
)
||
0
;
var
size
=
parseInt
(
file
.
size
,
10
)
||
0
;
if
(
size
>=
0
)
{
this
.
summary
.
totalSize
+=
size
;
}
else
{
this
.
summary
.
sumIsPending
=
true
;
}
if
(
!!
update
)
{
this
.
update
();
}
...
...
@@ -78,7 +84,10 @@
else
{
this
.
summary
.
totalFiles
--
;
}
this
.
summary
.
totalSize
-=
parseInt
(
file
.
size
,
10
)
||
0
;
var
size
=
parseInt
(
file
.
size
,
10
)
||
0
;
if
(
size
>=
0
)
{
this
.
summary
.
totalSize
-=
size
;
}
if
(
!!
update
)
{
this
.
update
();
}
...
...
@@ -103,7 +112,8 @@
totalDirs
:
0
,
totalFiles
:
0
,
totalSize
:
0
,
filter
:
this
.
summary
.
filter
filter
:
this
.
summary
.
filter
,
sumIsPending
:
false
};
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
...
...
@@ -117,7 +127,12 @@
else
{
summary
.
totalFiles
++
;
}
summary
.
totalSize
+=
parseInt
(
file
.
size
,
10
)
||
0
;
var
size
=
parseInt
(
file
.
size
,
10
)
||
0
;
if
(
size
>=
0
)
{
summary
.
totalSize
+=
size
;
}
else
{
summary
.
sumIsPending
=
true
;
}
}
this
.
setSummary
(
summary
);
},
...
...
@@ -160,7 +175,8 @@
// Substitute old content with new translations
$dirInfo
.
html
(
n
(
'
files
'
,
'
%n folder
'
,
'
%n folders
'
,
this
.
summary
.
totalDirs
));
$fileInfo
.
html
(
n
(
'
files
'
,
'
%n file
'
,
'
%n files
'
,
this
.
summary
.
totalFiles
));
this
.
$el
.
find
(
'
.filesize
'
).
html
(
OC
.
Util
.
humanFileSize
(
this
.
summary
.
totalSize
));
var
fileSize
=
this
.
summary
.
sumIsPending
?
t
(
'
files
'
,
'
Pending
'
)
:
OC
.
Util
.
humanFileSize
(
this
.
summary
.
totalSize
);
this
.
$el
.
find
(
'
.filesize
'
).
html
(
fileSize
);
// Show only what's necessary (may be hidden)
if
(
this
.
summary
.
totalDirs
===
0
)
{
...
...
@@ -194,10 +210,9 @@
var
summary
=
this
.
summary
;
var
directoryInfo
=
n
(
'
files
'
,
'
%n folder
'
,
'
%n folders
'
,
summary
.
totalDirs
);
var
fileInfo
=
n
(
'
files
'
,
'
%n file
'
,
'
%n files
'
,
summary
.
totalFiles
);
if
(
this
.
summary
.
filter
===
''
)
{
var
filterInfo
=
''
;
}
else
{
var
filterInfo
=
'
'
+
n
(
'
files
'
,
'
matches
\'
{filter}
\'
'
,
'
match
\'
{filter}
\'
'
,
summary
.
totalFiles
+
summary
.
totalDirs
,
{
filter
:
summary
.
filter
});
if
(
this
.
summary
.
filter
!==
''
)
{
filterInfo
=
'
'
+
n
(
'
files
'
,
'
matches
\'
{filter}
\'
'
,
'
match
\'
{filter}
\'
'
,
summary
.
totalFiles
+
summary
.
totalDirs
,
{
filter
:
summary
.
filter
});
}
var
infoVars
=
{
...
...
@@ -208,7 +223,8 @@
// don't show the filesize column, if filesize is NaN (e.g. in trashbin)
var
fileSize
=
''
;
if
(
!
isNaN
(
summary
.
totalSize
))
{
fileSize
=
'
<td class="filesize">
'
+
OC
.
Util
.
humanFileSize
(
summary
.
totalSize
)
+
'
</td>
'
;
fileSize
=
summary
.
sumIsPending
?
t
(
'
files
'
,
'
Pending
'
)
:
OC
.
Util
.
humanFileSize
(
summary
.
totalSize
);
fileSize
=
'
<td class="filesize">
'
+
fileSize
+
'
</td>
'
;
}
var
info
=
t
(
'
files
'
,
'
{dirs} and {files}
'
,
infoVars
,
null
,
{
'
escape
'
:
false
});
...
...
This diff is collapsed.
Click to expand it.
apps/files/tests/js/filesummarySpec.js
+
33
−
0
View file @
0ecc1c89
...
...
@@ -148,4 +148,37 @@ describe('OCA.Files.FileSummary tests', function() {
expect
(
s
.
summary
.
totalFiles
).
toEqual
(
1
);
expect
(
s
.
summary
.
totalSize
).
toEqual
(
127903
);
});
it
(
'
properly sum up pending folder sizes after adding
'
,
function
()
{
var
s
=
new
FileSummary
(
$container
);
s
.
setSummary
({
totalDirs
:
0
,
totalFiles
:
0
,
totalSize
:
0
});
s
.
add
({
type
:
'
dir
'
,
size
:
-
1
});
s
.
update
();
expect
(
$container
.
hasClass
(
'
hidden
'
)).
toEqual
(
false
);
expect
(
$container
.
find
(
'
.info
'
).
text
()).
toEqual
(
'
1 folder and 0 files
'
);
expect
(
$container
.
find
(
'
.filesize
'
).
text
()).
toEqual
(
'
Pending
'
);
expect
(
s
.
summary
.
totalDirs
).
toEqual
(
1
);
expect
(
s
.
summary
.
totalFiles
).
toEqual
(
0
);
expect
(
s
.
summary
.
totalSize
).
toEqual
(
0
);
});
it
(
'
properly sum up pending folder sizes after remove
'
,
function
()
{
var
s
=
new
FileSummary
(
$container
);
s
.
setSummary
({
totalDirs
:
0
,
totalFiles
:
0
,
totalSize
:
0
});
s
.
add
({
type
:
'
dir
'
,
size
:
-
1
});
s
.
remove
({
type
:
'
dir
'
,
size
:
-
1
});
s
.
update
();
expect
(
$container
.
hasClass
(
'
hidden
'
)).
toEqual
(
true
);
expect
(
$container
.
find
(
'
.info
'
).
text
()).
toEqual
(
'
0 folders and 0 files
'
);
expect
(
$container
.
find
(
'
.filesize
'
).
text
()).
toEqual
(
'
0 B
'
);
expect
(
s
.
summary
.
totalDirs
).
toEqual
(
0
);
expect
(
s
.
summary
.
totalFiles
).
toEqual
(
0
);
expect
(
s
.
summary
.
totalSize
).
toEqual
(
0
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment