Skip to content

Commit

Permalink
Merge pull request #85 from developmentseed/non-geospatial
Browse files Browse the repository at this point in the history
Non Geospatial
  • Loading branch information
ingalls authored Aug 19, 2020
2 parents b3ec570 + 85c61e7 commit 61ab659
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 7 deletions.
30 changes: 30 additions & 0 deletions migrations/versions/1e7eb18a9fe8_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""empty message
Revision ID: 1e7eb18a9fe8
Revises: 7abacee99e4d
Create Date: 2020-08-19 08:51:59.096778
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '1e7eb18a9fe8'
down_revision = '7abacee99e4d'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('imagery', sa.Column('fmt', sa.String(), nullable=True))
op.execute("UPDATE imagery SET fmt = 'wms'")
op.alter_column('imagery', 'fmt', nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('imagery', 'fmt')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions ml_enabler/models/dtos/ml_model_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ImageryDTO(Model):
model_id = IntType(required=True)
name = StringType(required=True)
url = StringType(required=True)
fmt = StringType(required=True)

class TaskDTO(Model):
""" Describes JSON of an Task """
Expand Down
12 changes: 10 additions & 2 deletions ml_enabler/models/imagery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class Imagery(db.Model):

name = db.Column(db.String, nullable=False)
url = db.Column(db.String, nullable=False)
fmt = db.Column(db.String, nullable=False)

def create(self, model_id: int, imagery: dict):
""" Creates and saves the current model to the DB """

self.model_id = model_id
self.name = imagery.get("name")
self.url = imagery.get("url")
self.fmt = imagery.get("fmt")

db.session.add(self)
db.session.commit()
Expand All @@ -34,6 +36,7 @@ def as_dto(self):
imagery_dto.model_id = self.model_id
imagery_dto.name = self.name
imagery_dto.url = self.url
imagery_dto.fmt = self.fmt

return imagery_dto

Expand All @@ -42,6 +45,7 @@ def get(imagery_id: int):
Imagery.id,
Imagery.name,
Imagery.url,
Imagery.fmt,
Imagery.model_id
).filter(Imagery.id == imagery_id)

Expand All @@ -56,15 +60,17 @@ def list(model_id: int):
query = db.session.query(
Imagery.id,
Imagery.name,
Imagery.url
Imagery.url,
Imagery.fmt
).filter(Imagery.model_id == model_id)

imagery = []
for img in query.all():
imagery.append({
"id": img[0],
"name": img[1],
"url": img[2]
"url": img[2],
"fmt": img[3]
})

return imagery
Expand All @@ -74,6 +80,8 @@ def update(self, update: dict):
self.name = update["name"]
if update.get("url") is not None:
self.url = update["url"]
if update.get("fmt") is not None:
self.url = update["fmt"]

db.session.commit()

17 changes: 15 additions & 2 deletions web/src/components/Imagery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@
</div>
<div class='border border--gray-light round col col--12 px12 py12 clearfix'>
<div class='grid grid--gut12'>
<div class='col col--12 py6'>
<div class='col col--8 py6'>
<label>Imagery Name</label>
<input v-model='imagery.name' class='input' placeholder='Imagery Name'/>
</div>

<div class='col col--4 py6'>
<label>Imagery Format</label>
<div class='select-container w-full'>
<select v-model='imagery.fmt' class='select'>
<option value='wms'>WMS</option>
<option value='list'>Chip List</option>
</select>
<div class='select-arrow'></div>
</div>
</div>

<div class='col col--12 py6'>
<label>Imagery Url</label>
<input v-model='imagery.url' class='input' placeholder='Imagery Name'/>
Expand Down Expand Up @@ -57,6 +68,7 @@ export default {
imageryId: false,
modelId: false,
name: '',
fmt: 'wms',
url: ''
}
};
Expand Down Expand Up @@ -101,7 +113,8 @@ export default {
body: JSON.stringify({
modelId: this.imagery.modelId,
name: this.imagery.name,
url: this.imagery.url
url: this.imagery.url,
fmt: this.imagery.fmt
})
});
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/Model.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
<template v-else>
<div :key='img.id' v-for='img in imagery' @click='editImagery(img.id)' class='cursor-pointer col col--12'>
<div class='col col--12 grid py6 px12 bg-darken10-on-hover'>
<h3 class='txt-h4 fl' v-text='img.name'></h3>
<div class='col col--8'><h3 class='txt-h4 fl' v-text='img.name'></h3></div>
<div class='col col--4'><div v-text='img.fmt' class='fr mx3 bg-blue-faint bg-blue-on-hover color-white-on-hover color-blue px6 py3 round txt-xs txt-bold'></div></div>
</div>
</div>
</template>
Expand Down
8 changes: 6 additions & 2 deletions web/src/components/prediction/Stack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@
<label>Imagery Source:</label>
<div class='border border--gray-light round my12'>
<div @click='params.image = img' :key='img.id' v-for='img in imagery' class='col col--12 cursor-pointer bg-darken10-on-hover'>
<h3 v-if='params.image.id === img.id' class='px12 py6 txt-h4 w-full bg-gray color-white round' v-text='img.name'></h3>
<h3 v-else class='txt-h4 round px12 py6' v-text='img.name'></h3>
<div class='w-full py6 px6' :class='{
"bg-gray-light": params.image.id === img.id
}'>
<span class='txt-h4 round' v-text='img.name'/>
<div v-text='img.fmt' class='fr mx3 bg-blue-faint bg-blue-on-hover color-white-on-hover color-blue px6 py3 round txt-xs txt-bold'></div>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 61ab659

Please sign in to comment.