Skip to content

Commit fa667c8

Browse files
committed
update login page
1 parent 29f4eb4 commit fa667c8

12 files changed

Lines changed: 189 additions & 92 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ A configuration example with explanation is avaiable in the `django/backend/conf
6060
DJANGO_DEBUG | Number | 0 | Whether or not Django starts in Debug Mode (0=Production, 1=Debug) |
6161
DJANGO_ALLOWED_HOSTS | String | | FQDN on which Django is listening. Only used in Production Mode |
6262
GOOGLE_API_KEY | String | | Google API Key to use [Google Map Javascript API](https://developers.google.com/maps/gmp-get-started) |
63+
APP_DISLCAIMER | String | | Disclaimer to display on the login page |
6364

django_app/backend/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
path('sites/', views.get_sites, name='get_sites'),
1212
#path('sites/derived/', views.get_site_derived, name='get_site_derived'),
1313
path('script', views.script, name="googlemaps"),
14-
path('gap', views.gap, name="gap")
14+
path('gap', views.gap, name="gap"),
15+
path('disclaimer', views.disclaimer, name="disclaimer")
1516
]
1617

django_app/backend/views.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,30 @@
77
import json
88
import time
99
import logging
10+
import os
1011

1112
from .mist_lib.devices import Devices
1213
from .mist_lib.sites import Sites
1314

1415
try:
1516
from .config import google_api_key
1617
except:
17-
import os
1818
google_api_key = os.environ.get("GOOGLE_API_KEY", default="")
19-
# if smtp_enabled:
20-
# smtp_config = {
21-
# "host": os.environ.get("MIST_SMTP_HOST", default=None),
22-
# "port": os.environ.get("MIST_SMTP_PORT", default=587),
23-
# "use_ssl": os.environ.get("MIST_SMTP_SSL", default=True),
24-
# "username": os.environ.get("MIST_SMTP_USER", default=None),
25-
# "password": os.environ.get("MIST_SMTP_PASSWORD", default=None),
26-
# "from_name": os.environ.get("MIST_SMTP_FROM_NAME", default="Wi-Fi Access"),
27-
# "from_email": os.environ.get("MIST_SMTP_FROM_EMAIL", default=None),
28-
# "logo_url": os.environ.get("MIST_SMTP_LOGO_URL", default="https://cdn.mist.com/wp-content/uploads/logo.png"),
29-
# "enable_qrcode": os.environ.get("MIST_SMTP_QRCODE", default=True)
30-
# }
31-
# else:
32-
# smtp_config = None
3319

34-
# try:
35-
# from .config import psk_config
36-
# except:
37-
# psk_config = {
38-
# "salt": os.environ.get("MIST_PSK_SALT", default="$2b$12$SIGWr574/7OggDO4BBJ1D."),
39-
# "length": int(os.environ.get("MIST_PSK_LENGTH", default=12))
40-
# }
41-
# psk_config["salt"] = str.encode(psk_config["salt"])
20+
try:
21+
from .config import app_disclaimer
22+
except:
23+
app_disclaimer = os.environ.get("APP_DISCLAIMER", default="")
4224

43-
# mist_smtp = Mist_SMTP(smtp_config)
25+
try:
26+
from .config import app_github_url
27+
except:
28+
app_github_url = os.environ.get("APP_GITHUB_URL", default="")
29+
30+
try:
31+
from .config import app_docker_url
32+
except:
33+
app_docker_url = os.environ.get("APP_DOCKER_URL", default="")
4434

4535

4636
##########
@@ -72,7 +62,6 @@ def update_device_settings(request):
7262
return Http404
7363

7464

75-
7665
##########
7766
# Switch Port
7867

@@ -82,7 +71,7 @@ def get_port_status(request):
8271
response = Devices().get_device_ports_status(request.body)
8372
return JsonResponse(status=response["status"], data=response["data"])
8473
else:
85-
return Http404
74+
return Http404
8675

8776
##########
8877
# Sites
@@ -178,6 +167,16 @@ def gap(request):
178167
return JsonResponse({"gap": google_api_key})
179168

180169

170+
@csrf_exempt
171+
def disclaimer(request):
172+
if request.method == "GET":
173+
return JsonResponse({
174+
"disclaimer": app_disclaimer,
175+
"github_url": app_github_url,
176+
"docker_url": app_docker_url
177+
})
178+
179+
181180
@csrf_exempt
182181
def script(request):
183182
if request.method == "GET":

django_app/mso/static/main-es2015.js

Lines changed: 48 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

django_app/mso/static/main-es2015.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

django_app/mso/static/main-es5.js

Lines changed: 70 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

django_app/mso/static/main-es5.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src_angular/src/app/login/login.component.css

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,24 @@ mat-card {
5959
align-self: center;
6060
}
6161

62-
.github-fork-me {
63-
position: absolute;
64-
right: 0;
65-
top: 0;
66-
z-index: 1000;
62+
.disclaimer {
63+
width: 50em;
64+
text-align: center;
65+
margin: auto;
66+
text-transform: uppercase;
67+
font-family: Roboto, "Helvetica Neue", sans-serif;
68+
font-weight: 100;
69+
font-size: smaller;
70+
}
71+
72+
.source {
73+
display: flex;
74+
flex-direction: row;
75+
align-items: center;
76+
justify-content: center;
77+
}
78+
79+
.source img {
80+
margin: 1em;
81+
height: 2em;
6782
}

src_angular/src/app/login/login.component.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ <h1>Access with Login/Password</h1>
4343
</div>
4444
<div fxLayout="column" class="login-form-or">
4545
<mat-divider [vertical]="true"></mat-divider>
46-
<button mat-fab color="accent" aria-label="OR" class="disable-click">
46+
<button mat-fab color="accent" aria-label="OR" class="disable-click" style="margin-bottom: 4em;">
4747
OR
4848
</button>
4949
<mat-divider [vertical]="true"></mat-divider>
5050
</div>
5151
<div fxLayout="column" class="login-form-inputs">
5252
<h1>Access with API Token</h1>
53-
<mat-form-field appearance="outline">
53+
<mat-form-field appearance="outline" style="padding: 0;">
5454
<mat-label>API Token</mat-label>
5555
<input type="text" matInput formControlName="token" (keydown.enter)="submitToken()" />
5656
</mat-form-field>
@@ -72,7 +72,12 @@ <h1>Access with API Token</h1>
7272
</form>
7373

7474
</mat-card>
75-
76-
<div *ngIf="show_github_fork_me" class="github-fork-me">
77-
<a class="github-fork-me" href="https://github.com/tmunzer/mist_claim_web_ui" target="_blank"><img loading="lazy" width="149" height="149" src="https://github.blog/wp-content/uploads/2008/12/forkme_right_red_aa0000.png?resize=149%2C149" class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a>
75+
<div class="disclaimer">
76+
<div>
77+
{{disclaimer}}
78+
</div>
79+
</div>
80+
<div class="source">
81+
<a *ngIf="github_url" href={{github_url}} target="_blank"><img src="assets/github.png"></a>
82+
<a *ngIf="docker_url" href={{docker_url}} target="_blank"><img src="assets/docker.png"></a>
7883
</div>

src_angular/src/app/login/login.component.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ export class LoginComponent implements OnInit {
2323
constructor(private _formBuilder: FormBuilder, private _http: HttpClient, private _router: Router, private _appService: ConnectorService, public _dialog: MatDialog, private _platformLocation: PlatformLocation
2424
) { }
2525

26+
27+
github_url: string;
28+
docker_url: string;
29+
disclaimer: string;
2630
host = null;
2731
headers = {};
2832
cookies = {};
2933
self = {};
30-
show_github_fork_me : boolean = false;
31-
hostnames_to_show_github_fork_me = [ "mso.mist-lab.fr"]
3234
loading: boolean;
3335
hosts = [
3436
{ value: 'api.mist.com', viewValue: 'US - manage.mist.com' },
@@ -53,9 +55,6 @@ export class LoginComponent implements OnInit {
5355

5456
//// INIT ////
5557
ngOnInit(): void {
56-
if (this.hostnames_to_show_github_fork_me.indexOf(this._platformLocation.hostname) >= 0){
57-
this.show_github_fork_me = true;
58-
}
5958
this.frmStepLogin = this._formBuilder.group({
6059
host: ['api.mist.com'],
6160
credentials: this._formBuilder.group({
@@ -68,6 +67,13 @@ export class LoginComponent implements OnInit {
6867
next: data => this._appService.googleApiKeySet(data.gap),
6968
error: error => console.error("Unable to load the Google API Key... Maps won't be available...")
7069
})
70+
this._http.get<any>("/api/disclaimer").subscribe({
71+
next: data => {
72+
if (data.disclaimer) this.disclaimer = data.disclaimer;
73+
if (data.github_url) this.github_url = data.github_url;
74+
if (data.docker_url) this.docker_url = data.docker_url;
75+
}
76+
})
7177
}
7278

7379
//// COMMON ////

0 commit comments

Comments
 (0)