This commit is contained in:
Eugene Pankov 2021-07-27 22:29:29 +02:00
parent dbf1ec5f3c
commit b3bb9fdd40
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
5 changed files with 12 additions and 3 deletions

View File

@ -162,6 +162,7 @@ class LogoutView(APIView):
class InstanceInfoSerializer(Serializer): class InstanceInfoSerializer(Serializer):
login_enabled = fields.BooleanField() login_enabled = fields.BooleanField()
homepage_enabled = fields.BooleanField()
class InstanceInfoViewSet(RetrieveModelMixin, GenericViewSet): class InstanceInfoViewSet(RetrieveModelMixin, GenericViewSet):
@ -171,6 +172,7 @@ class InstanceInfoViewSet(RetrieveModelMixin, GenericViewSet):
def get_object(self): def get_object(self):
return { return {
'login_enabled': settings.ENABLE_LOGIN, 'login_enabled': settings.ENABLE_LOGIN,
'homepage_enabled': settings.ENABLE_HOMEPAGE,
} }

View File

@ -194,6 +194,7 @@ for key in [
'ENABLE_LOGIN', 'ENABLE_LOGIN',
'GA_ID', 'GA_ID',
'GA_DOMAIN', 'GA_DOMAIN',
'ENABLE_HOMEPAGE',
]: ]:
globals()[key] = os.getenv(key) globals()[key] = os.getenv(key)
@ -206,6 +207,7 @@ for key in [
for key in [ for key in [
'ENABLE_LOGIN', 'ENABLE_LOGIN',
'ENABLE_HOMEPAGE',
]: ]:
globals()[key] = bool(globals()[key]) if globals()[key] else None globals()[key] = bool(globals()[key]) if globals()[key] else None

View File

@ -28,6 +28,7 @@ export interface Version {
export interface InstanceInfo { export interface InstanceInfo {
login_enabled: boolean login_enabled: boolean
homepage_enabled: boolean
} }
export interface Gateway { export interface Gateway {

View File

@ -112,6 +112,6 @@ strong {
img { img {
min-width: 100px; min-width: 100px;
max-width: 100%; max-width: 100%;
width: 100%; width: 100%;
} }
} }

View File

@ -5,7 +5,7 @@ import { Component, ElementRef, ViewChild } from '@angular/core'
import { InstanceInfo, Version } from '../api' import { InstanceInfo, Version } from '../api'
import { faCoffee, faDownload, faSignInAlt } from '@fortawesome/free-solid-svg-icons' import { faCoffee, faDownload, faSignInAlt } from '@fortawesome/free-solid-svg-icons'
import { faGithub } from '@fortawesome/free-brands-svg-icons' import { faGithub } from '@fortawesome/free-brands-svg-icons'
import { ActivatedRoute } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { CommonService } from '../services/common.service' import { CommonService } from '../services/common.service'
@ -101,9 +101,13 @@ export class HomeComponent {
private http: HttpClient, private http: HttpClient,
private commonService: CommonService, private commonService: CommonService,
route: ActivatedRoute, route: ActivatedRoute,
router: Router,
) { ) {
window.addEventListener('message', this.connectorRequestHandler) window.addEventListener('message', this.connectorRequestHandler)
this.instanceInfo = route.snapshot.data.instanceInfo this.instanceInfo = route.snapshot.data.instanceInfo
if (!this.instanceInfo.homepage_enabled) {
router.navigate(['/app'])
}
} }
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types