Notes/src/public/app/widgets/sync_status.js

90 lines
2.9 KiB
JavaScript
Raw Normal View History

2021-03-20 00:00:49 +01:00
import BasicWidget from "./basic_widget.js";
const TPL = `
<div class="sync-status-wrapper">
<style>
.sync-status-wrapper {
height: 35px;
box-sizing: border-box;
border-bottom: 1px solid var(--main-border-color);
}
.sync-status {
height: 34px;
box-sizing: border-box;
}
.sync-status button {
height: 34px;
border: none;
font-size: 180%;
padding-left: 10px;
padding-right: 10px;
}
2021-03-21 00:01:28 +01:00
.sync-status button > span {
display: inline-block;
2021-03-20 00:00:49 +01:00
position: relative;
top: -5px;
}
.sync-status button:hover {
background-color: var(--hover-item-background-color);
}
.sync-status .dropdown-menu {
width: 20em;
}
</style>
<div class="sync-status">
<button type="button" class="btn btn-sm" title="Sync status">
2021-03-21 00:01:28 +01:00
<span class="sync-status-icon sync-status-online-with-changes" title="Connected to the sync server. There are some outstanding changes yet to be synced.">
<span class="bx bx-wifi"></span>
<span class="bx bxs-star" style="font-size: 40%; position: absolute; left: -3px; top: 20px;"></span>
</span>
<span class="sync-status-icon sync-status-online-no-changes" title="Connected to the sync server. All changes have been already synced.">
<span class="bx bx-wifi"></span>
</span>
<span class="sync-status-icon sync-status-offline-with-changes" title="Establishing the connection to the sync server was unsuccessful. There are some outstanding changes yet to be synced.">
<span class="bx bx-wifi-off"></span>
<span class="bx bxs-star" style="font-size: 40%; position: absolute; left: -3px; top: 20px;"></span>
</span>
<span class="sync-status-icon sync-status-offline-no-changes" title="Establishing the connection to the sync server was unsuccessful. All known changes have been synced.">
<span class="bx bx-wifi-off"></span>
</span>
<span class="sync-status-icon sync-status-in-progress" title="Sync with the server is in progress.">
<span class="bx bx-analyse bx-spin"></span>
</span>
2021-03-20 00:00:49 +01:00
</button>
</div>
</div>
`;
export default class SyncStatusWidget extends BasicWidget {
doRender() {
this.$widget = $(TPL);
2021-03-21 00:01:28 +01:00
this.$widget.hide();
2021-03-20 00:00:49 +01:00
this.overflowing();
}
2021-03-21 00:01:28 +01:00
syncInProgressEvent() {
this.showIcon('in-progress');
}
syncFinishedEvent() {
this.showIcon('online-no-changes');
}
syncFailedEvent() {
this.showIcon('offline-no-changes');
}
showIcon(className) {
this.$widget.show();
this.$widget.find('.sync-status-icon').hide();
this.$widget.find('.sync-status-' + className).show();
}
2021-03-20 00:00:49 +01:00
}