Skip to content

Commit

Permalink
change spaces to tabs and remove double rule from eslint covered by p…
Browse files Browse the repository at this point in the history
…rettier
  • Loading branch information
iOvergaard committed Jul 1, 2022
1 parent 1927277 commit 7f3422e
Show file tree
Hide file tree
Showing 65 changed files with 3,267 additions and 3,270 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
},
"rules": {
"no-var": "error",
"quotes": [
"error",
"single"
],
"import/no-unresolved": "error"
},
"settings": {
Expand All @@ -50,4 +46,4 @@
}
}
}
}
}
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"bracketSameLine": true
"bracketSameLine": true,
"useTabs": true
}
226 changes: 113 additions & 113 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,120 +14,120 @@ import { IRoute } from 'router-slot/model';

@customElement('umb-app')
export class UmbApp extends UmbContextProviderMixin(LitElement) {
static styles = css`
:host,
#router-slot {
display: block;
width: 100%;
height: 100vh;
}
`;

@state()
private _routes: IRoute[] = [
{
path: 'login',
component: () => import('./auth/login/login.element'),
},
{
path: 'install',
component: () => import('./installer/installer.element'),
},
{
path: 'upgrade',
component: () => import('./upgrader/upgrader.element'),
guards: [this._isAuthorizedGuard.bind(this)],
},
{
path: '**',
component: () => import('./backoffice/backoffice.element'),
guards: [this._isAuthorizedGuard.bind(this)],
},
];

private _extensionRegistry: UmbExtensionRegistry = new UmbExtensionRegistry();
private _iconRegistry: UUIIconRegistryEssential = new UUIIconRegistryEssential();
private _serverStatus: ServerStatus = 'running';

constructor() {
super();
this._setup();
}

private async _setup() {
this._iconRegistry.attach(this);
this.provideContext('umbExtensionRegistry', this._extensionRegistry);

await this._registerExtensionManifestsFromServer();
await this._registerInternalManifests();
await this._setInitStatus();
this._redirect();
}

private async _setInitStatus() {
try {
const { data } = await getServerStatus({});
this._serverStatus = data.serverStatus;
} catch (error) {
console.log(error);
}
}

private _redirect() {
switch (this._serverStatus) {
case 'must-install':
history.replaceState(null, '', '/install');
break;

case 'must-upgrade':
history.replaceState(null, '', '/upgrade');
break;

case 'running': {
const pathname =
window.location.pathname === '/install' || window.location.pathname === '/upgrade'
? '/'
: window.location.pathname;
history.replaceState(null, '', pathname);
break;
}
}
}

private _isAuthorized(): boolean {
return sessionStorage.getItem('is-authenticated') === 'true';
}

private _isAuthorizedGuard(): boolean {
if (this._isAuthorized()) {
return true;
}

history.replaceState(null, '', '/login');
return false;
}

private async _registerExtensionManifestsFromServer() {
// TODO: add schema and use fetcher
const res = await fetch('/umbraco/backoffice/manifests');
const { manifests } = await res.json();
manifests.forEach((manifest: UmbExtensionManifest) => this._extensionRegistry.register(manifest));
}

private async _registerInternalManifests() {
// TODO: where do we get these from?
internalManifests.forEach((manifest: UmbExtensionManifestCore) =>
this._extensionRegistry.register<UmbExtensionManifestCore>(manifest)
);
}

render() {
return html`<router-slot id="router-slot" .routes=${this._routes}></router-slot>`;
}
static styles = css`
:host,
#router-slot {
display: block;
width: 100%;
height: 100vh;
}
`;

@state()
private _routes: IRoute[] = [
{
path: 'login',
component: () => import('./auth/login/login.element'),
},
{
path: 'install',
component: () => import('./installer/installer.element'),
},
{
path: 'upgrade',
component: () => import('./upgrader/upgrader.element'),
guards: [this._isAuthorizedGuard.bind(this)],
},
{
path: '**',
component: () => import('./backoffice/backoffice.element'),
guards: [this._isAuthorizedGuard.bind(this)],
},
];

private _extensionRegistry: UmbExtensionRegistry = new UmbExtensionRegistry();
private _iconRegistry: UUIIconRegistryEssential = new UUIIconRegistryEssential();
private _serverStatus: ServerStatus = 'running';

constructor() {
super();
this._setup();
}

private async _setup() {
this._iconRegistry.attach(this);
this.provideContext('umbExtensionRegistry', this._extensionRegistry);

await this._registerExtensionManifestsFromServer();
await this._registerInternalManifests();
await this._setInitStatus();
this._redirect();
}

private async _setInitStatus() {
try {
const { data } = await getServerStatus({});
this._serverStatus = data.serverStatus;
} catch (error) {
console.log(error);
}
}

private _redirect() {
switch (this._serverStatus) {
case 'must-install':
history.replaceState(null, '', '/install');
break;

case 'must-upgrade':
history.replaceState(null, '', '/upgrade');
break;

case 'running': {
const pathname =
window.location.pathname === '/install' || window.location.pathname === '/upgrade'
? '/'
: window.location.pathname;
history.replaceState(null, '', pathname);
break;
}
}
}

private _isAuthorized(): boolean {
return sessionStorage.getItem('is-authenticated') === 'true';
}

private _isAuthorizedGuard(): boolean {
if (this._isAuthorized()) {
return true;
}

history.replaceState(null, '', '/login');
return false;
}

private async _registerExtensionManifestsFromServer() {
// TODO: add schema and use fetcher
const res = await fetch('/umbraco/backoffice/manifests');
const { manifests } = await res.json();
manifests.forEach((manifest: UmbExtensionManifest) => this._extensionRegistry.register(manifest));
}

private async _registerInternalManifests() {
// TODO: where do we get these from?
internalManifests.forEach((manifest: UmbExtensionManifestCore) =>
this._extensionRegistry.register<UmbExtensionManifestCore>(manifest)
);
}

render() {
return html`<router-slot id="router-slot" .routes=${this._routes}></router-slot>`;
}
}

