Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diescalo/sensor lab init #17

Open
wants to merge 2 commits into
base: xbee_sensor_lab
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added sensor_lab/login/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions sensor_lab/login/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022, Digi International Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from django.contrib import admin

# Register your models here.
19 changes: 19 additions & 0 deletions sensor_lab/login/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2022, Digi International Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from django.apps import AppConfig


class LoginConfig(AppConfig):
name = 'login'
30 changes: 30 additions & 0 deletions sensor_lab/login/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022, Digi International Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import json


class DeviceCloudUser(object):
def __init__(self, server: str, username: str, password: str):
self.server = server
self.username = username
self.password = password

def to_json(self):
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True,
indent=4)

@classmethod
def from_json(cls, data):
return cls(**data)
Empty file.
33 changes: 33 additions & 0 deletions sensor_lab/login/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2022, Digi International Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from django import forms
from django.contrib.auth.forms import AuthenticationForm

SERVER_CHOICES = (
("https://remotemanager.digi.com", "Official server"),
("https://test.idigi.com", "Test server")
)


class CustomAuthForm(AuthenticationForm):
server = forms.ChoiceField(choices=SERVER_CHOICES, label='')
username = forms.CharField(widget=forms.TextInput(
attrs={"class": "validate", "placeholder": "DRM Username",
"autocomplete": "username"}), label="")
password = forms.CharField(widget=forms.PasswordInput(
attrs={"placeholder": "DRM Password",
"autocomplete": "current-password"}), label="")

field_order = ["server", "username", "password"]
242 changes: 242 additions & 0 deletions sensor_lab/login/static/css/login.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/* GENERAL */

:root {
--digi-green: #84C361;
--digi-gray: #717174;
}

form {
margin-bottom: 20px;
}

/* STRUCTURE */

.wrapper {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
width: 100%;
min-height: 80%;
padding: 20px;
}

#formContent {
-webkit-border-radius: 10px 10px 10px 10px;
border-radius: 10px 10px 10px 10px;
background: #fff;
padding: 30px;
width: 90%;
max-width: 450px;
position: relative;
-webkit-box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3);
text-align: center;
}

/* FORM TYPOGRAPHY*/

.login-title {
margin: 10px 0px 20px 0px;
}

input[type=button], .login-button, input[type=reset] {
background-color: var(--digi-green);
border: none;
color: white;
padding: 12px 80px;
text-align: center;
text-decoration: none;
display: inline-block;
text-transform: uppercase;
font-size: 14px;
-webkit-box-shadow: 0 10px 30px 0 rgba(132, 195, 97, 0.4);
box-shadow: 0 10px 30px 0 rgba(132, 195, 97, 0.4);
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}

input[type=button]:hover, .login-button:hover, input[type=reset]:hover {
background-color: #88C361;
}

input[type=button]:active, .login-button:active, input[type=reset]:active {
-moz-transform: scale(0.95);
-webkit-transform: scale(0.95);
-o-transform: scale(0.95);
-ms-transform: scale(0.95);
transform: scale(0.95);
}

input[type=text], input[type=password], select {
background-color: #f6f6f6;
border: none;
color: #0d0d0d;
padding: 12px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 0px 0px 25px 0px;
width: 85%;
border: 2px solid #f6f6f6;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
}

input[type=text]:focus, input[type=password]:focus, select:focus {
background-color: #fff;
border-bottom: 2px solid var(--digi-green);
}

select {
-moz-appearance:none; /* Firefox */
-webkit-appearance:none; /* Safari and Chrome */
appearance:none;
text-align-last: center;
background-image: url("../images/combo_arrow_gray.png");
background-repeat: no-repeat, repeat;
background-position: right .7em top 50%;
background-size: .65em auto;
}

select:focus {
background-image: url("../images/combo_arrow_green.png");
}

.login-desc, .create-account {
font-size: 12px;
color: var(--digi-gray);
}

.errorlist {
font-size: 13px;
background-color: #FFDEDE;
border-radius: 10px;
padding: 10px;
color: #C40000;
border: 1px solid #C40000;
list-style-type: none;
}

/* ANIMATIONS */

/* Simple CSS3 Fade-in-down Animation */
.fadeInDown {
-webkit-animation-name: fadeInDown;
animation-name: fadeInDown;
-webkit-animation-duration: 500ms;
animation-duration: 500ms;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}

@-webkit-keyframes fadeInDown {
0% {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
100% {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}

@keyframes fadeInDown {
0% {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
100% {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}

/* Simple CSS3 Fade-in Animation */
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.fadeIn {
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;

-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;

-webkit-animation-duration:1s;
-moz-animation-duration:1s;
animation-duration:1s;
}

.fadeIn.first {
-webkit-animation-delay: 0.4s;
-moz-animation-delay: 0.4s;
animation-delay: 0.4s;
}

.fadeIn.second {
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
animation-delay: 0.6s;
}

.fadeIn.third {
-webkit-animation-delay: 0.8s;
-moz-animation-delay: 0.8s;
animation-delay: 0.8s;
}

.fadeIn.fourth {
-webkit-animation-delay: 1s;
-moz-animation-delay: 1s;
animation-delay: 1s;
}

/* Simple CSS3 Fade-in Animation */
.underlineHover:after {
display: block;
left: 0;
bottom: -10px;
width: 0;
height: 2px;
background-color: #56baed;
content: "";
transition: width 0.2s;
}

.underlineHover:hover {
color: #0d0d0d;
}

.underlineHover:hover:after{
width: 100%;
}

/* OTHERS */

*:focus {
outline: none;
}

#icon {
width:60%;
}
18 changes: 18 additions & 0 deletions sensor_lab/login/templates/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "base.html" %}
{% block title %}
Digi XBee Sensor Lab - Login
{% endblock %}
{% block page_content %}
<div class="wrapper fadeIn">
<div id="formContent">
<h4 class="login-title">Login</h4>
<p class="login-desc">Log in with your Digi Remote Manager account:</p>
<form method="POST">
{% csrf_token %}
{{ form.as_table }}
<button type="submit" class="login-button">Login</button>
</form>
<span class="create-account">Don't have a DRM account? <a href="https://myaccount.digi.com/" target="_blank">Create one</a></span>
</div>
</div>
{% endblock %}
14 changes: 14 additions & 0 deletions sensor_lab/login/templates/logout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}
Digi XBee Sensor Lab - Logout
{% endblock %}
{% block page_content %}
<div class="wrapper fadeIn">
<div id="formContent">
<h4 class="login-title">Logout</h4>
<p class="logout-text">
Didn't want to log out? <a href="{% url 'login' %}">Log in again.</a>
</p>
</div>
</div>
{% endblock %}
17 changes: 17 additions & 0 deletions sensor_lab/login/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022, Digi International Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from django.test import TestCase

# Create your tests here.
Loading