Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5d16620
implemented confirmation for deleteMap
IreLynn Jun 21, 2017
79f8ba4
only allow one mapping per data row
IreLynn Jun 26, 2017
aea361c
working on delete_mappings
IreLynn Jun 28, 2017
c176a79
fixed for IDs binding to deleted id
IreLynn Jun 28, 2017
78df6cc
re-factored mapData
IreLynn Jun 28, 2017
1111c0a
deletion of mappings works properly; hover action still wonky after m…
IreLynn Jul 2, 2017
f5ee5aa
added a billion comments and working on restructuring things but more…
IreLynn Jul 3, 2017
e15facb
moved delete button to left side; delete button shows/hides based on …
IreLynn Jul 6, 2017
e3ed26b
fixed bug with first line
IreLynn Jul 6, 2017
0c164a6
added help button which triggers alert explaining how to tag
IreLynn Jul 6, 2017
5e60083
played with buttons
IreLynn Jul 6, 2017
d84c805
added cancel button to redirect to homepage without saving map
IreLynn Jul 11, 2017
8771873
sidebar scrolls across image with u
IreLynn Jul 12, 2017
1cde9f0
fixed wonky column widths in table, centered text
IreLynn Jul 12, 2017
8f522a9
played with table CSS a little
IreLynn Jul 12, 2017
b378e29
added alert on click of Save button
IreLynn Jul 18, 2017
30fc0c3
hid login button, renamed main.py to __init__.py because that's a thing
IreLynn Jul 18, 2017
bcd5c57
edited verbiage tag==>mapping
IreLynn Jul 18, 2017
1b25553
fixed version number lol
IreLynn Jul 24, 2017
1632fd6
added 'hint' on CSV upload page informing user that point number shou…
IreLynn Jul 24, 2017
785c275
trying something with hide button
IreLynn Jul 24, 2017
97e6947
set high max content length (trying to fix csv issue)
IreLynn Jul 25, 2017
f50b751
Merge branch 'delete_mappings' of https://github.com/IreLynn/IMMP int…
IreLynn Jul 25, 2017
157913c
undid hide button thing
IreLynn Jul 25, 2017
7c1dc90
attempting try/exception in postcsv
IreLynn Jul 25, 2017
4e98f60
Revert "attempting try/exception in postcsv"
IreLynn Jul 25, 2017
ec4a50c
added cancel mapping button; having issue with display:none
IreLynn Jul 31, 2017
3b9bbca
fixed show/hide issue with cancel mappings button
IreLynn Jul 31, 2017
abe8355
fixed cancel mapping button
IreLynn Jul 31, 2017
72eb659
implemented scroll to row in table on hover functionality but it's no…
IreLynn Sep 26, 2017
3f69042
tried to fix csv issue. appears to be working on my end but tryna pus…
IreLynn Nov 1, 2017
f7aec82
cleaned up a little. csv issue appears to actually be fixed
IreLynn Nov 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions main.py → __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:test@localhost/immp'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True;
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024 # 100MB limit
db = SQLAlchemy(app)

# Database schema
class Maps(db.Model):
id = db.Column(db.Integer(), primary_key=True)
url = db.Column(db.String(512), unique=True)
csv = db.Column(db.String())
csv = db.Column(db.Text())
mapping = db.Column(db.String())

def __init__(self, url):
Expand Down Expand Up @@ -41,10 +42,10 @@ def postmap():
return redirect('/map/id='+str(map.id))


@app.route('/postcsv')
@app.route('/postcsv', methods=['POST'])
def postcsv():
id = request.args.get('mapID', 0, type=int)
csv = request.args.get('csv')
id = request.json['mapID']
csv = request.json['csv']
map = Maps.query.filter_by(id=id).first()
map.csv = csv
db.session.commit()
Expand Down
41 changes: 0 additions & 41 deletions static/imgareaselect-default.css

This file was deleted.

93 changes: 81 additions & 12 deletions static/js/create_map.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
// createMode indicates if we are or are not in create mode
var createMode = false;
var x;
var y;
var deleteMode = false;

/** Coordinates of last point clicked on image. */
var x, y;

/** data store for tagged features/rows */
var ids = [];

function mapData(x, y, id){
function insertAndMapData(x, y, id){
$('#cancelTag').hide();
console.log("Mapping id: " + id + " to coordinates " + x + "," + y);
if (id == " " || x == null){
console.log("Invalid ID");
alert("ID is not valid.");
return;
}
if(ids[id]){
console.log("Data already mapped");
return;
}
ids[id] = x + "," + y; // adds to ID array
mapData(x,y,id);
}

//////
/*var a = jQuery('<area/>', { 'shape': "circle", 'id': id, 'data-name': "1,all", 'coords': x + "," + y + ",10", 'href': "#" });

var a = $('<area />', {
'shape': 'circle',
'id': '1',
'da'
})
a['shape'] = 'circle';
a['id'] = '1';
a['data-name'] = '1,all';
a['coords'] = '191,81,10';
a['href'] = '#';
$(".mapper-map").append(a);
*/

//////

function mapData(x,y,id){
var mapHTML = "<area shape=\"circle\" ";
mapHTML += "id=\"" + id + "\" ";
mapHTML += "data-name=\"" + id + ",all\" ";
mapHTML += "coords=\"" + x + "," + y + ",10\" href=\"#\">";
$(".mapper-map").append(mapHTML);

if(!deleteMode)
$('#tagged' + id).show();

map = $('#mapper');
map.mapster('unbind')
Expand All @@ -26,28 +61,62 @@ function mapData(x, y, id){
.mapster('set', true, 'all')
.mapster('set_options', single_opts);
}
}).bind('mouseout', function () {
if (!inArea) {
map.mapster('set', false, 'all');
}
});
}

function unmapData(id){
var mapHTML;
console.log("Delete tag for id: " + id + " from coords " + ids[id]);
if (id === ""){
console.log("Invalid ID");
return;
}

$('#deleteTag' + id).hide();

delete ids[id];

$(".mapper-map").empty(); //clear html ?

map = $('#mapper');
map.mapster('unbind')

for (var row in ids){
console.log(row + " " + ids[row]);
if(ids[row]){
var coords = ids[row].split(',');
console.log(coords[0] + "," + coords[1]);
mapData(coords[0],coords[1],row);
}
}
}


/**
* gets called from map.html document ready function if
* data already exists for map
*/
function build_mappings(mappingsString){
var maps = mappingsString.split('\n');
for(var i = 0; i < maps.length - 1; i++){
to_map = maps[i].split(',');
mapData(to_map[1],to_map[2],to_map[0]);
insertAndMapData(to_map[1],to_map[2],to_map[0]);
}

}

/**
* onClick handler which is attached to the rows after clicking on image
*
*
*/
function dataClick(id){
if(createMode){
mapData(x,y,id);
if (createMode) {
insertAndMapData(x,y,id);
}
createMode = false;

// use toggle class, elements same as line 120 in csv.js @ 1111c0a373f706c7a6e0d8aa46d3a06258ea7a27
$('.unlinked').removeClass("unlinked");
$('.linked').removeClass("linked");
$('.greyOut').removeClass("greyOut");
}
}
File renamed without changes.
Loading