Move <app-root> back to index.html

This commit is contained in:
Vinicius Fortuna 2020-04-27 15:47:10 -04:00
parent 226bd24614
commit 492e59c7fc
3 changed files with 17 additions and 16 deletions

View file

@ -36,5 +36,7 @@
<title>Outline Manager</title>
</head>
<body></body>
<body>
<app-root id="appRoot"></app-root>
</body>
</html>

View file

@ -594,15 +594,8 @@
};
}
ready() {
super.ready();
const messagesUrl = `/messages/${this.language}.json`;
this.loadResources(messagesUrl, this.language);
const langDir = this.getAttribute("dir");
if (langDir === "rtl") {
this.$.appDrawer.align = "right";
this.$.sideBar.align = "right";
}
constructor() {
super();
this.addEventListener("RegionSelected", this.handleRegionSelected);
this.addEventListener("SetUpGenericCloudProviderRequested", this.handleSetUpGenericCloudProviderRequested);
this.addEventListener("SetUpAwsRequested", this.handleSetUpAwsRequested);
@ -610,6 +603,16 @@
this.addEventListener("ManualServerEntryCancelled", this.handleManualCancelled);
}
setLanguage(newLanguage, langDir) {
const messagesUrl = `/messages/${newLanguage}.json`;
this.loadResources(messagesUrl, newLanguage);
if (langDir === "rtl") {
this.$.appDrawer.align = "right";
this.$.sideBar.align = "right";
}
this.language = newLanguage;
}
showIntro() {
this.maybeCloseDrawer();
this.selectedServer = undefined;

View file

@ -107,14 +107,10 @@ document.addEventListener('WebComponentsReady', () => {
const language = getLanguageToUse();
const languageDirection = SUPPORTED_LANGUAGES[language.string()].dir;
document.documentElement.setAttribute('dir', languageDirection);
const appRootEl = document.createElement('app-root');
appRootEl.setAttribute('language', language.string());
appRootEl.setAttribute('dir', languageDirection);
document.body.appendChild(appRootEl);
// NOTE: this cast is safe and allows us to leverage Polymer typings since we haven't migrated to
// Polymer 3, which adds typescript support.
// tslint:disable-next-line:no-any
const appRoot = appRootEl as unknown as polymer.Base;
const appRoot = document.getElementById('appRoot') as unknown as polymer.Base;
appRoot.setLanguage(language.string(), languageDirection);
new App(
appRoot, version, digitalocean_api.createDigitalOceanSession,
digitalOceanServerRepositoryFactory, new ManualServerRepository('manualServers'),