minimalistic settings

This commit is contained in:
Cayo Puigdefabregas 2022-05-12 17:19:22 +02:00
parent b927e1ac54
commit 763d2d1361
3 changed files with 5 additions and 53 deletions

View File

@ -28,22 +28,6 @@
<p class="small">Download the settings only for register devices.</p>
</div>
</div>
<div class="row pt-4">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=soft" class="btn btn-primary">Register and erase disks Basic</a>
</div>
<div class="col">
<p class="small">Download the settings for register devices and erase disks. This is less safe and more fast.</p>
</div>
</div>
<div class="row pt-3">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=hard" class="btn btn-primary">Register and erase disks for Sectors</a>
</div>
<div class="col">
<p class="small">Download the settings for register devices and erase disks. This is more safe and more slow.</p>
</div>
</div>
</div>
</div>

View File

@ -1,18 +1,4 @@
[settings]
DH_TOKEN = {{token}}
DH_HOST = {{host}}
DH_DATABASE = {{inventory}}
DEVICEHUB_URL = https://${DB_HOST}/${DB_DATABASE}/
WB_BENCHMARK = {{ benchmark }}
WB_STRESS_TEST = {{ stress_test }}
WB_SMART_TEST = short
WB_ERASE = {{ erase }}
WB_ERASE_STEPS = {{ steps }}
WB_ERASE_LEADING_ZEROS = {{ leading_zeros }}
WB_DEBUG = True
TOKEN = {{ token }}
URL = {{ url }}

View File

@ -35,36 +35,18 @@ class SettingsView(GenericMixView):
return flask.render_template(self.template_name, **self.context)
def download(self):
url = "https://{}/api/".format(app.config['HOST'])
self.wbContext = {
'token': self.get_token(),
'host': app.config['HOST'],
'inventory': app.config['SCHEMA'],
'benchmark': False,
'stress_test': 1,
'erase': '',
'steps': 0,
'leading_zeros': False,
'url': url,
}
options = {"register": self.register, "soft": self.soft, "hard": self.hard}
options = {"register": self.register}
return options[self.opt]()
def register(self):
data = flask.render_template('workbench/wbSettings.ini', **self.wbContext)
return self.response_download(data)
def soft(self):
self.wbContext['erase'] = 'EraseBasic'
self.wbContext['steps'] = 1
data = flask.render_template('workbench/wbSettings.ini', **self.wbContext)
return self.response_download(data)
def hard(self):
self.wbContext['erase'] = 'EraseSectors'
self.wbContext['steps'] = 1
self.wbContext['leading_zeros'] = True
data = flask.render_template('workbench/wbSettings.ini', **self.wbContext)
return self.response_download(data)
def response_download(self, data):
bfile = str.encode(data)
output = make_response(bfile)