going on forwar added form dire in templates for more precise type handlin like date string and so on defalut havlues fo select is also working now

master
Kerem Yollu 11 months ago
parent d25a310cab
commit 81b21bc69b

@ -0,0 +1,2 @@
name,device_id,serial_no,imsi,iccid,ip,port,user_id,owner_id,man_id,status_id,type_id,area_id
miniUni,24070580,24070576,901405710203483,89882280000107407542,10.128.24.42,50000,1,1,1,1,1,1
1 name device_id serial_no imsi iccid ip port user_id owner_id man_id status_id type_id area_id
2 miniUni 24070580 24070576 901405710203483 89882280000107407542 10.128.24.42 50000 1 1 1 1 1 1

@ -0,0 +1,5 @@
name,description
Roof,Placed on a roof
WashingMachine,Placed behind a washing machine
BoilerRoom,Placed on a the boiler room
Bathroom,Placed on a the bathroom
1 name description
2 Roof Placed on a roof
3 WashingMachine Placed behind a washing machine
4 BoilerRoom Placed on a the boiler room
5 Bathroom Placed on a the bathroom

@ -0,0 +1,5 @@
name,description
Active,Active an running
Ready,Registered and ready but not registered to the network
Offline,Went offline due to a reason like no more battery or
Deactivated,"Registration is overdue, and thus Deactivated by the operator"
1 name description
2 Active Active an running
3 Ready Registered and ready but not registered to the network
4 Offline Went offline due to a reason like no more battery or
5 Deactivated Registration is overdue, and thus Deactivated by the operator

@ -0,0 +1,2 @@
name,description
WaterDetector,Sensor for detection water levels.
1 name description
2 WaterDetector Sensor for detection water levels.

Binary file not shown.

@ -7,10 +7,10 @@ import minibase.blueprints.company.utils as companyUtils
class updateCompanyForm(FlaskForm): # Defines the form class to be used for the user update
name = StringField('Name', validators=[DataRequired(), Length(min=3, max=100)])
website = URLField('Website', validators=[DataRequired(), Length(min=3, max=100)])
street = StringField('Street', validators=[DataRequired()])
street_no = IntegerField('No', validators=[DataRequired()])
post_code = IntegerField('Post', validators=[DataRequired()])
city = SelectField('City', validators=[DataRequired()])
state = SelectField('State', validators=[DataRequired()])
country = SelectField('Country', validators=[DataRequired()])

