85 lines
3.2 KiB
PHP
85 lines
3.2 KiB
PHP
@extends('layout.base')
|
|
|
|
@section('page_content')
|
|
<h1>Registered Mailboxes</h1>
|
|
<div id="mailboxes"></div>
|
|
@endsection
|
|
|
|
@push('page_scripts')
|
|
<script type="text/javascript">
|
|
const mailboxes = {
|
|
div_id: '',
|
|
mailboxes: [],
|
|
get: function() {
|
|
const uri = '/mailboxes/registered'
|
|
this.draw().loading()
|
|
return Send.get(uri).then((response, status, jqXHR) => {
|
|
if (parseInt(jqXHR.status / 100) !== 2 || jqXHR.status === 204) {
|
|
this.draw().empty()
|
|
return
|
|
}
|
|
if (jqXHR.status === 200) {
|
|
this.mailboxes = response.mailboxes
|
|
}
|
|
this.draw().list()
|
|
})
|
|
},
|
|
draw: function() {
|
|
return {
|
|
loading: () => {
|
|
const parent = $(this.div_id)
|
|
parent.html('')
|
|
parent.append(
|
|
$('<div></div>').addClass('ui segment').append(
|
|
$('<p></p>').html(' ')
|
|
).append(
|
|
$('<div></div>').addClass('ui active dimmer').append(
|
|
$('<div></div>').addClass('ui indeterminate elastic loader')
|
|
)
|
|
).append(
|
|
$('<p></p>').html(' ')
|
|
)
|
|
)
|
|
},
|
|
list: () => {
|
|
const parent = $(this.div_id)
|
|
parent.html('')
|
|
if (this.mailboxes.length === 0) {
|
|
this.draw().empty()
|
|
return
|
|
}
|
|
const list = $('<div></div>').addClass('ui selection divided list')
|
|
this.mailboxes.forEach(mb => {
|
|
let count = ''
|
|
if (typeof mb.last_checked !== 'undefined') {
|
|
count = ' (<i class="envelope outline icon"></i>' + mb.last_checked.count + ')'
|
|
}
|
|
list.append(
|
|
$('<div></div>').addClass('item').append(
|
|
$('<i></i>').addClass('inbox icon')
|
|
).append(
|
|
$('<div></div>').addClass('content').append(
|
|
$('<a></a>').addClass('header').attr('href', '{{$urls->base}}/emails/mailbox/' + mb.id).html(mb.name).append(count)
|
|
)
|
|
)
|
|
)
|
|
})
|
|
parent.append(list)
|
|
},
|
|
empty: () => {
|
|
const parent = $(this.div_id)
|
|
parent.html('')
|
|
parent.append(
|
|
$('<div></div>').addClass('ui message').html('No mailboxes registered.')
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$().ready(() => {
|
|
mailboxes.div_id = '#mailboxes'
|
|
mailboxes.get()
|
|
})
|
|
</script>
|
|
@endpush
|