mirror of https://github.com/gophish/gophish
Made progress handling adding attachments to templates
parent
ca378f835f
commit
62fc7b2d97
|
@ -31,7 +31,7 @@
|
||||||
</tab>
|
</tab>
|
||||||
</tabset>
|
</tabset>
|
||||||
<br />
|
<br />
|
||||||
<label class="control-label" ng-hide="template.attachments.length == 0">Files:</label>
|
<label class="control-label">Files:</label>
|
||||||
<div ng-repeat="file in template.attachments" ng-model="template.attachments">
|
<div ng-repeat="file in template.attachments" ng-model="template.attachments">
|
||||||
<i class="fa fa-file-excel-o" ng-show="file.type == 'application/vnd.ms-excel'"></i>
|
<i class="fa fa-file-excel-o" ng-show="file.type == 'application/vnd.ms-excel'"></i>
|
||||||
<i class="fa fa-file-text-o" ng-show="file.type == 'text/plain'"></i>
|
<i class="fa fa-file-text-o" ng-show="file.type == 'text/plain'"></i>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<span class="btn btn-danger btn-file"><i class="fa fa-plus"></i> Add Files
|
<span class="btn btn-danger btn-file"><i class="fa fa-plus"></i> Add Files
|
||||||
<input type="file" ng-file-select="onFileSelect($files)" multiple>
|
<input type="file" onchange="attach(this.files)" multiple>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
// Save attempts to POST to /groups/
|
var template = {attachments:[]}
|
||||||
function save(){
|
var icons = {
|
||||||
var targets = []
|
"application/vnd.ms-excel" : "fa-file-excel-o",
|
||||||
$.each($("#targetsTable").DataTable().rows().data(), function(i, target){
|
"text/plain" : "fa-file-text-o",
|
||||||
targets.push({
|
"image/gif" : "fa-file-image-o",
|
||||||
first_name : target[0],
|
"image/png" : "fa-file-image-o",
|
||||||
last_name: target[1],
|
"application/pdf" : "fa-file-pdf-o",
|
||||||
email: target[2],
|
"application/x-zip-compressed" : "fa-file-archive-o",
|
||||||
position: target[3]
|
"application/x-gzip" : "fa-file-archive-o",
|
||||||
})
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation" : "fa-file-powerpoint-o",
|
||||||
})
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" : "fa-file-word-o",
|
||||||
var group = {
|
"application/octet-stream" : "fa-file-o",
|
||||||
name: $("#name").val(),
|
"application/x-msdownload" : "fa-file-o"
|
||||||
targets: targets
|
|
||||||
}
|
}
|
||||||
console.log(group)
|
|
||||||
// Submit the group
|
// Save attempts to POST to /templates/
|
||||||
api.groups.post(group)
|
function save(){
|
||||||
|
template.name = $("#name").val()
|
||||||
|
console.log(template)
|
||||||
|
// Submit the template
|
||||||
|
api.templates.post(template)
|
||||||
.success(function(data){
|
.success(function(data){
|
||||||
successFlash("Group added successfully!")
|
successFlash("Template added successfully!")
|
||||||
load()
|
load()
|
||||||
dismiss()
|
dismiss()
|
||||||
})
|
})
|
||||||
|
@ -30,38 +33,38 @@ function save(){
|
||||||
function dismiss(){
|
function dismiss(){
|
||||||
$("#modal\\.flashes").empty()
|
$("#modal\\.flashes").empty()
|
||||||
$("#modal").modal('hide')
|
$("#modal").modal('hide')
|
||||||
|
template = {attachments:[]}
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(group){
|
function attach(files){
|
||||||
$("#html_editor").ckeditor()
|
$.each(files, function(i, file){
|
||||||
if (group == "new") {
|
var reader = new FileReader();
|
||||||
group = {}
|
/* Make this a datatable */
|
||||||
|
reader.onload = function(e){
|
||||||
|
// Add the attachment
|
||||||
|
template.attachments.push({
|
||||||
|
name: file.name,
|
||||||
|
content: reader.result.split(",")[1],
|
||||||
|
type: file.type || "application/octet-stream"
|
||||||
|
})
|
||||||
|
var icon = icons[file.type] || "fa-file-o"
|
||||||
|
// Add the record to the modal
|
||||||
|
$("#attachments").append('<i class="fa ' + icon + '"></i> ' + file.name + '<span class="remove-row"><i class="fa fa-trash-o"></i></span><br/>');
|
||||||
}
|
}
|
||||||
targets = $("#targetsTable").dataTable()
|
reader.onerror = function(e) {
|
||||||
// Handle Addition
|
console.log(e)
|
||||||
$("#targetForm").submit(function(){
|
}
|
||||||
targets.DataTable()
|
reader.readAsDataURL(file)
|
||||||
.row.add([
|
|
||||||
$("#firstName").val(),
|
|
||||||
$("#lastName").val(),
|
|
||||||
$("#email").val(),
|
|
||||||
$("#position").val(),
|
|
||||||
'<span style="cursor:pointer;"><i class="fa fa-trash-o"></i></span>'
|
|
||||||
])
|
|
||||||
.draw()
|
|
||||||
$("#targetForm>div>input").val('')
|
|
||||||
$("#firstName").focus()
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
// Handle Deletion
|
|
||||||
$("#targetsTable").on("click", "span>i.fa-trash-o", function(){
|
|
||||||
targets.DataTable()
|
|
||||||
.row( $(this).parents('tr') )
|
|
||||||
.remove()
|
|
||||||
.draw();
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function edit(t){
|
||||||
|
$("#html_editor").ckeditor()
|
||||||
|
if (t == "new") {
|
||||||
|
template = {attachments:[]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function load(){
|
function load(){
|
||||||
api.templates.get()
|
api.templates.get()
|
||||||
.success(function(templates){
|
.success(function(templates){
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Nav tabs -->
|
<!-- Nav tabs -->
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li role="text"><a href="#text" aria-controls="text" role="tab" data-toggle="tab">Text</a></li>
|
<li class="active" role="text"><a href="#text" aria-controls="text" role="tab" data-toggle="tab">Text</a></li>
|
||||||
<li role="html"><a href="#html" aria-controls="html" role="tab" data-toggle="tab">HTML</a></li>
|
<li role="html"><a href="#html" aria-controls="html" role="tab" data-toggle="tab">HTML</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
|
@ -111,27 +111,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<label class="control-label" ng-hide="template.attachments.length == 0">Files:</label>
|
<label class="control-label">Files:</label>
|
||||||
<div ng-repeat="file in template.attachments" ng-model="template.attachments">
|
<div id="attachments"></div>
|
||||||
<i class="fa fa-file-excel-o" ng-show="file.type == 'application/vnd.ms-excel'"></i>
|
|
||||||
<i class="fa fa-file-text-o" ng-show="file.type == 'text/plain'"></i>
|
|
||||||
<i class="fa fa-file-image-o" ng-show="file.type == 'image/gif'"></i>
|
|
||||||
<i class="fa fa-file-pdf-o" ng-show="file.type == 'application/pdf'"></i>
|
|
||||||
<i class="fa fa-file-archive-o" ng-show="file.type == 'application/x-zip-compressed' || file.type == 'application/x-gzip'"></i>
|
|
||||||
<i class="fa fa-file-powerpoint-o" ng-show="file.type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation'"></i>
|
|
||||||
<i class="fa fa-file-word-o" ng-show="file.type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'"></i>
|
|
||||||
<i class="fa fa-file-o" ng-show="file.type == 'application/octet-stream' || file.type == 'application/x-msdownload'"></i>
|
|
||||||
file.name
|
|
||||||
<span onclick="removeFile(file)" class="remove-row"><i class="fa fa-trash-o"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<br/>
|
<br/>
|
||||||
<span class="btn btn-danger btn-file"><i class="fa fa-plus"></i> Add Files
|
<span class="btn btn-danger btn-file"><i class="fa fa-plus"></i> Add Files
|
||||||
<input type="file" multiple>
|
<input type="file" onchange="attach(this.files)" multiple>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" onclick="cancel()">Cancel</button>
|
<button type="button" class="btn btn-default" onclick="dismiss()">Cancel</button>
|
||||||
<button type="button" class="btn btn-primary" onclick="save()" data-dismiss="modal">Save Template</button>
|
<button type="button" class="btn btn-primary" onclick="save()" data-dismiss="modal">Save Template</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue