Skip to content

Commit

Permalink
Merge pull request #1290 from ProjectSidewalk/develop
Browse files Browse the repository at this point in the history
v4.5.0
  • Loading branch information
misaugstad authored Jul 21, 2018
2 parents 7bb222f + 0065e08 commit 5226d14
Show file tree
Hide file tree
Showing 142 changed files with 2,479 additions and 2,856 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public/javascripts/FAQ/build/*
public/javascripts/Progress/build/*
download

#public/javascripts/SVLabel/build/SVLabel.js
# Keys
rootkey.csv
special_api_key.txt

# sidewalk-webpage-binary directory
sidewalk-webpage/
Expand Down
38 changes: 31 additions & 7 deletions app/controllers/AdminController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ package controllers

import java.util.UUID
import javax.inject.Inject
import java.sql.Time
import java.net.URLDecoder

import com.mohiva.play.silhouette.api.{Environment, LogoutEvent, Silhouette}
import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import com.vividsolutions.jts.geom.Coordinate
import controllers.headers.ProvidesHeader
import formats.json.TaskFormats._
import formats.json.UserRoleSubmissionFormats._
import models.audit.{AuditTaskInteraction, AuditTaskInteractionTable, AuditTaskTable, InteractionWithLabel}
import models.attribute.{GlobalAttribute, GlobalAttributeTable}
import models.audit.{AuditTaskInteractionTable, AuditTaskTable, InteractionWithLabel}
import models.daos.slick.DBTableDefinitions.UserTable
import models.label.LabelTable.LabelMetadata
import models.label.{LabelPointTable, LabelTable}
import models.label.{LabelPointTable, LabelTable, LabelTypeTable}
import models.mission.MissionTable
import models.region.{RegionCompletionTable, RegionTable}
import models.street.{StreetEdge, StreetEdgeTable}
import models.region.RegionCompletionTable
import models.street.StreetEdgeTable
import models.user.{RoleTable, User, UserRoleTable, WebpageActivityTable}
import models.daos.UserDAOImpl
import org.geotools.geometry.jts.JTS
import org.geotools.referencing.CRS
import play.api.libs.json.{JsArray, JsError, JsObject, JsValue, Json}
import play.api.libs.json.{JsArray, JsError, JsObject, Json}
import play.extras.geojson
import play.api.mvc.BodyParsers

Expand Down Expand Up @@ -101,6 +101,30 @@ class AdminController @Inject() (implicit val env: Environment[User, SessionAuth
}
}

/**
* Get a list of all global attributes
*
* @return
*/
def getAllAttributes = UserAwareAction.async { implicit request =>
if (isAdmin(request.identity)) {
val attributes: List[GlobalAttribute] = GlobalAttributeTable.getAllGlobalAttributes
val features: List[JsObject] = attributes.map { attribute =>
val point = geojson.Point(geojson.LatLng(attribute.lat.toDouble, attribute.lng.toDouble))
val properties = Json.obj(
"attribute_id" -> attribute.globalAttributeId,
"label_type" -> LabelTypeTable.labelTypeIdToLabelType(attribute.labelTypeId),
"severity" -> attribute.severity
)
Json.obj("type" -> "Feature", "geometry" -> point, "properties" -> properties)
}
val featureCollection = Json.obj("type" -> "FeatureCollection", "features" -> features)
Future.successful(Ok(featureCollection))
} else {
Future.successful(Redirect("/"))
}
}

/**
* Returns audit coverage of each neighborhood
*
Expand Down
Loading

0 comments on commit 5226d14

Please sign in to comment.