2020-08-05 22:08:55 +05:30
|
|
|
/*
|
|
|
|
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-04-21 00:56:39 +05:30
|
|
|
import {SessionView} from "./session/SessionView.js";
|
|
|
|
import {LoginView} from "./login/LoginView.js";
|
2020-10-08 21:53:53 +05:30
|
|
|
import {SessionLoadView} from "./login/SessionLoadView.js";
|
2020-04-21 00:56:39 +05:30
|
|
|
import {SessionPickerView} from "./login/SessionPickerView.js";
|
2021-09-16 19:16:02 +05:30
|
|
|
import {TemplateView} from "./general/TemplateView";
|
2020-10-08 21:53:53 +05:30
|
|
|
import {StaticView} from "./general/StaticView.js";
|
2019-09-08 13:48:59 +05:30
|
|
|
|
2020-10-09 20:31:39 +05:30
|
|
|
export class RootView extends TemplateView {
|
|
|
|
render(t, vm) {
|
|
|
|
return t.mapView(vm => vm.activeSection, activeSection => {
|
|
|
|
switch (activeSection) {
|
|
|
|
case "error":
|
2020-10-14 14:56:39 +05:30
|
|
|
return new StaticView(t => {
|
|
|
|
return t.div({className: "StatusView"}, [
|
|
|
|
t.h1("Something went wrong"),
|
|
|
|
t.p(vm.errorText),
|
|
|
|
])
|
|
|
|
});
|
2020-10-09 20:31:39 +05:30
|
|
|
case "session":
|
|
|
|
return new SessionView(vm.sessionViewModel);
|
|
|
|
case "login":
|
|
|
|
return new LoginView(vm.loginViewModel);
|
|
|
|
case "picker":
|
|
|
|
return new SessionPickerView(vm.sessionPickerViewModel);
|
|
|
|
case "redirecting":
|
|
|
|
return new StaticView(t => t.p("Redirecting..."));
|
|
|
|
case "loading":
|
|
|
|
return new SessionLoadView(vm.sessionLoadViewModel);
|
|
|
|
default:
|
|
|
|
throw new Error(`Unknown section: ${vm.activeSection}`);
|
|
|
|
}
|
|
|
|
});
|
2019-09-08 13:48:59 +05:30
|
|
|
}
|
|
|
|
}
|