ail-framework/var/www/modules/PasteSubmit/templates/submit_items.html

423 lines
13 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<title>AIL-Framework</title>
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png')}}">
<!-- Core CSS -->
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/tags.css') }}" rel="stylesheet" type="text/css" />
<!-- JS -->
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/tags.js') }}"></script>
</head>
2021-04-28 13:24:33 +00:00
<body>
{% if UUID %}
2021-04-28 13:24:33 +00:00
<div id="modalsubmit" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
2021-04-28 13:24:33 +00:00
<div id="mymodalcontent" class="modal-content">
<div class="modal-header"
style="border-bottom: 4px solid #cccccc; background-color: #cccccc; color: #ffffff;">
<p class="heading">
<h1>Submitting Items ...</h1>
</p>
2021-04-28 13:24:33 +00:00
</div>
2021-04-28 13:24:33 +00:00
<div class="modal-body">
2021-04-28 13:24:33 +00:00
<div class="progress mt-1" id="pr" hidden>
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%" id="progress-bar">
2021-04-28 13:24:33 +00:00
0%
</div>
2021-04-28 13:24:33 +00:00
</div>
<span class="btn btn-info mt-2" id="files_submitted_btn" hidden>
Files Submitted <span class="badge badge-light" id="files_submitted">1 / 1</span>
</span>
2021-04-28 13:24:33 +00:00
<button class="btn btn-lg btn-warning" style="margin: auto;" id="loading_button">
<i class="fas fa-sync-alt fa-spin"></i>
&nbsp;&nbsp;&nbsp;&nbsp;Loading&nbsp;.&nbsp;.&nbsp;.
</button>
2021-04-28 13:24:33 +00:00
<br></br>
2021-04-28 13:24:33 +00:00
<div class="card border-danger" id="panel_error" hidden>
<div class="card-header bg-danger text-white">ERROR</div>
<div class="card-body">
<p id="error_message">error</p>
</div>
2021-04-28 13:24:33 +00:00
</div>
2021-04-28 13:24:33 +00:00
<div class="list-group" id="submit_pastes" hidden>
<li class="list-group-item bg-dark text-white">Submitted Items</li>
</div>
2021-04-28 13:24:33 +00:00
</div>
<div class="modal-footer">
<a class="btn btn-light text-secondary"
href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags=infoleak:submission=&quot;manual&quot;"
target="_blank" id="submit_result" hidden>
<i class="fas fa-paper-plane fa-2x"></i>
<span class="label-icon">Submitted Items </span>
</a>
<button class="btn btn-success btn-tags ml-auto" data-dismiss="modal" id="success_submit_button"
hidden>
<span class="label-icon">Success </span>
<i class="fas fa-check"></i>
</button>
<button class="btn btn-danger btn-tags ml-auto" data-dismiss="modal" id="error_submit_button"
hidden>
<span class="label-icon">ERROR </span>
<i class="fas fa-times"></i>
</button>
</div>
</div>
</div>
2021-04-28 13:24:33 +00:00
</div>
{% endif %}
{% include 'nav_bar.html' %}
<div class="container-fluid">
<div class="row">
{% include 'item_submit/menu_sidebar.html' %}
<div class="col-12 col-lg-10" id="core_content">
2021-04-28 13:24:33 +00:00
{% if message %}
<p>{{ message }}</p>
2021-04-28 13:24:33 +00:00
{% endif %}
<form action="{{ url_for('PasteSubmit.submit') }}" id="pasteSubmitForm" method="post"
enctype=multipart/form-data onsubmit="submitPaste()">
<input type="hidden" id="tags_taxonomies" name="tags_taxonomies" value="test">
<input type="hidden" id="tags_galaxies" name="tags_galaxies" value="test">
2021-04-28 13:24:33 +00:00
<div class="card mt-2 mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Submit Item</h6>
</div>
2021-04-28 13:24:33 +00:00
<div class="card-body">
2021-04-28 13:24:33 +00:00
<div class="row mb-3">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="radioimportfile" name="radioimport"
value="file" checked />
<label class="form-check-label" for="radioimportfile"> Submit a file </label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" type="radio" id="radioimporttext"
name="radioimport" value="text" />
<label class="form-check-label" for="radioimporttext"> Submit a text </label>
</div>
2021-04-28 13:24:33 +00:00
</div>
<label for="ltags">Optional Tags:</label>
2021-04-28 13:24:33 +00:00
<div class="row mb-3">
<div class="col">
<div class="input-group">
<input id="ltags" type="text" class="form-control" autocomplete="off">
</div>
<div class="dropdown">
2021-04-28 13:24:33 +00:00
<button type="button" class="btn btn-info dropdown-toggle mt-1 mb-3"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
id="dropdown-taxonomie">
Taxonomie Selected
</button>
2021-04-28 13:24:33 +00:00
<div class="dropdown-menu dropdown-menu-right"
aria-labelledby="dropdown-taxonomie">
<!-- TODO: make dropdown-scrollable -->
<h6 class="dropdown-header">Taxonomie Tags</h6>
2021-04-28 13:24:33 +00:00
<button class="dropdown-item" type="button" id="all-tags-taxonomies">All
Tags <i class="fas fa-tags"></i></button>
<div class="dropdown-divider"></div>
{% for taxo in active_taxonomies %}
<button class="dropdown-item" type="button"
id="{{ taxo }}-id{{ loop.index0 }}">{{ taxo }}</button>
{% endfor %}
</div>
</div>
2021-04-28 13:24:33 +00:00
</div>
<div class="col">
<div class="input-group">
<input id="ltagsgalaxies" type="text" class="form-control" autocomplete="off">
</div>
<div class="dropdown">
2021-04-28 13:24:33 +00:00
<button type="button" class="btn btn-info dropdown-toggle mt-1 mb-3"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
id="dropdown-galaxy">
Galaxy Selected
</button>
2021-04-28 13:24:33 +00:00
<div class="dropdown-menu dropdown-menu-right"
aria-labelledby="dropdown-galaxy">
<!-- TODO: make dropdown-scrollable -->
<h6 class="dropdown-header">Galaxy Tags</h6>
2021-04-28 13:24:33 +00:00
<button class="dropdown-item" type="button" id="all-tags-galaxies">All Tags
<i class="fas fa-tags"></i></button>
<div class="dropdown-divider"></div>
{% for galaxy in active_galaxies %}
<button class="dropdown-item" type="button"
id="{{ galaxy }}-idgalax{{ loop.index0 }}">{{ galaxy }}</button>
{% endfor %}
</div>
</div>
2021-04-28 13:24:33 +00:00
</div>
</div>
</div>
2021-04-28 13:24:33 +00:00
<!-- Card Import File -->
<div class="input-group mt-2 mb-2" id="cardimportfile">
<div class="card-body">
<div class="form-group">
<label for="file">Submit a file, format allowed: {{allowed_extensions}}, max size
{{file_max_size}} Gb</label>
<input type="file" class="form-control-file" id="file" name="file">
</div>
<!-- TODO reactivate while zipped format are enabled -->
<div class="form-group d-none">
<label for="paste_name">Archive Password</label>
<input type="text" class="form-control" id="archive_pass" name="archive_pass"
2021-04-28 13:24:33 +00:00
placeholder="Optional">
</div>
</div>
2021-04-28 13:24:33 +00:00
</div>
2021-04-28 13:24:33 +00:00
<!-- Card Import Text -->
<div class="input-group mb-4 mb-2" id="cardimporttext">
<div class="card-body">
<div class="form-group">
<label for="paste_source">Submit a text, max size {{text_max_size}} Mb</label>
<input id="paste_source" type="text" name="paste_source"
class="form-control bg-light border-0 small" placeholder="Source"
aria-label="Source" aria-describedby="basic-addon2">
</div>
<div class="form-group mt-3">
<textarea class="form-control" id="paste_content" name="paste_content"
rows="20"></textarea>
</div>
</div>
</div>
2021-04-28 13:24:33 +00:00
<div class="form-group">
<button class="btn btn-primary btn-lg btn-block" name="submit" type="submit">Submit
Item</button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
2021-04-28 13:24:33 +00:00
<!-- Toggle import div related to radio button selected -->
<script>
$(document).ready(function () {
$("#cardimporttext").hide();
$('input[type="radio"]').click(function () {
var inputValue = $(this).attr("value");
$("#cardimportfile").hide();
$("#cardimporttext").hide();
var targetBox = $("#cardimport" + inputValue);
$(targetBox).show();
});
});
</script>
<script>
2021-04-28 13:24:33 +00:00
var ltags
var ltagsgalaxies
2021-04-28 13:24:33 +00:00
$(document).ready(function () {
$("#page-items-submit").addClass("active");
2023-04-05 09:06:21 +00:00
$.getJSON("{{ url_for('tags_ui.get_all_taxonomies_customs_tags') }}",
2021-04-28 13:24:33 +00:00
function (data) {
ltags = $('#ltags').tagSuggest({
data: data,
maxDropHeight: 200,
name: 'ltags',
emptyText: 'Add Taxonomies Tags',
2021-04-28 13:24:33 +00:00
});
});
2023-04-05 09:06:21 +00:00
$.getJSON("{{ url_for('tags_ui.tag_galaxies_tags_enabled_json') }}",
2021-04-28 13:24:33 +00:00
function (data) {
ltagsgalaxies = $('#ltagsgalaxies').tagSuggest({
data: data,
maxDropHeight: 200,
name: 'ltagsgalaxies',
emptyText: 'Add Galaxies Tags',
2021-04-28 13:24:33 +00:00
});
});
$('#modalsubmit').modal({ backdrop: 'static' })
});
function toggle_sidebar() {
if ($('#nav_menu').is(':visible')) {
$('#nav_menu').hide();
$('#side_menu').removeClass('border-right')
$('#side_menu').removeClass('col-lg-2')
$('#core_content').removeClass('col-lg-10')
} else {
$('#nav_menu').show();
$('#side_menu').addClass('border-right')
$('#side_menu').addClass('col-lg-2')
$('#core_content').addClass('col-lg-10')
}
}
</script>
<script>
2021-04-28 13:24:33 +00:00
function submitPaste() {
document.getElementById("tags_taxonomies").value = ltags.getValue();
document.getElementById("tags_galaxies").value = ltagsgalaxies.getValue();
}
</script>
<script>
2021-04-28 13:24:33 +00:00
jQuery("#all-tags-taxonomies").on("click", function (e) {
//change input tags list
2023-04-05 09:06:21 +00:00
$.getJSON("{{ url_for('tags_ui.get_all_taxonomies_customs_tags') }}",
2021-04-28 13:24:33 +00:00
function (data) {
ltags.setData(data)
});
});
</script>
<script>
2021-04-28 13:24:33 +00:00
jQuery("#all-tags-galaxies").on("click", function (e) {
2023-04-05 09:06:21 +00:00
$.getJSON("{{ url_for('tags_ui.tag_galaxies_tags_enabled_json') }}",
2021-04-28 13:24:33 +00:00
function (data) {
ltagsgalaxies.setData(data)
});
});
{% for taxo in active_taxonomies %}
jQuery("#{{ taxo }}-id{{ loop.index0 }}").on("click", function (e) {
2023-04-05 09:06:21 +00:00
$.getJSON("{{ url_for('tags_ui.tag_taxonomie_tags_enabled_json') }}?taxonomie={{ taxo }}",
function (data) {
ltags.setData(data)
});
});
2021-04-28 13:24:33 +00:00
{% endfor %}
</script>
<script>
2021-04-28 13:24:33 +00:00
{% for galaxy in active_galaxies %}
jQuery("#{{ galaxy }}-idgalax{{ loop.index0 }}").on("click", function (e) {
2023-04-05 09:06:21 +00:00
$.getJSON("{{ url_for('tags_ui.tag_galaxy_tags_enabled_json') }}?galaxy={{ galaxy }}",
function (data) {
ltagsgalaxies.setData(data)
});
});
2021-04-28 13:24:33 +00:00
{% endfor %}
</script>
<script type="text/javascript">
2021-04-28 13:24:33 +00:00
var i = 0;
var err = 0;
$(".progress-bar").css("width", i + "%").text(i + " %");
function makeProgress() {
$.getJSON("{{ url_for('PasteSubmit.submit_status') }}?UUID={{ UUID }}",
function (data) {
var end = data.end;
var prog = data.prog;
var in_progress = data.in_progress;
var processing = data.processing;
var isError = data.isError;
var error = data.error;
if (processing) {
$("#loading_button").hide();
$("#pr").prop('hidden', false);
$("#files_submitted_btn").prop('hidden', false);
}
2021-04-28 13:24:33 +00:00
if (i < 100) {
$(".progress-bar").css("width", prog + "%").text(prog + " %");
}
2021-04-28 13:24:33 +00:00
if (!end) {
2021-04-28 13:24:33 +00:00
document.getElementById('files_submitted').innerHTML = in_progress;
2021-04-28 13:24:33 +00:00
//error handler
if (isError) {
document.getElementById('error_message').innerHTML = error;
$("#panel_error").prop('hidden', false);
$("#error_submit_button").prop('hidden', false);
err = err + 1;
}
2021-04-28 13:24:33 +00:00
// Wait for sometime before running this script again
if (err < 100) {
setTimeout("makeProgress()", 100);
}
} else {
document.getElementById('files_submitted').innerHTML = in_progress;
$("#progress-bar").removeClass('progress-bar-animated');
$("#submit_result").prop('hidden', false);
2021-04-28 13:24:33 +00:00
if (isError) {
document.getElementById('error_message').innerHTML = error;
$("#panel_error").prop('hidden', false);
$("#error_submit_button").prop('hidden', false);
2021-04-28 13:24:33 +00:00
} else {
$("#success_submit_button").prop('hidden', false);
}
2021-04-28 13:24:33 +00:00
if (in_progress == '0 / ') {
document.getElementById('files_submitted').innerHTML = '0 / 0'
$(".progress-bar").css("width", "100%").text("100 %");
$("#progress-bar").addClass('bg-danger')
} else {
var link = data.link;
$("#submit_pastes").append(link);
$("#submit_pastes").prop('hidden', false);
}
2021-04-28 13:24:33 +00:00
}
2021-04-28 13:24:33 +00:00
}
2021-04-28 13:24:33 +00:00
);
2021-04-28 13:24:33 +00:00
}
makeProgress();
</script>
</html>