Skip to content

Commit

Permalink
#6423 SyncIndicatorWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
piorek committed Jan 29, 2018
1 parent e93860b commit 0922ce0
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions js/lab/src/tree/JVMOptions/SyncIndicatorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as $ from "jquery";
import { Widget } from "@phosphor/widgets";

export default class SyncIndicatorWidget extends Widget {
export class SyncIndicatorWidget extends Widget {

public readonly HTML_ELEMENT_TEMPLATE = `
<style>
Expand All @@ -34,13 +34,51 @@ export default class SyncIndicatorWidget extends Widget {
<div id="errors" style="color: red"></div>
`;

private $savingEl;
private $savedEl;
private $errorsEl;
private $resultEl;

public get $node() {
return $(this.node);
}

constructor() {
super();
this.createContent();

$(this.HTML_ELEMENT_TEMPLATE).appendTo(this.node);

this.$savingEl = this.$node.find('#sync_indicator .saving');
this.$savedEl = this.$node.find('#sync_indicator .saved');
this.$errorsEl = this.$node.find('#errors');
this.$resultEl = this.$node.find('#result');
}

public onSyncStart() {
this.$savingEl.removeClass('hidden');
this.$savedEl.addClass('hidden');
}

public onSyncEnd() {
this.$savingEl.addClass('hidden');
this.$savedEl.removeClass('hidden');
}

public onError(error: Error) {
this.$errorsEl
.empty()
.append($('<span>', {
text: error.message
}));
}

public clearErrors() {
this.$errorsEl.empty();
}

private createContent() {
$(this.HTML_ELEMENT_TEMPLATE)
.appendTo(this.node);
public showResult(result: string) {
this.$resultEl
.empty()
.text(result);
}
}

0 comments on commit 0922ce0

Please sign in to comment.