Commit f65fca93 authored by Josh's avatar Josh
Browse files

need to reconfigure to mvc

parent 86e9aea7
......@@ -115,8 +115,8 @@ def getDBImageList():
return { "data": imageList }
@app.route("/copy-to-static", methods=["GET", "POST"])
def copyImageToStatic():
@app.route("/copy-original-to-static", methods=["GET", "POST"])
def copyOriginalImageToStatic():
if request.method == "POST":
imgLoc = OR_LOC.joinpath( request.get_data().decode( "utf-8" ) )
print( imgLoc )
......@@ -136,6 +136,19 @@ def copyImageToStatic():
else:
return jsonify( "Not Found" )
@app.route("/copy-sliced-128-to-static", methods=["GET", "POST"])
def copySlicedImageToStatic():
if request.method == "POST":
requestedFile = request.get_data().decode( "utf-8" )
print( SL_LOC )
imgLoc = SL_LOC.joinpath( "GeoEye-0" ).joinpath( "128" ).joinpath( "{}".format( requestedFile ) )
print( imgLoc )
if imgLoc.is_file():
# Copy image to active media
shutil.copy( imgLoc, ACTIVE_MEDIA.joinpath( imgLoc.name ) )
return jsonify( "static/activeMedia/{}".format( imgLoc.name ) )
else:
return jsonify( "Not Found" )
def open_browser():
webbrowser.open_new( "http://127.0.0.1:2000/" )
......
var availableImageNames;
/*
* Contains the logic to query the image database
*/
class ImageDBController {
constructor() {
this._imageList;
// image currently selected
this._activeImage;
// contains images associated with the active image
this._availableImages;
loadImageList( ( ev ) => this.setImageListCallback( ev ) );
}
setImageListCallback( returnData ) {
console.log( "database controller", returnData );
}
}
/*
* DATABASE VIEWER FUNCTIONALITY
*/
......@@ -50,6 +72,11 @@ class DBViewer extends HTMLElement {
this._sliceSelector = false;
this._processedTypeSelector = false;
this._imageSelectorID = "image-select";
this._sliceSizeSelectorID = "slice-sizes";
this._sliceSelectorID = "slice";
this._processedTypeSelectorID = "processed";
this.appendChild( DBViewerTemplate.content.cloneNode( true ) );
}
......@@ -60,29 +87,59 @@ class DBViewer extends HTMLElement {
copyToStatic( newImage, this.updateImage, false );
}
updateOriginalImageCallback( returnData ) {
console.log( "updateOriginalImageCallback" )
availableImageNames = returnData;
console.log( availableImageNames );
/* Callback for updating image url */
var controller = document.getElementById( "originalImage" ).updateImage( returnData["mainImageUrl"] );
}
updateSlicedImageCallback( returnData ) {
console.log( returnData );
var sliceController = document.getElementById( "sliceImage" ).updateImage( returnData );
}
sliceSizeSelected( ev ) {
console.log( "slice size selected" );
console.log( "sliceSizeSelected" );
var select = document.getElementById( "slice-sizes" );
// Show available slice names
var sliceSelect = document.getElementById( "slice-selector" );
if ( select.value == "128" )
sliceSelect.elementList = availableImageNames["s128"];
else if ( select.value == "256" )
sliceSelect.elementList = availableImageNames["s256"];
else if ( select.value == "256" )
sliceSelect.elementList = availableImageNames["s512"];
// Show selector
sliceSelect.show();
}
sliceSelected( ev ) {
console.log( "slice selected" );
console.log( "sliceSelected" );
// Load Slice
var sliceSelect = document.getElementById( "slice" );
var sizeSelect = document.getElementById( "slice-sizes" );
console.log( sliceSelect.value );
if ( sizeSelect.value == "128" )
copySliced128ToStatic( sliceSelect.value, this.updateSlicedImageCallback, false );
// Show Processed Image Options
}
processedTypeSelected( ev ) {
console.log( "processed type selected" );
}
updateOriginalImageCallback( returnData ) {
console.log( returnData )
/* Callback for updating image url */
var controller = document.getElementById( "originalImage" ).updateImage( returnData["mainImageUrl"] );
console.log( "processedTypeSelected" );
}
newImageSelected( ev ) {
var select = document.getElementById( "image-select" );
copyToStatic( select.value, this.updateOriginalImageCallback, false );
console.log( "newImageSelected" );
var select = document.getElementById( "image-select" );
// Show size selector
var sizeSelect = document.getElementById( "slice-sizes-selector" );
sizeSelect.show();
copyOriginalToStatic( select.value, this.updateOriginalImageCallback, false );
}
connectedCallback() {
......@@ -90,19 +147,20 @@ class DBViewer extends HTMLElement {
var dbViewerCont = document.getElementsByClassName( "db-view-container" )[0];
// CREATE IMAGE CONTROLLERS
var sW = screen.width;
var sH = screen.height;
// Image controller for original image
this._originalImageController = new ImageController( "original-image", 450, 450, "static/default.jpg" );
this._originalImageController = new ImageController( "original-image", sH * ( 1 / 2 ), sH * ( 1 / 2 ), "static/default.jpg" );
this._originalImageController.id = "originalImage";
this._originalImageController.style.gridArea = "original";
// Image controller for sliced, unprocessed image
this._slicedImageController = new ImageController( "slice-image", 450, 450, "static/default.jpg" );
this._slicedImageController = new ImageController( "slice-image", sH * ( 1 / 3 ), sH * ( 1 / 3 ), "static/default.jpg" );
this._slicedImageController.id = "sliceImage";
this._slicedImageController.style.gridArea = "slice";
// Image controller for processed image
this._processedImageController = new ImageController( "processed-image", 450, 450, "static/default.jpg" );
this._processedImageController = new ImageController( "processed-image", sH * ( 1 / 3 ), sH * ( 1 / 3 ), "static/default.jpg" );
this._processedImageController.id = "processedSlice";
this._processedImageController.style.gridArea = "processed";
......@@ -113,16 +171,28 @@ class DBViewer extends HTMLElement {
console.log( this._imageList )
// Image selector
this._imageSelector = new ListSelector( this._imageList, "image-select", "Available Images: ", ( ev ) => this.newImageSelected( ev ) );
this._imageSelector = new ListSelector( this._imageList,
this._imageSelectorID,
"Available Images: ",
( ev ) => this.newImageSelected( ev ) );
// Slice Size Selector
this._sliceSizeSelector = new ListSelector( [], "slice-sizes", "Available Slice Sizes: ", ( ev ) => this.sliceSizeSelected( ev ) );
this._sliceSizeSelector = new ListSelector( this._sliceSizes,
this._sliceSizeSelectorID,
"Available Slice Sizes: ",
( ev ) => this.sliceSizeSelected( ev ) );
// Slice Selector
this._sliceSelector = new ListSelector( [], "slice-selector", "Available Slices: ", ( ev ) => this.sliceSelected( ev ) );
this._sliceSelector = new ListSelector( [],
this._sliceSelectorID,
"Available Slices: ",
( ev ) => this.sliceSelected( ev ) );
// Processed Selector
this._processedTypeSelector = new ListSelector( [], "processed-selector", "Available Processed: ", ( ev ) => this.processedTypeSelected( ev ) );
this._processedTypeSelector = new ListSelector( [],
this._processedTypeSelectorID,
"Available Processed: ",
( ev ) => this.processedTypeSelected( ev ) );
// Add Selectors
this._toolBar.appendChild( this._imageSelector );
......@@ -131,9 +201,9 @@ class DBViewer extends HTMLElement {
this._toolBar.appendChild( this._processedTypeSelector );
this._imageSelector.show();
this._sliceSizeSelector.show();
this._sliceSelector.show();
this._processedTypeSelector.show();
this._sliceSizeSelector.hide();
this._sliceSelector.hide();
this._processedTypeSelector.hide();
dbViewerCont.appendChild( this._originalImageController );
......@@ -143,12 +213,12 @@ class DBViewer extends HTMLElement {
dbViewerCont.style.display = "grid";
dbViewerCont.style.gridTemplateRows = "100px 50px 400px 1fr";
dbViewerCont.style.gridTemplateColumns = "450px 1fr 400px 1fr 450px";
dbViewerCont.style.gridTemplateRows = `100px 50px auto`;
dbViewerCont.style.gridTemplateColumns = `${sH*(1/2)}px 1fr ${sH*(1/3)}px 1fr ${sH*(1/3)}px`;
dbViewerCont.style.gridTemplateAreas = `"toolbar toolbar toolbar toolbar toolbar "
". . . . . "
"original . slice . processed"
"original . slcie . processed"`;
"original . . . . "
"original . slice . processed"`;
}
}
......@@ -157,8 +227,9 @@ class DBViewer extends HTMLElement {
class ListSelector extends HTMLElement {
constructor( elementList, id, label, onSelectCallback ) {
super();
this.id = `${id}-selector`;
this._elementList = elementList;
this._id = id;
this._id = id; // select id
this._label = label;
this._onSelectCallback = onSelectCallback;
}
......
......@@ -86,8 +86,29 @@ function loadImageList( callback )
appGET( "/image-list", callback, false, false );
}
// copy image to static folder
function copyToStatic( imageName, successCallback, errorCallback )
// copy original image to static folder
function copyOriginalToStatic( imageName, successCallback, errorCallback )
{
appPOST( "/copy-to-static", successCallback, errorCallback, data=imageName );
appPOST( "/copy-original-to-static", successCallback, errorCallback, data=imageName );
}
// copy sliced image to static folder
function copySliced128ToStatic( imageName, successCallback, errorCallback )
{
console.log( "copy 128" );
appPOST( "/copy-sliced-128-to-static", successCallback, errorCallback, data=imageName );
}
// copy sliced image to static folder
function copySliced256ToStatic( imageName, successCallback, errorCallback )
{
console.log( "copy 256" );
appPOST( "/copy-sliced-256-to-static", successCallback, errorCallback, data=imageName );
}
// copy sliced image to static folder
function copySliced512ToStatic( imageName, successCallback, errorCallback )
{
console.log( "copy 512" );
appPOST( "/copy-sliced-512-to-static", successCallback, errorCallback, data=imageName );
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment