Added ability to clear scraped folders

nightly
Andrew 4 years ago
parent a2c1f87230
commit 314e5c5041
  1. 38
      stashr/api.py
  2. 13
      stashr/templates/scrape_page.html

@ -2362,6 +2362,44 @@ def api_post_directories_extend(scrape_id):
return jsonify(create_json_return('200'))
@api.route('/scrape/directories', methods=['DELETE'])
def api_delete_scrape_directories():
"""To Update Later
This is using docstrings for specifications.
---
tags:
- scrape
"""
user = current_user
if not user.is_authenticated:
if not request.json:
return jsonify(create_json_return('400'))
if "api_key" not in request.json:
return jsonify(create_json_return('400'))
if request.json['api_key'] == "":
return jsonify(create_json_return('100'))
user = database.session \
.query(database.Users) \
.filter(database.Users.api_key == request.json['api_key']) \
.first()
if user is None:
return jsonify(create_json_return('100'))
if user.role != 'admin':
return jsonify(create_json_return('401'))
database.session \
.query(database.ScrapeItems) \
.delete()
database.session.commit()
return jsonify(create_json_return('200'))
""" --- PLUGIN UPLOAD/INSTALL --- """

@ -240,6 +240,10 @@ Vue.component('directories', {
<i class="fas fa-sync-alt"></i>
Refresh Directories
</button>
<button type="button" class="btn btn-info m-1 w-100" data-bs-toggle="tooltip" data-bs-placement="top" title="Clear Directories" onclick="app.clearDirectories()">
<i class="fas fa-trash-alt"></i>
Clear Directories
</button>
</div>
</div>
</div>
@ -355,6 +359,15 @@ var app = new Vue({
})
}
})
},
clearDirectories() {
axios.delete('{{ url_for('api.api_delete_scrape_directories') }}')
.then(res => {
if(res.data.status_code == 200) {
this.directories = [];
stashrToast('Scrape Directories Cleared', 'success')
}
})
}
},
delimiters: ["[","]]"]

Loading…
Cancel
Save