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