Added option to disable backup in import

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2020-05-11 20:41:10 -07:00
parent 9a2ed804ca
commit 95cc48e422
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC
11 changed files with 95 additions and 85 deletions

View file

@ -119,7 +119,14 @@ class ImportController extends Controller
{ {
$this->authorize('import'); $this->authorize('import');
// Run a backup immediately before processing // Run a backup immediately before processing
Artisan::call('backup:run');
if ($request->has('run-backup')) {
\Log::debug('Backup manually requested via importer');
Artisan::call('backup:run');
} else {
\Log::debug('NO BACKUP requested via importer');
}
$errors = $request->import(Import::find($import_id)); $errors = $request->import(Import::find($import_id));
$redirectTo = "hardware.index"; $redirectTo = "hardware.index";
switch ($request->get('import-type')) { switch ($request->get('import-type')) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/js/dist/all.js vendored

Binary file not shown.

View file

@ -1,11 +1,11 @@
{ {
"/js/build/vue.js": "/js/build/vue.js?id=684d1ab5c98c5b1b9d3c", "/js/build/vue.js": "/js/build/vue.js?id=1d5d300bca67f973816c",
"/css/AdminLTE.css": "/css/AdminLTE.css?id=56b8066cfbc70df10545", "/css/AdminLTE.css": "/css/AdminLTE.css?id=56b8066cfbc70df10545",
"/css/app.css": "/css/app.css?id=407edb63cc6b6dc62405", "/css/app.css": "/css/app.css?id=407edb63cc6b6dc62405",
"/css/overrides.css": "/css/overrides.css?id=014ba62bc420467fd405", "/css/overrides.css": "/css/overrides.css?id=014ba62bc420467fd405",
"/css/skins/skin-blue.css": "/css/skins/skin-blue.css?id=c28283a1d468e2337428", "/css/skins/skin-blue.css": "/css/skins/skin-blue.css?id=c28283a1d468e2337428",
"/css/skins/skin-red.css": "/css/skins/skin-red.css?id=079dd6c501fa9ea60a98", "/css/skins/skin-red.css": "/css/skins/skin-red.css?id=079dd6c501fa9ea60a98",
"/css/skins/skin-contrast.css": "/css/skins/skin-contrast.css?id=47303dc15032d3ecb343", "/css/skins/skin-contrast.css": "/css/skins/skin-contrast.css?id=62e14190151e9efc9995",
"/css/skins/skin-green.css": "/css/skins/skin-green.css?id=2c53f7ed585fcad563b2", "/css/skins/skin-green.css": "/css/skins/skin-green.css?id=2c53f7ed585fcad563b2",
"/css/skins/skin-green-dark.css": "/css/skins/skin-green-dark.css?id=cb34691dbbb72cae7f5f", "/css/skins/skin-green-dark.css": "/css/skins/skin-green-dark.css?id=cb34691dbbb72cae7f5f",
"/css/skins/skin-black.css": "/css/skins/skin-black.css?id=1dfec89b8640b69dc0fc", "/css/skins/skin-black.css": "/css/skins/skin-black.css?id=1dfec89b8640b69dc0fc",
@ -18,13 +18,13 @@
"/css/skins/skin-blue-dark.css": "/css/skins/skin-blue-dark.css?id=d25c77d9c6f4cfe2efd4", "/css/skins/skin-blue-dark.css": "/css/skins/skin-blue-dark.css?id=d25c77d9c6f4cfe2efd4",
"/css/skins/skin-orange-dark.css": "/css/skins/skin-orange-dark.css?id=abc219c1fed59cecb860", "/css/skins/skin-orange-dark.css": "/css/skins/skin-orange-dark.css?id=abc219c1fed59cecb860",
"/css/skins/skin-orange.css": "/css/skins/skin-orange.css?id=59664dbd286988d2a438", "/css/skins/skin-orange.css": "/css/skins/skin-orange.css?id=59664dbd286988d2a438",
"/js/build/vue.js.map": "/js/build/vue.js.map?id=8fafb985154034fd882a", "/js/build/vue.js.map": "/js/build/vue.js.map?id=f89fab0f3e7a8694efa9",
"/css/AdminLTE.css.map": "/css/AdminLTE.css.map?id=5a2d6f3c59191ce716e2", "/css/AdminLTE.css.map": "/css/AdminLTE.css.map?id=5a2d6f3c59191ce716e2",
"/css/app.css.map": "/css/app.css.map?id=96b5c985e860716e6a16", "/css/app.css.map": "/css/app.css.map?id=96b5c985e860716e6a16",
"/css/overrides.css.map": "/css/overrides.css.map?id=fe0a3186bd85efc442ca", "/css/overrides.css.map": "/css/overrides.css.map?id=fe0a3186bd85efc442ca",
"/css/skins/skin-blue.css.map": "/css/skins/skin-blue.css.map?id=129b9523e6ffd5683230", "/css/skins/skin-blue.css.map": "/css/skins/skin-blue.css.map?id=129b9523e6ffd5683230",
"/css/skins/skin-red.css.map": "/css/skins/skin-red.css.map?id=292dfa49bf2b6f23fa59", "/css/skins/skin-red.css.map": "/css/skins/skin-red.css.map?id=292dfa49bf2b6f23fa59",
"/css/skins/skin-contrast.css.map": "/css/skins/skin-contrast.css.map?id=141c0891e3ed15673d22", "/css/skins/skin-contrast.css.map": "/css/skins/skin-contrast.css.map?id=bf37f812f0b6a109b5ce",
"/css/skins/skin-green.css.map": "/css/skins/skin-green.css.map?id=50461604ff9b1934d580", "/css/skins/skin-green.css.map": "/css/skins/skin-green.css.map?id=50461604ff9b1934d580",
"/css/skins/skin-green-dark.css.map": "/css/skins/skin-green-dark.css.map?id=988cf7da13d22c56bd8c", "/css/skins/skin-green-dark.css.map": "/css/skins/skin-green-dark.css.map?id=988cf7da13d22c56bd8c",
"/css/skins/skin-black.css.map": "/css/skins/skin-black.css.map?id=ad0bf20283280a01b34f", "/css/skins/skin-black.css.map": "/css/skins/skin-black.css.map?id=ad0bf20283280a01b34f",
@ -37,8 +37,8 @@
"/css/skins/skin-blue-dark.css.map": "/css/skins/skin-blue-dark.css.map?id=32784cb5d02773eb0e69", "/css/skins/skin-blue-dark.css.map": "/css/skins/skin-blue-dark.css.map?id=32784cb5d02773eb0e69",
"/css/skins/skin-orange-dark.css.map": "/css/skins/skin-orange-dark.css.map?id=68b998638217fd08ef29", "/css/skins/skin-orange-dark.css.map": "/css/skins/skin-orange-dark.css.map?id=68b998638217fd08ef29",
"/css/skins/skin-orange.css.map": "/css/skins/skin-orange.css.map?id=f90fda3cc0a48c048a9e", "/css/skins/skin-orange.css.map": "/css/skins/skin-orange.css.map?id=f90fda3cc0a48c048a9e",
"/css/dist/all.css": "/css/dist/all.css?id=41fe3b2990d453da1997", "/css/dist/all.css": "/css/dist/all.css?id=32f6e6a70fdaa03a0d88",
"/js/dist/all.js": "/js/dist/all.js?id=8ec0e00558ab4b60acb8", "/js/dist/all.js": "/js/dist/all.js?id=f46f0f728670ee80267a",
"/css/build/all.css": "/css/build/all.css?id=41fe3b2990d453da1997", "/css/build/all.css": "/css/build/all.css?id=32f6e6a70fdaa03a0d88",
"/js/build/all.js": "/js/build/all.js?id=8ec0e00558ab4b60acb8" "/js/build/all.js": "/js/build/all.js?id=f46f0f728670ee80267a"
} }

View file

@ -1,9 +1,3 @@
<style>
tr {
padding-left:30px;
}
</style>
<template> <template>
<div v-show="processDetail"> <div v-show="processDetail">
@ -11,30 +5,38 @@ tr {
<div class="col-md-2"></div> <div class="col-md-2"></div>
<div class="col-md-8" style="padding-top: 30px; margin: 0 auto;"> <div class="col-md-8" style="padding-top: 30px; margin: 0 auto;">
<div class="dynamic-form-row"> <div class="dynamic-form-row">
<div class="col-md-5 col-xs-12"> <div class="col-md-5 col-xs-12">
<label for="import-type">Import Type:</label> <label for="import-type">Import Type:</label>
</div>
<div class="col-md-7 col-xs-12">
<select2 :options="options.importTypes" v-model="options.importType" required>
<option disabled value="0"></option>
</select2>
</div>
</div> </div>
<div class="col-md-7 col-xs-12"> <div class="dynamic-form-row">
<select2 :options="options.importTypes" v-model="options.importType" required> <div class="col-md-5 col-xs-12">
<option disabled value="0"></option> <label for="import-update">Update Existing Values?:</label>
</select2> </div>
<div class="col-md-7 col-xs-12">
<input type="checkbox" class="minimal" name="import-update" v-model="options.update">
</div>
</div> </div>
</div> <div class="dynamic-form-row">
<div class="dynamic-form-row"> <div class="col-md-5 col-xs-12">
<div class="col-md-5 col-xs-12"> <label for="send-welcome">Send Welcome Email for new Users?</label>
<label for="import-update">Update Existing Values?:</label> </div>
</div> <div class="col-md-7 col-xs-12">
<div class="col-md-7 col-xs-12"> <input type="checkbox" class="minimal" name="send-welcome" v-model="options.send_welcome">
<input type="checkbox" name="import-update" v-model="options.update"> </div>
</div>
</div>
<div class="dynamic-form-row">
<div class="col-md-5 col-xs-12">
<label for="send-welcome">Send Welcome Email for new Users?</label>
</div>
<div class="col-md-7 col-xs-12">
<input type="checkbox" name="send-welcome" v-model="options.send_welcome">
</div> </div>
<div class="dynamic-form-row">
<div class="col-md-5 col-xs-12">
<label for="send-welcome">Backup before importing?</label>
</div>
<div class="col-md-7 col-xs-12">
<input type="checkbox" class="minimal" name="run-backup" v-model="options.run_backup">
</div>
</div> </div>
</div> </div>
<div class="alert col-md-8 col-md-offset-2" style="text-align:left" <div class="alert col-md-8 col-md-offset-2" style="text-align:left"
@ -43,53 +45,53 @@ tr {
{{ this.statusText }} {{ this.statusText }}
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-2"></div> <div class="col-md-2"></div>
<div class="col-md-8" style="padding-top: 30px;"> <div class="col-md-8" style="padding-top: 30px;">
<div class="col-md-4 text-right"><h4>Header Field</h4></div> <div class="col-md-4 text-right"><h4>Header Field</h4></div>
<div class="col-md-4"><h4>Import Field</h4></div> <div class="col-md-4"><h4>Import Field</h4></div>
<div class="col-md-4"><h4>Sample Value</h4></div> <div class="col-md-4"><h4>Sample Value</h4></div>
</div> </div>
</div> </div>
<template v-for="(header, index) in file.header_row"> <template v-for="(header, index) in file.header_row">
<div class="row"> <div class="row">
<div class="col-md-2"></div> <div class="col-md-2"></div>
<div class="col-md-8"> <div class="col-md-8">
<div class="col-md-4 text-right"> <div class="col-md-4 text-right">
<label :for="header" class="control-label">{{ header }}</label> <label :for="header" class="control-label">{{ header }}</label>
</div> </div>
<div class="col-md-4 form-group"> <div class="col-md-4 form-group">
<div required> <div required>
<select2 :options="columns" v-model="columnMappings[header]"> <select2 :options="columns" v-model="columnMappings[header]">
<option value="0">Do Not Import</option> <option value="0">Do Not Import</option>
</select2> </select2>
</div>
</div>
<div class="col-md-4">
<p class="form-control-static">{{ activeFile.first_row[index] }}</p>
</div>
</div> </div>
</div> </div>
</template> <div class="col-md-4">
<p class="form-control-static">{{ activeFile.first_row[index] }}</p>
<div class="row">
<div class="col-md-6 col-md-offset-2 text-right" style="padding-top: 20px;">
<button type="button" class="btn btn-sm btn-default" @click="processDetail = false">Cancel</button>
<button type="submit" class="btn btn-sm btn-primary" @click="postSave">Import</button>
<br><br>
</div>
</div>
<div class="row">
<div class="alert col-md-8 col-md-offset-2" style="padding-top: 20px;"
:class="alertClass"
v-if="statusText">
{{ this.statusText }}
</div> </div>
</div> </div>
</div> </div>
</template>
<div class="row">
<div class="col-md-6 col-md-offset-2 text-right" style="padding-top: 20px;">
<button type="button" class="btn btn-sm btn-default" @click="processDetail = false">Cancel</button>
<button type="submit" class="btn btn-sm btn-primary" @click="postSave">Import</button>
<br><br>
</div>
</div>
<div class="row">
<div class="alert col-md-8 col-md-offset-2" style="padding-top: 20px;"
:class="alertClass"
v-if="statusText">
{{ this.statusText }}
</div>
</div>
</div>
</template> </template>
<script> <script>
@ -192,14 +194,14 @@ tr {
switch(this.options.importType) { switch(this.options.importType) {
case 'asset': case 'asset':
return this.columnOptions.general return this.columnOptions.general
.concat(this.columnOptions.assets) .concat(this.columnOptions.assets)
.concat(this.columnOptions.customFields) .concat(this.columnOptions.customFields)
.sort(sorter); .sort(sorter);
case 'consumable': case 'consumable':
return this.columnOptions.general return this.columnOptions.general
.concat(this.columnOptions.consumables) .concat(this.columnOptions.consumables)
.sort(sorter); .sort(sorter);
case 'license': case 'license':
return this.columnOptions.general.concat(this.columnOptions.licenses).sort(sorter); return this.columnOptions.general.concat(this.columnOptions.licenses).sort(sorter);
case 'user': case 'user':
@ -237,6 +239,7 @@ tr {
'import-update': this.options.update, 'import-update': this.options.update,
'send-welcome': this.options.send_welcome, 'send-welcome': this.options.send_welcome,
'import-type': this.options.importType, 'import-type': this.options.importType,
'run-backup': this.options.run_backup,
'column-mappings': this.columnMappings 'column-mappings': this.columnMappings
}).then( ({body}) => { }).then( ({body}) => {
// Success // Success
@ -289,4 +292,4 @@ tr {
select2: require('../select2.vue') select2: require('../select2.vue')
} }
} }
</script> </script>