show session load view when picking a session

This commit is contained in:
Bruno Windels 2020-05-04 19:38:03 +02:00
parent 3dde23fc4b
commit 225fe873be
3 changed files with 14 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import {TemplateView} from "../general/TemplateView.js"; import {TemplateView} from "../general/TemplateView.js";
import {brawlGithubLink} from "./common.js"; import {brawlGithubLink} from "./common.js";
import {spinner} from "../common.js"; import {SessionLoadView} from "./SessionLoadView.js";
export class LoginView extends TemplateView { export class LoginView extends TemplateView {
render(t, vm) { render(t, vm) {
@ -25,11 +25,3 @@ export class LoginView extends TemplateView {
} }
} }
class SessionLoadView extends TemplateView {
render(t) {
return t.div({className: "SessionLoadView"}, [
spinner(t, {hidden: vm => !vm.loading}),
t.p(vm => vm.loadLabel)
]);
}
}

View File

@ -0,0 +1,11 @@
import {TemplateView} from "../general/TemplateView.js";
import {spinner} from "../common.js";
export class SessionLoadView extends TemplateView {
render(t) {
return t.div({className: "SessionLoadView"}, [
spinner(t, {hidden: vm => !vm.loading}),
t.p(vm => vm.loadLabel)
]);
}
}

View File

@ -1,6 +1,7 @@
import {ListView} from "../general/ListView.js"; import {ListView} from "../general/ListView.js";
import {TemplateView} from "../general/TemplateView.js"; import {TemplateView} from "../general/TemplateView.js";
import {brawlGithubLink} from "./common.js"; import {brawlGithubLink} from "./common.js";
import {SessionLoadView} from "./SessionLoadView.js";
function selectFileAsText(mimeType) { function selectFileAsText(mimeType) {
const input = document.createElement("input"); const input = document.createElement("input");
@ -85,6 +86,7 @@ export class SessionPickerView extends TemplateView {
t.view(sessionList), t.view(sessionList),
t.p(t.button({onClick: () => vm.cancel()}, ["Log in to a new session instead"])), t.p(t.button({onClick: () => vm.cancel()}, ["Log in to a new session instead"])),
t.p(t.button({onClick: async () => vm.import(await selectFileAsText("application/json"))}, "Import")), t.p(t.button({onClick: async () => vm.import(await selectFileAsText("application/json"))}, "Import")),
t.if(vm => vm.loadViewModel, vm => new SessionLoadView(vm.loadViewModel)),
t.p(brawlGithubLink(t)) t.p(brawlGithubLink(t))
]); ]);
} }