add datastorage placeholders
This commit is contained in:
parent
a38c990412
commit
2543f7f761
|
@ -55,9 +55,11 @@ from ereuse_devicehub.resources.device.models import (
|
||||||
DataStorage,
|
DataStorage,
|
||||||
Desktop,
|
Desktop,
|
||||||
Device,
|
Device,
|
||||||
|
HardDrive,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
Laptop,
|
Laptop,
|
||||||
MemoryCardReader,
|
MemoryCardReader,
|
||||||
|
Mobile,
|
||||||
Monitor,
|
Monitor,
|
||||||
Mouse,
|
Mouse,
|
||||||
Other,
|
Other,
|
||||||
|
@ -65,6 +67,7 @@ from ereuse_devicehub.resources.device.models import (
|
||||||
Projector,
|
Projector,
|
||||||
Server,
|
Server,
|
||||||
Smartphone,
|
Smartphone,
|
||||||
|
SolidStateDrive,
|
||||||
Tablet,
|
Tablet,
|
||||||
TelevisionSet,
|
TelevisionSet,
|
||||||
)
|
)
|
||||||
|
@ -100,7 +103,7 @@ DEVICES = {
|
||||||
"Drives & Storage": [
|
"Drives & Storage": [
|
||||||
"All DataStorage",
|
"All DataStorage",
|
||||||
"HardDrive",
|
"HardDrive",
|
||||||
"SolidStageDrive",
|
"SolidStateDrive",
|
||||||
],
|
],
|
||||||
"Accessories": [
|
"Accessories": [
|
||||||
"All Accessories",
|
"All Accessories",
|
||||||
|
@ -128,6 +131,7 @@ MOBILE = ["Mobile", "Tablet", "Smartphone", "Cellphone"]
|
||||||
STORAGE = ["HardDrive", "SolidStateDrive"]
|
STORAGE = ["HardDrive", "SolidStateDrive"]
|
||||||
ACCESSORIES = ["Mouse", "MemoryCardReader", "SAI", "Keyboard"]
|
ACCESSORIES = ["Mouse", "MemoryCardReader", "SAI", "Keyboard"]
|
||||||
OTHERS = ["Other"]
|
OTHERS = ["Other"]
|
||||||
|
DATASTORAGE = ['HardDrive', 'SolidStateDrive']
|
||||||
|
|
||||||
|
|
||||||
class AdvancedSearchForm(FlaskForm):
|
class AdvancedSearchForm(FlaskForm):
|
||||||
|
@ -202,7 +206,7 @@ class FilterForm(FlaskForm):
|
||||||
|
|
||||||
# Generic Filters
|
# Generic Filters
|
||||||
if "All Devices" == self.device_type:
|
if "All Devices" == self.device_type:
|
||||||
filter_type = COMPUTERS + MONITORS + MOBILE + OTHERS
|
filter_type = COMPUTERS + MONITORS + MOBILE + DATASTORAGE + OTHERS
|
||||||
|
|
||||||
elif "All Computers" == self.device_type:
|
elif "All Computers" == self.device_type:
|
||||||
filter_type = COMPUTERS
|
filter_type = COMPUTERS
|
||||||
|
@ -398,6 +402,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
sku = StringField('SKU', [validators.Optional()])
|
sku = StringField('SKU', [validators.Optional()])
|
||||||
image = URLField('Image', [validators.Optional(), validators.URL()])
|
image = URLField('Image', [validators.Optional(), validators.URL()])
|
||||||
imei = IntegerField('IMEI', [validators.Optional()])
|
imei = IntegerField('IMEI', [validators.Optional()])
|
||||||
|
data_storage_size = IntegerField('Storage Size', [validators.Optional()])
|
||||||
meid = StringField('MEID', [validators.Optional()])
|
meid = StringField('MEID', [validators.Optional()])
|
||||||
resolution = IntegerField('Resolution width', [validators.Optional()])
|
resolution = IntegerField('Resolution width', [validators.Optional()])
|
||||||
screen = FloatField('Screen size', [validators.Optional()])
|
screen = FloatField('Screen size', [validators.Optional()])
|
||||||
|
@ -417,6 +422,8 @@ class NewDeviceForm(FlaskForm):
|
||||||
"Smartphone": Smartphone,
|
"Smartphone": Smartphone,
|
||||||
"Tablet": Tablet,
|
"Tablet": Tablet,
|
||||||
"Cellphone": Cellphone,
|
"Cellphone": Cellphone,
|
||||||
|
"HardDrive": HardDrive,
|
||||||
|
"SolidStateDrive": SolidStateDrive,
|
||||||
"ComputerMonitor": ComputerMonitor,
|
"ComputerMonitor": ComputerMonitor,
|
||||||
"Monitor": Monitor,
|
"Monitor": Monitor,
|
||||||
"TelevisionSet": TelevisionSet,
|
"TelevisionSet": TelevisionSet,
|
||||||
|
@ -465,6 +472,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
||||||
self.imei.data = self._obj.imei
|
self.imei.data = self._obj.imei
|
||||||
self.meid.data = self._obj.meid
|
self.meid.data = self._obj.meid
|
||||||
|
self.data_storage_size.data = self._obj.data_storage_size
|
||||||
if self._obj.type == 'ComputerMonitor':
|
if self._obj.type == 'ComputerMonitor':
|
||||||
self.resolution.data = self._obj.resolution_width
|
self.resolution.data = self._obj.resolution_width
|
||||||
self.screen.data = self._obj.size
|
self.screen.data = self._obj.size
|
||||||
|
@ -492,6 +500,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
||||||
self.imei.render_kw = disabled
|
self.imei.render_kw = disabled
|
||||||
self.meid.render_kw = disabled
|
self.meid.render_kw = disabled
|
||||||
|
self.data_storage_size.render_kw = disabled
|
||||||
if self._obj.type == 'ComputerMonitor':
|
if self._obj.type == 'ComputerMonitor':
|
||||||
self.resolution.render_kw = disabled
|
self.resolution.render_kw = disabled
|
||||||
self.screen.render_kw = disabled
|
self.screen.render_kw = disabled
|
||||||
|
@ -561,6 +570,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
|
|
||||||
def create_device(self):
|
def create_device(self):
|
||||||
schema = SnapshotSchema()
|
schema = SnapshotSchema()
|
||||||
|
@ -604,6 +614,10 @@ class NewDeviceForm(FlaskForm):
|
||||||
if self.type.data in ['Smartphone', 'Tablet', 'Cellphone']:
|
if self.type.data in ['Smartphone', 'Tablet', 'Cellphone']:
|
||||||
device.imei = self.imei.data
|
device.imei = self.imei.data
|
||||||
device.meid = self.meid.data
|
device.meid = self.meid.data
|
||||||
|
device.data_storage_size = self.data_storage_size.data
|
||||||
|
|
||||||
|
if self.type.data in ['HardDrive', 'SolidStateDrive']:
|
||||||
|
device.data_storage_size = self.data_storage_size.data
|
||||||
|
|
||||||
device.image = URL(self.image.data)
|
device.image = URL(self.image.data)
|
||||||
|
|
||||||
|
@ -672,6 +686,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
if self._obj.type in ['Smartphone', 'Tablet', 'Cellphone']:
|
||||||
self._obj.imei = self.imei.data
|
self._obj.imei = self.imei.data
|
||||||
self._obj.meid = self.meid.data
|
self._obj.meid = self.meid.data
|
||||||
|
self._obj.data_storage_size = self.data_storage_size.data
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.appearance.data
|
self.appearance.data
|
||||||
|
@ -1084,6 +1099,14 @@ class DataWipeForm(ActionFormMixin):
|
||||||
del self.document
|
del self.document
|
||||||
for dev in self._devices:
|
for dev in self._devices:
|
||||||
ac = None
|
ac = None
|
||||||
|
if isinstance(dev, Mobile) or isinstance(dev, DataStorage):
|
||||||
|
ac = Model()
|
||||||
|
self.populate_obj(ac)
|
||||||
|
ac.device_id = dev.id
|
||||||
|
ac.document = document.form._obj
|
||||||
|
db.session.add(ac)
|
||||||
|
continue
|
||||||
|
|
||||||
for hd in dev.components:
|
for hd in dev.components:
|
||||||
if not isinstance(hd, DataStorage):
|
if not isinstance(hd, DataStorage):
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,28 +1,44 @@
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$("#type").on("change", deviceInputs);
|
$("#type").on("change", deviceInputs2);
|
||||||
$("#amount").on("change", amountInputs);
|
$("#amount").on("change", deviceInputs2);
|
||||||
|
deviceInputs2()
|
||||||
|
})
|
||||||
|
|
||||||
|
function deviceInputs2() {
|
||||||
deviceInputs();
|
deviceInputs();
|
||||||
amountInputs();
|
amountInputs();
|
||||||
})
|
}
|
||||||
|
|
||||||
function deviceInputs() {
|
function deviceInputs() {
|
||||||
if ($("#type").val() == "ComputerMonitor") {
|
if ($("#type").val() == "ComputerMonitor") {
|
||||||
$("#screen").show();
|
$("#screen").show();
|
||||||
$("#resolution").show();
|
$("#resolution").show();
|
||||||
|
$("#components2").hide();
|
||||||
$("#imei").hide();
|
$("#imei").hide();
|
||||||
$("#meid").hide();
|
$("#meid").hide();
|
||||||
|
$("#data_storage_size").hide();
|
||||||
} else if (["Smartphone", "Cellphone", "Tablet"].includes($("#type").val())) {
|
} else if (["Smartphone", "Cellphone", "Tablet"].includes($("#type").val())) {
|
||||||
$("#screen").hide();
|
$("#screen").hide();
|
||||||
$("#resolution").hide();
|
$("#resolution").hide();
|
||||||
|
$("#components2").hide();
|
||||||
$("#imei").show();
|
$("#imei").show();
|
||||||
$("#meid").show();
|
$("#meid").show();
|
||||||
|
$("#data_storage_size").show();
|
||||||
|
} else if (["HardDrive", "SolidStateDrive"].includes($("#type").val())) {
|
||||||
|
$("#screen").hide();
|
||||||
|
$("#resolution").hide();
|
||||||
|
$("#components2").hide();
|
||||||
|
$("#imei").hide();
|
||||||
|
$("#meid").hide();
|
||||||
|
$("#data_storage_size").show();
|
||||||
} else {
|
} else {
|
||||||
$("#screen").hide();
|
$("#screen").hide();
|
||||||
$("#resolution").hide();
|
$("#resolution").hide();
|
||||||
$("#imei").hide();
|
$("#imei").hide();
|
||||||
$("#meid").hide();
|
$("#meid").hide();
|
||||||
|
$("#data_storage_size").hide();
|
||||||
|
$("#components2").show();
|
||||||
};
|
};
|
||||||
amountInputs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function amountInputs() {
|
function amountInputs() {
|
||||||
|
@ -35,6 +51,7 @@ function amountInputs() {
|
||||||
$("#Sku").hide();
|
$("#Sku").hide();
|
||||||
$("#imei").hide();
|
$("#imei").hide();
|
||||||
$("#meid").hide();
|
$("#meid").hide();
|
||||||
|
$("#data_storage_size").hide();
|
||||||
} else {
|
} else {
|
||||||
$("#Phid").show();
|
$("#Phid").show();
|
||||||
$("#Id_device_supplier").show();
|
$("#Id_device_supplier").show();
|
||||||
|
@ -42,6 +59,5 @@ function amountInputs() {
|
||||||
$("#Serial_number").show();
|
$("#Serial_number").show();
|
||||||
$("#Part_number").show();
|
$("#Part_number").show();
|
||||||
$("#Sku").show();
|
$("#Sku").show();
|
||||||
deviceInputs();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,12 @@
|
||||||
<option value="Cellphone"
|
<option value="Cellphone"
|
||||||
{% if form.type.data == 'Cellphone' %} selected="selected"{% endif %}>Cellphone</option>
|
{% if form.type.data == 'Cellphone' %} selected="selected"{% endif %}>Cellphone</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
<optgroup label="Data Storage">
|
||||||
|
<option value="HardDrive"
|
||||||
|
{% if form.type.data == 'HardDrive' %} selected="selected"{% endif %}>HardDrive</option>
|
||||||
|
<option value="SolidStateDrive"
|
||||||
|
{% if form.type.data == 'SolidStateDrive' %} selected="selected"{% endif %}>SolidStateDrive</option>
|
||||||
|
</optgroup>
|
||||||
<optgroup label="Computer Accessory">
|
<optgroup label="Computer Accessory">
|
||||||
<option value="Mouse"
|
<option value="Mouse"
|
||||||
{% if form.type.data == 'Mouse' %} selected="selected"{% endif %}>Mouse</option>
|
{% if form.type.data == 'Mouse' %} selected="selected"{% endif %}>Mouse</option>
|
||||||
|
@ -152,7 +158,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group mb-2">
|
<div id="components2" class="from-group mb-2">
|
||||||
<label for="label" class="form-label">{{ form.components.label }}</label>
|
<label for="label" class="form-label">{{ form.components.label }}</label>
|
||||||
{{ form.components(class_="form-control") }}
|
{{ form.components(class_="form-control") }}
|
||||||
<small class="text-muted form-text">Description of components</small>
|
<small class="text-muted form-text">Description of components</small>
|
||||||
|
@ -434,6 +440,19 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="data_storage_size" class="from-group mb-2">
|
||||||
|
<label for="data_storage_size" class="form-label">{{ form.data_storage_size.label }}</label>
|
||||||
|
{{ form.data_storage_size(class_="form-control") }}
|
||||||
|
<small class="text-muted form-text">Size in GB.</small>
|
||||||
|
{% if form.data_storage_size.errors %}
|
||||||
|
<p class="text-danger">
|
||||||
|
{% for error in form.data_storage_size.errors %}
|
||||||
|
{{ error }}<br/>
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="resolution" class="from-group has-validation mb-2">
|
<div id="resolution" class="from-group has-validation mb-2">
|
||||||
<label for="resolution" class="form-label">{{ form.resolution.label }}</label>
|
<label for="resolution" class="form-label">{{ form.resolution.label }}</label>
|
||||||
{{ form.resolution(class_="form-control") }}
|
{{ form.resolution(class_="form-control") }}
|
||||||
|
|
Reference in New Issue