mirror of
https://github.com/sismics/docs.git
synced 2024-12-22 19:33:47 +01:00
Closes #51: File sizes displayed in kB or MB
This commit is contained in:
parent
5f516047bd
commit
046984a447
18
docs-web/src/main/webapp/src/app/docs/filter/Filesize.js
Normal file
18
docs-web/src/main/webapp/src/app/docs/filter/Filesize.js
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Format file sizes.
|
||||
*/
|
||||
angular.module('docs').filter('filesize', function() {
|
||||
return function(text) {
|
||||
if (!text) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var size = parseInt(text);
|
||||
if (size > 1000000) { // 1MB
|
||||
return Math.round(size / 1000000) + 'MB';
|
||||
}
|
||||
return Math.round(size / 1000) + 'kB';
|
||||
}
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Filter converting new lines in <br />
|
||||
* Filter converting new lines in <br />.
|
||||
*/
|
||||
angular.module('docs').filter('newline', function() {
|
||||
return function(text) {
|
||||
@ -10,4 +10,4 @@ angular.module('docs').filter('newline', function() {
|
||||
}
|
||||
return text.replace(/\n/g, '<br/>');
|
||||
}
|
||||
})
|
||||
});
|
@ -10,4 +10,4 @@ angular.module('docs').filter('shorten', function() {
|
||||
}
|
||||
return text.substring(0, 1).toUpperCase();
|
||||
}
|
||||
})
|
||||
});
|
18
docs-web/src/main/webapp/src/app/share/filter/Filesize.js
Normal file
18
docs-web/src/main/webapp/src/app/share/filter/Filesize.js
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Format file sizes.
|
||||
*/
|
||||
angular.module('share').filter('filesize', function() {
|
||||
return function(text) {
|
||||
if (!text) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var size = parseInt(text);
|
||||
if (size > 1000000) { // 1MB
|
||||
return Math.round(size / 1000000) + 'MB';
|
||||
}
|
||||
return Math.round(size / 1000) + 'kB';
|
||||
}
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Filter converting new lines in <br />
|
||||
* Filter converting new lines in <br />.
|
||||
*/
|
||||
angular.module('share').filter('newline', function() {
|
||||
return function(text) {
|
||||
@ -10,4 +10,4 @@ angular.module('share').filter('newline', function() {
|
||||
}
|
||||
return text.replace(/\n/g, '<br/>');
|
||||
}
|
||||
})
|
||||
});
|
@ -63,6 +63,7 @@
|
||||
<script src="app/docs/service/Tag.js" type="text/javascript"></script>
|
||||
<script src="app/docs/filter/Newline.js" type="text/javascript"></script>
|
||||
<script src="app/docs/filter/Shorten.js" type="text/javascript"></script>
|
||||
<script src="app/docs/filter/Filesize.js" type="text/javascript"></script>
|
||||
<script src="app/docs/directive/File.js" type="text/javascript"></script>
|
||||
<script src="app/docs/directive/SelectTag.js" type="text/javascript"></script>
|
||||
<script src="app/docs/directive/AuditLog.js" type="text/javascript"></script>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2 text-center" ng-repeat="file in files">
|
||||
<div class="thumbnail" ng-class="{ 'thumbnail-checked': file.checked }" ng-if="file.id">
|
||||
<a ng-click="openFile(file)">
|
||||
<img class="thumbnail-file" ng-src="../api/file/{{ file.id }}/data?size=thumb" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
<img class="thumbnail-file" ng-src="../api/file/{{ file.id }}/data?size=thumb" tooltip="{{ file.mimetype }} | {{ file.size | filesize }}" tooltip-placement="top" />
|
||||
</a>
|
||||
<div class="caption pointer" ng-click="file.checked = !file.checked">
|
||||
<div class="pull-left">
|
||||
|
@ -6,7 +6,7 @@
|
||||
<div class="col-xs-6 col-sm-4 col-md-4 col-lg-3 text-center" ng-repeat="file in files">
|
||||
<div class="thumbnail" ng-if="file.id">
|
||||
<a ng-click="openFile(file)">
|
||||
<img class="thumbnail-file" ng-src="../api/file/{{ file.id }}/data?size=thumb" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
<img class="thumbnail-file" ng-src="../api/file/{{ file.id }}/data?size=thumb" tooltip="{{ file.mimetype }} | {{ file.size | filesize }}" tooltip-placement="top" />
|
||||
</a>
|
||||
<div class="caption" ng-show="document.writable">
|
||||
<div class="pull-left">
|
||||
|
@ -18,7 +18,9 @@
|
||||
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2 text-center" ng-repeat="file in files">
|
||||
<div class="thumbnail">
|
||||
<a ng-click="openFile(file)">
|
||||
<img class="thumbnail-file" ng-src="../api/file/{{ file.id }}/data?size=thumb&share={{ $stateParams.shareId }}" tooltip="{{ file.mimetype }}" tooltip-placement="top" />
|
||||
<img class="thumbnail-file"
|
||||
ng-src="../api/file/{{ file.id }}/data?size=thumb&share={{ $stateParams.shareId }}"
|
||||
tooltip="{{ file.mimetype }} | {{ file.size | filesize }}" tooltip-placement="top" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,6 +37,7 @@
|
||||
<script src="app/share/controller/FileView.js" type="text/javascript"></script>
|
||||
<script src="app/share/controller/FileModalView.js" type="text/javascript"></script>
|
||||
<script src="app/share/filter/Newline.js" type="text/javascript"></script>
|
||||
<script src="app/share/filter/Filesize.js" type="text/javascript"></script>
|
||||
<!-- endref -->
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user