|
1 | 1 | package controllers |
2 | 2 |
|
3 | | -import java.net.URL |
4 | | -import java.util.{ Calendar, Date } |
5 | | -import javax.inject.Inject |
6 | | - |
7 | 3 | import api.Permission |
8 | 4 | import api.Permission._ |
9 | 5 | import models._ |
10 | | -import play.api.{ Logger, Play } |
| 6 | +import org.joda.time.DateTime |
11 | 7 | import play.api.data.Forms._ |
12 | | -import play.api.data.{ Form, Forms } |
13 | | -import play.api.libs.json.JsValue |
14 | | -import play.api.libs.json.Json |
| 8 | +import play.api.data.{Form, Forms} |
15 | 9 | import play.api.i18n.Messages |
| 10 | +import play.api.{Logger, Play} |
| 11 | +import securesocial.core.providers.{Token, UsernamePasswordProvider} |
16 | 12 | import services._ |
17 | | -import securesocial.core.providers.{ Token, UsernamePasswordProvider } |
18 | | -import org.joda.time.DateTime |
19 | | -import play.api.i18n.Messages |
20 | | -import play.api.libs.ws._ |
21 | | -import services.AppConfiguration |
22 | | -import util.{ Formatters, Mail, Publications } |
| 13 | +import util.{Formatters, Mail, Publications} |
23 | 14 |
|
| 15 | +import java.net.URL |
| 16 | +import java.util.{Calendar, Date} |
| 17 | +import javax.inject.Inject |
24 | 18 | import scala.collection.immutable.List |
25 | | -import scala.collection.mutable.{ ArrayBuffer, ListBuffer } |
26 | | -import scala.concurrent.{ Future, Await } |
27 | | -import scala.concurrent.duration._ |
28 | | -import org.apache.commons.lang.StringEscapeUtils.escapeJava |
| 19 | +import scala.collection.mutable.{ArrayBuffer, ListBuffer} |
29 | 20 |
|
30 | 21 | /** |
31 | 22 | * Spaces allow users to partition the data into realms only accessible to users with the right permissions. |
@@ -176,6 +167,8 @@ class Spaces @Inject() (spaces: SpaceService, users: UserService, events: EventS |
176 | 167 | var creatorActual: User = null |
177 | 168 | val collectionsInSpace = spaces.getCollectionsInSpace(Some(id.stringify), Some(size)) |
178 | 169 | val datasetsInSpace = datasets.listSpace(size, id.toString(), user) |
| 170 | + val spaceBytes : Long = s.spaceBytes |
| 171 | + val spaceFiles : Integer = getFilesPerSpace(id, user.get) |
179 | 172 | val publicDatasetsInSpace = datasets.listSpaceStatus(size, id.toString(), "publicAll", user) |
180 | 173 | val usersInSpace = spaces.getUsersInSpace(id, None) |
181 | 174 | var curationObjectsInSpace: List[CurationObject] = List() |
@@ -224,7 +217,7 @@ class Spaces @Inject() (spaces: SpaceService, users: UserService, events: EventS |
224 | 217 | case None => List.empty |
225 | 218 | } |
226 | 219 | sinkService.logSpaceViewEvent(s, user) |
227 | | - Ok(views.html.spaces.space(Utils.decodeSpaceElements(s), collectionsInSpace, publicDatasetsInSpace, datasetsInSpace, rs, play.Play.application().configuration().getString("SEADservices.uri"), userRoleMap, userSelections)) |
| 220 | + Ok(views.html.spaces.space(Utils.decodeSpaceElements(s), collectionsInSpace, publicDatasetsInSpace, datasetsInSpace, rs, play.Play.application().configuration().getString("SEADservices.uri"), userRoleMap, userSelections, spaceBytes, spaceFiles)) |
228 | 221 | } |
229 | 222 | case None => BadRequest(views.html.notFound(spaceTitle + " does not exist.")) |
230 | 223 | } |
@@ -421,7 +414,7 @@ class Spaces @Inject() (spaces: SpaceService, users: UserService, events: EventS |
421 | 414 | val newSpace = ProjectSpace(name = formData.name, description = formData.description, |
422 | 415 | created = new Date, creator = userId, homePage = formData.homePage, |
423 | 416 | logoURL = formData.logoURL, bannerURL = formData.bannerURL, |
424 | | - collectionCount = 0, datasetCount = 0, userCount = 0, metadata = List.empty, |
| 417 | + collectionCount = 0, datasetCount = 0, userCount = 0, spaceBytes = 0, metadata = List.empty, |
425 | 418 | resourceTimeToLive = formData.resourceTimeToLive * 60 * 60 * 1000L, isTimeToLiveEnabled = formData.isTimeToLiveEnabled, |
426 | 419 | status = formData.access, |
427 | 420 | affiliatedSpaces = formData.affSpace) |
@@ -648,4 +641,14 @@ class Spaces @Inject() (spaces: SpaceService, users: UserService, events: EventS |
648 | 641 | } |
649 | 642 | } |
650 | 643 |
|
| 644 | + private def getFilesPerSpace(spaceId: UUID, user: models.User) : Integer = { |
| 645 | + var spaceFiles: Integer = 0 |
| 646 | + val allDatasetsInSpace = datasets.listSpace(0, spaceId.toString(), Some(user)) |
| 647 | + for (ds <- allDatasetsInSpace) { |
| 648 | + val files_in_ds = ds.files.length |
| 649 | + spaceFiles += files_in_ds |
| 650 | + } |
| 651 | + spaceFiles |
| 652 | + } |
| 653 | + |
651 | 654 | } |
0 commit comments