Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions frontend/webEditor/src/loadingIndicator/loadingIndicator.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
color: white;

background-color: rgba(0, 0, 0, 0.8);

opacity: 0;
display: none;
}

#loading-indicator-wrapper.show {
display: flex;
animation: show 0s forwards;
animation-delay: 0.2s;
}

@keyframes show {
to {
opacity: 1;
}
}

#turning-circle {
Expand Down
27 changes: 8 additions & 19 deletions frontend/webEditor/src/loadingIndicator/loadingIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class LoadingIndicator extends AbstractUIExtension {
static readonly ID = "loading-indicator";
private loadingIndicatorWrapper: HTMLElement | undefined;
private loadingIndicatorText: HTMLElement | undefined;
private waitTimeout?: number;
private static VISIBLE_CLASS = "show";

id(): string {
return LoadingIndicator.ID;
Expand All @@ -16,7 +16,6 @@ export class LoadingIndicator extends AbstractUIExtension {
protected initializeContents(containerElement: HTMLElement): void {
this.loadingIndicatorWrapper = document.createElement("div");
this.loadingIndicatorWrapper.id = "loading-indicator-wrapper";
this.loadingIndicatorWrapper.style.display = "none";

const loadingIndicator = document.createElement("div");
loadingIndicator.id = "turning-circle";
Expand All @@ -30,28 +29,18 @@ export class LoadingIndicator extends AbstractUIExtension {
}

public showIndicator(text?: string) {
this.waitTimeout = setTimeout(() => {
if (!this.waitTimeout) {
return;
}
if (this.loadingIndicatorWrapper) {
this.loadingIndicatorWrapper.style.display = "flex";
if (this.loadingIndicatorText) {
this.loadingIndicatorText.innerText = text || "Loading...";
}
this.loadingIndicatorWrapper.focus();
this.waitTimeout = undefined;
if (this.loadingIndicatorWrapper) {
this.loadingIndicatorWrapper.classList.add(LoadingIndicator.VISIBLE_CLASS);
if (this.loadingIndicatorText) {
this.loadingIndicatorText.innerText = text || "Loading...";
}
}, 200);
this.loadingIndicatorWrapper.focus();
}
}

public hideIndicator() {
if (this.waitTimeout) {
clearTimeout(this.waitTimeout);
this.waitTimeout = undefined;
}
if (this.loadingIndicatorWrapper) {
this.loadingIndicatorWrapper.style.display = "none";
this.loadingIndicatorWrapper.classList.remove(LoadingIndicator.VISIBLE_CLASS);
}
}
}
10 changes: 5 additions & 5 deletions frontend/webEditor/src/serialize/loadJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export abstract class LoadJsonCommand extends Command {

this.file = await this.getFile(context).catch(() => undefined);
if (!this.file) {
this.loadingIndicator.hide();
this.loadingIndicator.hideIndicator();
this.actionDispatcher.dispatch(InitializeCanvasBoundsAction.create(this.oldRoot.canvasBounds));
return this.oldRoot;
}
Expand Down Expand Up @@ -108,13 +108,13 @@ export abstract class LoadJsonCommand extends Command {
this.oldFileName = this.fileName.getName();
this.fileName.setName(this.file.fileName);

this.loadingIndicator.hide();
this.loadingIndicator.hideIndicator();
return this.newRoot;
} catch (error) {
this.logger.error(this, "Error loading model", error);
this.newRoot = this.oldRoot;
this.actionDispatcher.dispatch(InitializeCanvasBoundsAction.create(this.oldRoot.canvasBounds));
this.loadingIndicator.hide();
this.loadingIndicator.hideIndicator();
return this.oldRoot;
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ export abstract class LoadJsonCommand extends Command {

this.fileName.setName(this.oldFileName ?? "diagram");

this.loadingIndicator.hide();
this.loadingIndicator.hideIndicator();
return this.oldRoot ?? context.modelFactory.createRoot(EMPTY_ROOT);
}

Expand Down Expand Up @@ -175,7 +175,7 @@ export abstract class LoadJsonCommand extends Command {

this.fileName.setName(this.file?.fileName ?? "diagram");

this.loadingIndicator.hide();
this.loadingIndicator.hideIndicator();
return this.newRoot ?? this.oldRoot ?? context.modelFactory.createRoot(EMPTY_ROOT);
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/webEditor/src/serialize/saveFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export abstract class SaveFileCommand extends SavedDiagramCreatorCommand {
this.downloadFile(file);
}

this.loadingIndicator.hide();
this.loadingIndicator.hideIndicator();
return context.root;
}
undo(context: CommandExecutionContext): CommandReturn {
Expand Down
Loading