Update storage display when checking in

This commit is contained in:
gplane 2017-04-21 00:05:45 +08:00
parent e3e70a59e6
commit 3e27625064
3 changed files with 16 additions and 9 deletions

View File

@ -73,6 +73,7 @@ class UserController extends Controller
'errno' => 0,
'msg' => trans('user.sign-in-success', ['score' => $acuiredScore]),
'score' => $this->user->getScore(),
'storage' => $this->calculatePercentageUsed($this->user->getStorageUsed(), option('score_per_storage')),
'remaining_time' => round($this->user->getSignInRemainingTime() / 3600)
]);
} else {

View File

@ -554,6 +554,14 @@ function signIn() {
var dom = '<i class="fa fa-calendar-check-o"></i> &nbsp;' + trans('user.signInRemainingTime', { time: String(json.remaining_time) });
$('#sign-in-button').attr('disabled', 'disabled').html(dom);
if (json.storage.used > 1024) {
$('#user-storage').html(`<b>${Math.round(json.storage.used)}</b>/ ${Math.round(json.storage.total)} MB`);
} else {
$('#user-storage').html(`<b>${Math.round(json.storage.used)}</b>/ ${Math.round(json.storage.total)} KB`);
}
$('#user-storage-bar').css('width', `${json.storage.percentage}%`)
swal({
type: 'success',
html: json.msg

View File

@ -44,18 +44,16 @@
$total = $statistics['storage']['total'];
?>
@if ($used > 1024)
<span class="progress-number">
<b>{{ round($used / 1024, 1) }}</b>/ {{ is_string($total) ? $total : round($total / 1024, 1) }} MB
<span class="progress-number" id="user-storage">
@if ($used > 1024)
<b>{{ round($used / 1024, 1) }}</b>/ {{ is_string($total) ? $total : round($total / 1024, 1) }} MB
@else
<b>{{ $used }}</b>/ {{ $total }} KB
@endif
</span>
@else
<span class="progress-number">
<b>{{ $used }}</b>/ {{ $total }} KB
</span>
@endif
<div class="progress sm">
<div class="progress-bar progress-bar-yellow" style="width: {{ $statistics['storage']['percentage'] }}%"></div>
<div class="progress-bar progress-bar-yellow" id="user-storage-bar" style="width: {{ $statistics['storage']['percentage'] }}%"></div>
</div>
</div><!-- /.progress-group -->
</div><!-- /.col -->