declare global {
interface HTMLElementTagNameMap {
'umb-app': UmbApp;
}
interface HTMLElementTagNameMap {
'umb-app': UmbApp;
}
}
110 changes: 55 additions & 55 deletions src/auth/auth-layout.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,70 @@ import { customElement } from 'lit/decorators.js';

@customElement('umb-auth-layout')
export class UmbAuthLayout extends LitElement {
static styles: CSSResultGroup = [
css`
#background {
position: fixed;
overflow: hidden;
background-position: 50%;
background-repeat: no-repeat;
background-size: cover;
background-image: url('/login.jpeg');
width: 100vw;
height: 100vh;
}
static styles: CSSResultGroup = [
css`
#background {
position: fixed;
overflow: hidden;
background-position: 50%;
background-repeat: no-repeat;
background-size: cover;
background-image: url('/login.jpeg');
width: 100vw;
height: 100vh;
}
#logo {
position: fixed;
top: var(--uui-size-space-5);
left: var(--uui-size-space-5);
height: 30px;
}
#logo {
position: fixed;
top: var(--uui-size-space-5);
left: var(--uui-size-space-5);
height: 30px;
}
#logo img {
height: 100%;
}
#logo img {
height: 100%;
}
#container {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
}
#container {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
}
#box {
width: 500px;
padding: var(--uui-size-space-6) var(--uui-size-space-5) var(--uui-size-space-5) var(--uui-size-space-5);
}
#box {
width: 500px;
padding: var(--uui-size-space-6) var(--uui-size-space-5) var(--uui-size-space-5) var(--uui-size-space-5);
}
#email,
#password {
width: 100%;
}
`,
];
#email,
#password {
width: 100%;
}
`,
];

render() {
return html`
<div id="background"></div>
render() {
return html`
<div id="background"></div>
<div id="logo">
<img src="/umbraco_logo_white.svg" alt="Umbraco" />
</div>
<div id="logo">
<img src="/umbraco_logo_white.svg" alt="Umbraco" />
</div>
<div id="container">
<uui-box id="box">
<slot></slot>
</uui-box>
</div>
`;
}
<div id="container">
<uui-box id="box">
<slot></slot>
</uui-box>
</div>
`;
}
}

declare global {
interface HTMLElementTagNameMap {
'umb-auth-layout': UmbAuthLayout;
}
interface HTMLElementTagNameMap {
'umb-auth-layout': UmbAuthLayout;
}
}
Loading

0 comments on commit 7f3422e

Please sign in to comment.