Skip to content

Commit

Permalink
update login page
Browse files Browse the repository at this point in the history
  • Loading branch information
tmunzer committed Jul 13, 2021
1 parent 29f4eb4 commit fa667c8
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 92 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ A configuration example with explanation is avaiable in the `django/backend/conf
DJANGO_DEBUG | Number | 0 | Whether or not Django starts in Debug Mode (0=Production, 1=Debug) |
DJANGO_ALLOWED_HOSTS | String | | FQDN on which Django is listening. Only used in Production Mode |
GOOGLE_API_KEY | String | | Google API Key to use [Google Map Javascript API](https://developers.google.com/maps/gmp-get-started) |
APP_DISLCAIMER | String | | Disclaimer to display on the login page |

3 changes: 2 additions & 1 deletion django_app/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
path('sites/', views.get_sites, name='get_sites'),
#path('sites/derived/', views.get_site_derived, name='get_site_derived'),
path('script', views.script, name="googlemaps"),
path('gap', views.gap, name="gap")
path('gap', views.gap, name="gap"),
path('disclaimer', views.disclaimer, name="disclaimer")
]

51 changes: 25 additions & 26 deletions django_app/backend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,30 @@
import json
import time
import logging
import os

from .mist_lib.devices import Devices
from .mist_lib.sites import Sites

try:
from .config import google_api_key
except:
import os
google_api_key = os.environ.get("GOOGLE_API_KEY", default="")
# if smtp_enabled:
# smtp_config = {
# "host": os.environ.get("MIST_SMTP_HOST", default=None),
# "port": os.environ.get("MIST_SMTP_PORT", default=587),
# "use_ssl": os.environ.get("MIST_SMTP_SSL", default=True),
# "username": os.environ.get("MIST_SMTP_USER", default=None),
# "password": os.environ.get("MIST_SMTP_PASSWORD", default=None),
# "from_name": os.environ.get("MIST_SMTP_FROM_NAME", default="Wi-Fi Access"),
# "from_email": os.environ.get("MIST_SMTP_FROM_EMAIL", default=None),
# "logo_url": os.environ.get("MIST_SMTP_LOGO_URL", default="https://cdn.mist.com/wp-content/uploads/logo.png"),
# "enable_qrcode": os.environ.get("MIST_SMTP_QRCODE", default=True)
# }
# else:
# smtp_config = None

# try:
# from .config import psk_config
# except:
# psk_config = {
# "salt": os.environ.get("MIST_PSK_SALT", default="$2b$12$SIGWr574/7OggDO4BBJ1D."),
# "length": int(os.environ.get("MIST_PSK_LENGTH", default=12))
# }
# psk_config["salt"] = str.encode(psk_config["salt"])
try:
from .config import app_disclaimer
except:
app_disclaimer = os.environ.get("APP_DISCLAIMER", default="")

# mist_smtp = Mist_SMTP(smtp_config)
try:
from .config import app_github_url
except:
app_github_url = os.environ.get("APP_GITHUB_URL", default="")

try:
from .config import app_docker_url
except:
app_docker_url = os.environ.get("APP_DOCKER_URL", default="")


##########
Expand Down Expand Up @@ -72,7 +62,6 @@ def update_device_settings(request):
return Http404



##########
# Switch Port

Expand All @@ -82,7 +71,7 @@ def get_port_status(request):
response = Devices().get_device_ports_status(request.body)
return JsonResponse(status=response["status"], data=response["data"])
else:
return Http404
return Http404

##########
# Sites
Expand Down Expand Up @@ -178,6 +167,16 @@ def gap(request):
return JsonResponse({"gap": google_api_key})


@csrf_exempt
def disclaimer(request):
if request.method == "GET":
return JsonResponse({
"disclaimer": app_disclaimer,
"github_url": app_github_url,
"docker_url": app_docker_url
})


@csrf_exempt
def script(request):
if request.method == "GET":
Expand Down
70 changes: 48 additions & 22 deletions django_app/mso/static/main-es2015.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion django_app/mso/static/main-es2015.js.map

Large diffs are not rendered by default.

96 changes: 70 additions & 26 deletions django_app/mso/static/main-es5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion django_app/mso/static/main-es5.js.map

Large diffs are not rendered by default.

25 changes: 20 additions & 5 deletions src_angular/src/app/login/login.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,24 @@ mat-card {
align-self: center;
}

.github-fork-me {
position: absolute;
right: 0;
top: 0;
z-index: 1000;
.disclaimer {
width: 50em;
text-align: center;
margin: auto;
text-transform: uppercase;
font-family: Roboto, "Helvetica Neue", sans-serif;
font-weight: 100;
font-size: smaller;
}

.source {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}

.source img {
margin: 1em;
height: 2em;
}
15 changes: 10 additions & 5 deletions src_angular/src/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ <h1>Access with Login/Password</h1>
</div>
<div fxLayout="column" class="login-form-or">
<mat-divider [vertical]="true"></mat-divider>
<button mat-fab color="accent" aria-label="OR" class="disable-click">
<button mat-fab color="accent" aria-label="OR" class="disable-click" style="margin-bottom: 4em;">
OR
</button>
<mat-divider [vertical]="true"></mat-divider>
</div>
<div fxLayout="column" class="login-form-inputs">
<h1>Access with API Token</h1>
<mat-form-field appearance="outline">
<mat-form-field appearance="outline" style="padding: 0;">
<mat-label>API Token</mat-label>
<input type="text" matInput formControlName="token" (keydown.enter)="submitToken()" />
</mat-form-field>
Expand All @@ -72,7 +72,12 @@ <h1>Access with API Token</h1>
</form>

</mat-card>

<div *ngIf="show_github_fork_me" class="github-fork-me">
<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>
<div class="disclaimer">
<div>
{{disclaimer}}
</div>
</div>
<div class="source">
<a *ngIf="github_url" href={{github_url}} target="_blank"><img src="assets/github.png"></a>
<a *ngIf="docker_url" href={{docker_url}} target="_blank"><img src="assets/docker.png"></a>
</div>
16 changes: 11 additions & 5 deletions src_angular/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export class LoginComponent implements OnInit {
constructor(private _formBuilder: FormBuilder, private _http: HttpClient, private _router: Router, private _appService: ConnectorService, public _dialog: MatDialog, private _platformLocation: PlatformLocation
) { }


github_url: string;
docker_url: string;
disclaimer: string;
host = null;
headers = {};
cookies = {};
self = {};
show_github_fork_me : boolean = false;
hostnames_to_show_github_fork_me = [ "mso.mist-lab.fr"]
loading: boolean;
hosts = [
{ value: 'api.mist.com', viewValue: 'US - manage.mist.com' },
Expand All @@ -53,9 +55,6 @@ export class LoginComponent implements OnInit {

//// INIT ////
ngOnInit(): void {
if (this.hostnames_to_show_github_fork_me.indexOf(this._platformLocation.hostname) >= 0){
this.show_github_fork_me = true;
}
this.frmStepLogin = this._formBuilder.group({
host: ['api.mist.com'],
credentials: this._formBuilder.group({
Expand All @@ -68,6 +67,13 @@ export class LoginComponent implements OnInit {
next: data => this._appService.googleApiKeySet(data.gap),
error: error => console.error("Unable to load the Google API Key... Maps won't be available...")
})
this._http.get<any>("/api/disclaimer").subscribe({
next: data => {
if (data.disclaimer) this.disclaimer = data.disclaimer;
if (data.github_url) this.github_url = data.github_url;
if (data.docker_url) this.docker_url = data.docker_url;
}
})
}

//// COMMON ////
Expand Down
Binary file added src_angular/src/assets/docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src_angular/src/assets/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa667c8

Please sign in to comment.