@ -28,6 +28,14 @@ def edit_company(companyId):
if id:
form = updateCompanyForm()
company = companyUtils.queryById(companyId)
form.city.choices = [(row.id, row.name) for row in geoUtils.queryCiytNamesOfStateWithDefId(company.city_id, company.state_id)]
form.state.choices = [(row.id, row.name) for row in geoUtils.queryStateNamesOfCuntryWithDefId(company.state_id, company.country_id)]
form.country.choices = [(row.id, row.name) for row in geoUtils.queryCountryNamesWithDefault(company.country_id)]
form.industry.choices = [(row.id, row.name) for row in mainUtils.queryIndustryNamesWithDefault(company.industry_id)]
form.legal_entity.choices = [(row.id, row.name) for row in companyUtils.queryLegalEntityNames()]
form.type.choices = [(row.id, row.name) for row in companyUtils.queryTypeNames()]
form.relation.choices = [(row.id, row.name) for row in companyUtils.queryRelationNames()]
form.status.choices = [(row.id, row.name) for row in companyUtils.queryStatusNames()]
if form.validate_on_submit():
comp = Companies(
@ -53,22 +61,7 @@ def edit_company(companyId):
form.street.data = company.street
form.street_no.data = company.street_no
form.post_code.data = company.post_code
#form.city.choices = [(row.id, row.name) for row in geoUtils.queryCityNames()]
form.city.data = company.city
form.state.choices = [(row.id, row.name) for row in geoUtils.queryStateNamesOfCuntry(company.country.id)]
form.state.data = company.state
form.country.choices = [(row.id, row.name) for row in geoUtils.queryCountryNames()]
form.country.data = company.country
form.industry.choices = [(row.id, row.name) for row in mainUtils.queryIndustryNames()]
form.industry.data = company.industry
form.legal_entity.choices = [(row.id, row.name) for row in companyUtils.queryLegalEntityNames()]
form.legal_entity.data = company.legal_entity
form.type.choices = [(row.id, row.name) for row in companyUtils.queryTypeNames()]
form.type.data = company.type
form.relation.choices = [(row.id, row.name) for row in companyUtils.queryRelationNames()]
form.relation.data = company.relation
form.status.choices = [(row.id, row.name) for row in companyUtils.queryStatusNames()]
form.status.data = company.status
form.comment.data = company.comment
# This could be very interesting but neds more time to think !
#for field in form:
@ -76,11 +69,13 @@ def edit_company(companyId):
# attr = getattr(company, field.name)
# field.data = attr
image_file = url_for('static', filename='pics/' + companyUtils.queryImageById(companyId))
info = "kerem"
mylist = [['name','website','industry'], ['street','street_no','city','state','country'], 'timestamp']
return render_template('company/account.html',
theme=theme,
image_file=image_file,
info = info,
itemList=mylist,
form=form)
else:
flash('You need to select a company id', 'alarm')

@ -6,27 +6,26 @@
<div class="col-md-3 border-right">
<div class="d-flex flex-column align-items-center text-center p-3 py-5">
<img class="rounded-circle mt-4 border-info" width="150px" src="{{ image_file }}">
<h2 class="account-heading" style="color: {{ theme.orange }};">{{ current_user.username }}</h2>
<h5 class="account-heading" style="color: {{ theme.light_blue }};">{{ current_user.email_account }}</h5>
<h2 class="account-heading" style="color: {{ theme.orange }};">{{ form.name.data }}</h2>
<h3 class="account-heading" style="color: {{ theme.orange }};">{{ form.legal_entity.data }}</h2>
<h5 class="account-heading" style="color: {{ theme.light_blue }};">{{ form.website.data }}</h5>
<div class="p-3 py-5">
<h4 class="account-heading" style="color: {{ theme.yellow }};">Permission</h4>
<h5 class="account-heading" style="color: {{ theme.yellow }};">{{ current_user.role.name }}</h5>
<h4 class="account-heading" style="color: {{ theme.yellow }};">{{ form.type.data }}</h4>
</div>
</div>
</div>
<div class="col-md-5 border-right">
<div class="p-3 py-5">
<div class="col-md-4">
<div class="p-3 py-4">
{% include 'form.html' %}
</div>
</div>
<div class="col-md-4 rounded">
<div class="p-3 py-5">
{{ info }}
<div class="col-md-4">
<div class="p-3 py-4">
</div>
</div>
</div>
</div>
{% endblock content %}

@ -1,5 +1,5 @@
from minibase.app import db
from sqlalchemy import case
class table_printable:
def __init__(self, table, link_for_item, item_to_be_linked):
@ -19,15 +19,16 @@ class table_printable_paginate:
self.item_to_be_linked = item_to_be_linked
self.paginate = 1
def queryNameWithDefaultId(table,defId):
choices = table.query.order_by(case((table.id == defId, 0),else_=1),table.name.asc())
return choices
def dbAdd(dbClass):
db.session.add(dbClass)
def dbCommit():
db.session.commit()
def dbAddAndCommit(dbClass):
db.session.add(dbClass)
db.session.commit()

@ -1,20 +1,39 @@
from minibase.blueprints.geography.models import Country, City, State, Region, Subregion
import minibase.blueprints.database.utils as dbUtils
from sqlalchemy import case
def queryCountryNames():
choices = Country.query.order_by(Country.name.asc())
return choices
def queryCountryNamesWithDefault(defId):
choices = dbUtils.queryNameWithDefaultId(Country,defId)
return choices
def queryStateNames():
choices = State.query.order_by(State.name.asc())
return choices
def queryStateNamesOfCuntry(id):
choices = State.query.order_by(State.name.asc()).filter_by(country_id=id)
def queryStateNamesWithDefault(defId):
choices = dbUtils.queryNameWithDefaultId(State,defId)
return choices
def queryCityNames():
choices = City.query.order_by(City.name.asc())
return choices
def queryCityNamesWithDefault(defId):
choices = dbUtils.queryNameWithDefaultId(City,defId)
return choices
def queryCiytNamesOfStateWithDefId(defId, Filterid):
table=City
choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(state_id=Filterid)
return choices
def queryStateNamesOfCuntryWithDefId(defId, Filterid):
table=State
choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(country_id=Filterid)
return choices

@ -1,6 +1,15 @@
from minibase.blueprints.main.models import Industries
import minibase.blueprints.database.utils as dbUtils
from sqlalchemy import case
def queryIndustryNames():
choices = Industries.query.order_by(Industries.name.asc())
return choices
def queryIndustryNamesWithDefault(defId):
choices = dbUtils.queryNameWithDefaultId(Industries,defId)
return choices

@ -0,0 +1,117 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import StringField, PasswordField, SubmitField, BooleanField, URLField, IntegerField, DateField, SelectField
from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError
from iot.blueprints.sensor.models import nbiotDevice
from datetime import date
class updateNbioDeviceUpdateForm(FlaskForm): # Defines the form class to be used for the user update
name = StringField('Device Name', validators=[DataRequired(), Length(min=3, max=50)])
device_id = StringField('Device Id', validators=[DataRequired(), Length(min=3, max=50)])
serialNumber = StringField('Serial Number', validators=[DataRequired(), Length(min=3, max=50)])
imsi = StringField('Imsi No', validators=[DataRequired(), Length(min=10, max=50)])
iccid = StringField('Iccid No', validators=[DataRequired(), Length(min=10, max=100)])
ip = StringField('Ip (ipv4)', validators=[DataRequired(), Length(min=7, max=15)])
port = StringField('Port', validators=[DataRequired(), Length(min=3, max=10)])
registration_date = DateField('Registration Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
activation_date = DateField('Activation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
deactivation_date = DateField('Deactivation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
owner_id = SelectField('Owner', validators=[DataRequired()])
user_id = SelectField('User')
status_id = SelectField('Status', validators=[DataRequired()])
type_id = SelectField('Type', validators=[DataRequired()])
area_id = SelectField('Area', validators=[DataRequired()])
submit = SubmitField(f'Update')
def __init__(self, current_device_id, *args, **kwargs):
super().__init__(*args, **kwargs)
self.current_device = nbiotDevice.query.get(current_device_id)
def validate_name(self, input):
if input.data != self.current_device.name:
content = nbiotDevice.query.filter_by(name=input.data).first()
if content:
raise ValidationError('That device name is taken please choose another one')
def validate_device_id(self, input):
if input.data != self.current_device.device_id:
content = nbiotDevice.query.filter_by(device_id=input.data).first()
if content:
raise ValidationError('That device id is taken please choose another one')
def validate_imsi(self, input):
if input.data != self.current_device.imsi:
content = nbiotDevice.query.filter_by(imsi=input.data).first()
if content:
raise ValidationError('That IMSI id is taken please choose another one')
def validate_iccid(self, input):
if input.data != self.current_device.iccid:
content = nbiotDevice.query.filter_by(iccid=input.data).first()
if content:
raise ValidationError('That ICCID id is taken please choose another one')
def validate_ip(self, input):
if input.data != self.current_device.ip:
content = nbiotDevice.query.filter_by(ip=input.data).first()
if content:
raise ValidationError('That IP id is taken please choose another one')
class updateNbioDeviceAddForm(FlaskForm): # Defines the form class to be used for the user update
name = StringField('Device Name', validators=[DataRequired(), Length(min=3, max=50)])
device_id = StringField('Device Id', validators=[DataRequired(), Length(min=3, max=50)])
imsi = StringField('Imsi No', validators=[DataRequired(), Length(min=10, max=50)])
iccid = StringField('Iccid No', validators=[DataRequired(), Length(min=10, max=100)])
ip = StringField('Ip (ipv4)', validators=[Length(min=7, max=15)])
port = StringField('Port', validators=[Length(min=3, max=10)])
registration_date = DateField('Registration Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
activation_date = DateField('Activation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
deactivation_date = DateField('Deactivation Date', format='%Y-%m-%d', default=date.today, validators=[DataRequired()])
user_id = SelectField('Owner', validators=[DataRequired()])
status_id = SelectField('Status', validators=[DataRequired()])
type_id = SelectField('Type', validators=[DataRequired()])
area_id = SelectField('Area', validators=[DataRequired()])
submit = SubmitField(f'Add')
def validate_name(self, input):
content = nbiotDevice.query.filter_by(name=input.data).first()
if content:
raise ValidationError('That device name is taken please choose another one')
def validate_device_id(self, input):
content = nbiotDevice.query.filter_by(device_id=input.data).first()
if content:
raise ValidationError('That device id is taken please choose another one')
def validate_imsi(self, input):
content = nbiotDevice.query.filter_by(imsi=input.data).first()
if content:
raise ValidationError('That IMSI id is taken please choose another one')
def validate_iccid(self, input):
content = nbiotDevice.query.filter_by(iccid=input.data).first()
if content:
raise ValidationError('That ICCID id is taken please choose another one')
def validate_ip(self, input):
content = nbiotDevice.query.filter_by(ip=input.data).first()
if content:
raise ValidationError('That IP id is taken please choose another one')
class updateRoleForm(FlaskForm):
id = StringField('ID', render_kw={'disabled':''})
role = StringField('Role', validators=[DataRequired(), Length(min=4, max=20)])
description = StringField('Description', validators=[DataRequired(), Length(min=4, max=200)])
submit = SubmitField()
class updateRoleForm(FlaskForm):
id = StringField('ID', render_kw={'disabled':''})
role = StringField('Role', validators=[DataRequired(), Length(min=4, max=20)])
description = StringField('Description', validators=[DataRequired(), Length(min=4, max=200)])
submit = SubmitField()

@ -0,0 +1,61 @@
from iot.app import db
from datetime import datetime
class nbiotDevice(db.Model):
__tablename__ = 'nbiotDevice'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
device_id = db.Column(db.String(30), nullable=False)
imsi = db.Column(db.String(30), nullable=False)
iccid = db.Column(db.String(50), nullable=False)
ip = db.Column(db.String(20), nullable=True)
port = db.Column(db.String(20), nullable=True)
registration_date = db.Column(db.DateTime, nullable=True)
activation_date = db.Column(db.DateTime, nullable=True)
deactivation_date = db.Column(db.DateTime, nullable=True)
created = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
updated = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
owner_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True)
status_id = db.Column(db.Integer, db.ForeignKey('nbiotDeviceStatus.id'), nullable=False)
type_id = db.Column(db.Integer, db.ForeignKey('nbiotDeviceType.id'), nullable=False)
area_id = db.Column(db.Integer, db.ForeignKey('nbiotDeviceArea.id'), nullable=False)
owner = db.relationship('User', foreign_keys=[owner_id], backref='owned_devices')
user = db.relationship('User', foreign_keys=[user_id], backref='used_devices')
class nbiotDeviceStatus(db.Model):
__tablename__ = 'nbiotDeviceStatus'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
description = db.Column(db.String(300), nullable=False)
class nbiotDeviceType(db.Model):
__tablename__ = 'nbiotDeviceType'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
description = db.Column(db.String(300), nullable=False)
class nbiotDeviceArea(db.Model):
__tablename__ = 'nbiotDeviceArea'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
description = db.Column(db.String(300), nullable=False)
class waterDetector(db.Model):
__tablename__ = 'waterDetector'
id = db.Column(db.Integer, primary_key=True)
pins = db.Column(db.Integer, nullable=True)
alarms = db.Column(db.Integer, nullable=True)
voltage = db.Column(db.Integer, nullable=True)
signal = db.Column(db.Integer, nullable=True)
sleepTime = db.Column(db.Integer, nullable=True)
scanTime = db.Column(db.Integer, nullable=True)
holdTime = db.Column(db.Integer, nullable=True)
timeStamp = db.Column(db.DateTime, nullable=False)

@ -0,0 +1,133 @@
from flask import render_template, Blueprint, request, flash, redirect, url_for
import iot.theme as theme
from iot.blueprints.sensor.models import nbiotDevice
import iot.blueprints.sensor.utils as sensorUtils
from iot.blueprints.sensor.forms import updateNbioDeviceUpdateForm, updateNbioDeviceAddForm
import iot.blueprints.database.utils as dbUtils
import iot.blueprints.user.utils as userUtils
from iot.app import db
import json
import os
sensor = Blueprint('sensor', __name__, template_folder='templates')
DATA_FILE = 'data.json'
sensor.route('/callback', methods=['POST'])
def callback():
data = request.json
if not data:
return jsonify({"error": "Invalid data"}), 400
# Read existing data
if os.path.exists(DATA_FILE):
with open(DATA_FILE, 'r') as f:
stored_data = json.load(f)
else:
stored_data = []
# Append new data
stored_data.append(data)
# Write data back to file
with open(DATA_FILE, 'w') as f:
json.dump(stored_data, f, indent=4)
return 'Callback received', 200
@sensor.route('/data', methods=['GET'])
def get_data():
if os.path.exists(DATA_FILE):
with open(DATA_FILE, 'r') as f:
stored_data = json.load(f)
else:
stored_data = []
return jsonify(stored_data)
@sensor.route('/list', methods=['GET','POST'])
def list():
page=request.args.get('page', 1, type=int)
table=dbUtils.table_printable_paginate(nbiotDevice, page, 20, 'edit/', 'id')
return(render_template('view.html', theme=theme, table=table, title="Devices List"))
@sensor.route("/edit/<int:deviceId>", methods=['GET', 'POST'])
def edit(deviceId):
if deviceId:
device = nbiotDevice.query.get_or_404(deviceId)
form = updateNbioDeviceUpdateForm(current_device_id=device.id)
form.user_id.choices = [(row.id, row.username) for row in userUtils.queryUserChoices(device.user_id)]
form.owner_id.choices = [(row.id, row.username) for row in userUtils.queryUserChoices(device.user_id)]
form.status_id.choices = [(row.id, row.name) for row in sensorUtils.queryStatusChoices(device.status_id)]
form.type_id.choices = [(row.id, row.name) for row in sensorUtils.queryTypeChoices(device.type_id)]
form.area_id.choices = [(row.id, row.name) for row in sensorUtils.queryAreaChoices(device.area_id)]
if form.validate_on_submit():
device.name=form.name.data
device.device_id=form.device_id.data
device.imsi=form.imsi.data
device.iccid=form.iccid.data
device.ip=form.ip.data
device.port=form.port.data
device.registration_date=form.registration_date.data
device.activation_date=form.activation_date.data
device.deactivation_date=form.deactivation_date.data
device.owner_id=form.owner_id.data
device.user_id=form.user_id.data
device.status_id=form.status_id.data
device.type_id=form.type_id.data
device.area_id=form.area_id.data
db.session.commit()
flash('Device has been successfully updated', 'success')
return redirect(url_for('sensor.edit', deviceId=deviceId))
elif request.method == 'GET':
form.name.data = device.name
form.device_id.data = device.device_id
form.imsi.data = device.imsi
form.iccid.data = device.iccid
form.ip.data = device.ip
form.port.data = device.port
form.registration_date.data = device.registration_date
form.activation_date.data = device.activation_date
form.deactivation_date.data = device.deactivation_date
return render_template('sensor/account.html',
theme=theme,
form=form)
else:
flash('You need to select a Device id', 'alarm')
return redirect(url_for('sensor.list'))
@sensor.route('/add', methods=['GET', 'POST'])
def add():
form = updateNbioDeviceAddForm()
form.user_id.choices = [(row.id, row.username) for row in userUtils.queryUserChoices(1)]
form.status_id.choices = [(row.id, row.name) for row in sensorUtils.queryStatusChoices(1)]
form.type_id.choices = [(row.id, row.name) for row in sensorUtils.queryTypeChoices(1)]
form.area_id.choices = [(row.id, row.name) for row in sensorUtils.queryAreaChoices(1)]
if form.validate_on_submit():
dev = nbiotDevice(
name=form.name.data,
device_id=form.device_id.data,
imsi=form.imsi.data,
iccid=form.iccid.data,
ip=form.ip.data,
port=form.port.data,
registration_date=form.registration_date.data,
activation_date=form.activation_date.data,
deactivation_date=form.deactivation_date.data,
user_id=form.user_id.data,
status_id=form.status_id.data,
type_id=form.type_id.data,
area_id=form.area_id.data)
dbUtils.dbAddAndCommit(dev)
flash('Device has been successfully added', 'success')
return render_template('sensor/account.html',
theme=theme,
form=form)

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block content %}
<div class="container-fluid rounded-5 mt-5 mb-5" style="{{ theme.form.div_style }};">
<div class="row">
<div class="col-md-3 border-right">
<div class="d-flex flex-column align-items-center text-center p-3 py-5">
<h2 class="account-heading" style="color: {{ theme.orange }};">{{ current_user.username }}</h2>
<h5 class="account-heading" style="color: {{ theme.light_blue }};">{{ current_user.email_account }}</h5>
</div>
</div>
</div>
<div class="col-md-5 border-right">
<div class="p-3 py-5">
{% include 'form.html' %}
</div>
</div>
<div class="col-md-4 rounded">
<div class="p-3 py-5">
{{ info }}
</div>
</div>
</div>
</div>
{% endblock content %}

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block title %}iot{% endblock %}
{% block content %}
<h1>Hompage of iot</h1>
{{ info }}
{% endblock %}

@ -0,0 +1,22 @@
from iot.blueprints.sensor.models import nbiotDevice, nbiotDeviceStatus, nbiotDeviceType, nbiotDeviceArea
from sqlalchemy import case
def queryById(id):
return nbiotDevice.query.filter_by(id=id).first()
def queryStatusChoices(curretnId):
choices = nbiotDeviceStatus.query.order_by(case((nbiotDeviceStatus.id == curretnId, 0),else_=1),nbiotDeviceStatus.name.asc())
return choices
def queryTypeChoices(curretnId):
choices = nbiotDeviceType.query.order_by(case((nbiotDeviceType.id == curretnId, 0),else_=1),nbiotDeviceType.name.asc())
return choices
def queryAreaChoices(curretnId):
choices = nbiotDeviceArea.query.order_by(case((nbiotDeviceArea.id == curretnId, 0),else_=1),nbiotDeviceArea.name.asc())
return choices

@ -0,0 +1,29 @@
import os
def generate_blueprint_structure(root_dir):
blueprint = {}
# Traverse the directory structure starting from the root_dir
for root, dirs, files in os.walk(root_dir):
# Identify the relative path to the current directory
relative_path = os.path.relpath(root, root_dir)
# Skip the root directory itself
if relative_path == ".":
continue
# Split the relative path into its components
path_parts = relative_path.split(os.sep)
# Check if we're in a directory like user/templates/user/
if len(path_parts) >= 3:
if path_parts[0] == path_parts[2]:
blueprint_name = path_parts[2]
# Initialize the dictionary for the blueprint if it doesn't exist
if blueprint_name not in blueprint:
blueprint[blueprint_name] = {"directory": [], "html_files": []}
blueprint[blueprint_name]["directory"].append(blueprint_name)
# Process files, specifically .html files, and add them to the "html_files" list
for f in files:
if f.endswith(".html"):
blueprint[blueprint_name]["html_files"].append(os.path.splitext(f)[0])
return blueprint

@ -5,33 +5,12 @@
{% if item.id == 'submit' %}
{% elif item.id == 'csrf_token' %}
{% else %}
{% if item.type == 'BooleanField' %}
<br>
{{ item.label(class=theme.form.check_label_class, style=theme.form.check_label_style) }}
{% else %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
<!-- Checks if There are somer errors While Filling the form -->
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type == 'BooleanField' %}
{{ item(class=theme.form.check_class) }}
{% else %}
{{ item(class=theme.form.input_class) }}
{% endif %}
{% endif %}
{% include 'form/stringField.html' %}
{% include 'form/selectFieldVer.html' %}
{% include 'form/dateField.html' %}
{% include 'form/boolField.html' %}
{% endif %}
{% endfor %}
</fieldset>
<div class="form-groupe">
<br>
{{ form.submit(class=theme.form.submit_class, style=theme.form.submit_style) }}
<br>
</div>
<div>{% include 'form/submitField.html' %}</div>
</form>

@ -0,0 +1,15 @@
{% if item.type == 'BooleanField' %}
{{ item.label(class=theme.form.check_label_class, style=theme.form.check_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type == 'BooleanField' %}
{{ item(class=theme.form.check_class) }}
{% endif %}
{% endif %}

@ -0,0 +1,23 @@
{% for item in form %}
{% if item.id == 'submit' %}
{% elif item.id == 'csrf_token' %}
{% else %}
{% if item.type == 'BooleanField' %}
<br>
{{ item.label(class=theme.form.check_label_class, style=theme.form.check_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type == 'BooleanField' %}
<br>
{{ item(class=theme.form.check_class) }}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}

@ -0,0 +1,15 @@
{% if item.type in ['DateField', 'DateTimeField'] %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['DateField', 'DateTimeField'] %}
{{ item(class=theme.form.input_class, type=theme.form.date_type) }}
{% endif %}
{% endif %}

@ -0,0 +1,23 @@
{% for item in form %}
{% if item.id == 'submit' %}
{% elif item.id == 'csrf_token' %}
{% else %}
{% if item.type in ['DateField', 'DateTimeField'] %}
<br>
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['DateField', 'DateTimeField'] %}
<br>
{{ item(class=theme.form.input_class, type=theme.form.date_type) }}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}

@ -0,0 +1,6 @@
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>

@ -0,0 +1,15 @@
{% if item.type in ['IntegerField', 'DecimalField', 'FloatField'] %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['IntegerField', 'DecimalField', 'FloatField'] %}
{{ item(class=theme.form.input_class) }}
{% endif %}
{% endif %}

@ -0,0 +1,15 @@
{% if item.type in ['SelectField'] %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['SelectField'] %}
{{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }}
{% endif %}
{% endif %}

@ -0,0 +1,17 @@
{% if item.type in ['SelectField'] %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
<br>
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['SelectField'] %}
{{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }}
<br>
{% endif %}
{% endif %}

@ -0,0 +1,23 @@
{% for item in form %}
{% if item.id == 'submit' %}
{% elif item.id == 'csrf_token' %}
{% else %}
{% if item.type in ['SelectField'] %}
<br>
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['SelectField'] %}
<br>
{{ item(class=theme.form.select_class, type=theme.form.select_type, style=theme.form.select_style) }}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}

@ -0,0 +1,15 @@
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
{{ item(class=theme.form.input_class) }}
{% endif %}
{% endif %}

@ -0,0 +1,21 @@
{% for item in form %}
{% if item.id == 'submit' %}
{% elif item.id == 'csrf_token' %}
{% else %}
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
{{ item.label(class=theme.form.input_label_class, style=theme.form.input_label_style) }}
{% endif %}
{% if item.errors %}
{{ item(class=theme.form.input_error_class) }}
<div class="{{ theme.form.div_error_class }}">
{% for error in item.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{% if item.type in ['StringField', 'TextAreaField', 'PasswordField'] %}
{{ item(class=theme.form.input_class) }}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}

@ -0,0 +1,5 @@
<div class="form-groupe">
<br>
{{ form.submit(class=theme.form.submit_class, style=theme.form.submit_style) }}
<br>
</div>

@ -0,0 +1,34 @@
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
<fieldset class="form-group">
{% if itemList | length == 1 %}
<div class="col-md-3 rounded">
<div class="p-3 py-5">
{% include 'form.html' %}
</div>
</div>
{% else %}
{% for labelItems in itemList %}
<div class="col-md-3">
<div class="p-3 py-4">
{% for item in form %}
{% if item.id == 'submit' %}
{% elif item.id == 'csrf_token' %}
{% else %}
{% for label in labelItems %}
{% if label == item.name %}
{% include 'form/stringField.html' %}
{% include 'form/selectFieldVer.html' %}
{% include 'form/dateField.html' %}
{% include 'form/boolField.html' %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
{% endif %}
</fieldset>
<div>{% include 'form/submitField.html' %}</div>
</form>

@ -0,0 +1,10 @@
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<div>{% include 'form/stringFields.html' %}</div>
<div>{% include 'form/selectFields.html' %}</div>
<div>{% include 'form/dateFields.html' %}</div>
<div>{% include 'form/boolFields.html' %}</div>
</fieldset>
<div>{% include 'form/submitField.html' %}</div>
</form>

@ -14,7 +14,7 @@
{% if item.sublinks %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{{item.text}}
{{item.menuName}}
</a>
<ul class="dropdown-menu">
{% for sublink in item.sublinks %}
@ -30,7 +30,7 @@
</li>
{% elif item.url %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for(item.url) }}">{{item.text}}</a>
<a class="nav-link" href="{{ url_for(item.url) }}">{{item.menuName}}</a>
</li>
{% elif item.decoration %}
{% endif %}
@ -48,7 +48,7 @@
{% if item.sublinks %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{{item.text}}
{{item.menuName}}
</a>
<ul class="dropdown-menu">
{% for sublink in item.sublinks %}
@ -58,7 +58,7 @@
</li>
{% elif item.url %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for(item.url) }}">{{item.text}}</a>
<a class="nav-link" href="{{ url_for(item.url) }}">{{item.menuName}}</a>
</li>
{% endif %}
{% endif %}
@ -72,7 +72,7 @@
{% if item.sublinks %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{{item.text}}
{{item.menuName}}
</a>
<ul class="dropdown-menu">
{% for sublink in item.sublinks %}
@ -82,7 +82,7 @@
</li>
{% elif item.url %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for(item.url) }}">{{item.text}}</a>
<a class="nav-link" href="{{ url_for(item.url) }}">{{item.menuName}}</a>
</li>
{% endif %}
{% endif %}

@ -1,3 +1,4 @@
from minibase.menuDictionary import generate_blueprint_structure
# Color pallette of kynsight
black = "#191717"
@ -11,25 +12,35 @@ yellow = "#f8cb66"
class maineTheme:
div_style = "background-color:" + yellow
class form:
div_style = "background-color:" + black + "; " +" width:98%;"
div_class = "container rounded p-4 py-4"
div_error_class = "invalid-feedback"
input_label_class = "col-form-label"
input_label_style = "color:" + orange + "; font-size: 14pt; font-weight: bold;"
input_class = "form-control form-control-lg"
input_error_class = input_class+ " is-invalid"
check_label_class = "form-check-label"
check_label_style = input_label_style
check_label_style = "input_label_style"
check_class = "form-check-input"
submit_class = "btn btn-outline-info mb-2 mt-2"
submit_style = ""
input_error_class = "form-control form-control-lg is-invalid"
input_class = "form-control form-control-lg"
date_type = "date"
select_class = "btn btn-lg dropdown-toggle"
select_style = "color:" + black + "; font-size: 14pt; background-color: " + white + ";"
class menu:
menuDict = generate_blueprint_structure('minibase/blueprints')
navbar_items_navigation = [
{"text": "Relations",
{"menuName":"Company",
"sublinks": [
{"text": "Companies", "url": "main.index"},
{"text": "List", "url": "company.list"},
{"text": "Presons", "url": "main.index"},
{"decoration": "line"},
{"text": "Create Company", "url": "main.index"},
@ -41,20 +52,20 @@ class menu:
]
navbar_items_user = [
{"text": "Login", "url": "user.login", "show":"not_logged"},
{"text": "Register", "url": "user.register", "show":"not_logged"},
{"text": "Account", "url": "user.account", "show":"logged"},
{"text": "Logout", "url": "user.logout", "show":"logged"}
{"menuName": "Login", "url": "user.login", "show":"not_logged"},
{"menuName": "Register", "url": "user.register", "show":"not_logged"},
{"menuName": "Account", "url": "user.account", "show":"logged"},
{"menuName": "Logout", "url": "user.logout", "show":"logged"}
]
navbar_items_admin = [
{"text": "Admin",
{"menuName": "Admin",
"sublinks": [
{"text": "Create User", "url": "main.index"},
{"text": "Delete User", "url": "main.index"},
{"text": "Update User", "url": "main.index"},
],},
{"text": "Database",
{"menuName": "Database",
"sublinks": [
{"text": "Tables", "url": "main.index"},
{"text": "Entires", "url": "main.index"},

Loading…
Cancel
Save