Skip to content

Commit

Permalink
Option to reset storage sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq committed Oct 26, 2020
1 parent ea8cf8a commit 0ecb393
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ private[server] final class ShadowCloudApiImpl(sc: ShadowCloudExtension) extends
Future.successful(sc.modules.storage.defaultConfig(storageType))
}

def resetStorageSessions(storageId: StorageId) =
for {
_ sc.sessions.provider.dropSessions(storageId)
_ suspendStorage(storageId)
_ resumeStorage(storageId)
} yield Done

// -----------------------------------------------------------------------
// Keys
// -----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ trait ShadowCloudApi {
def getStorageHealth(storageId: StorageId): Future[StorageHealth]
def getStorageTypes(): Future[Set[String]]
def getDefaultStorageConfig(storageType: String): Future[SerializedProps]
def resetStorageSessions(storageId: StorageId): Future[Done]

// -----------------------------------------------------------------------
// Keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ object AjaxApi extends ShadowCloudApi with FileApi with SCApiMeta {
apiClient.getDefaultStorageConfig(storageType).call()
}

def resetStorageSessions(storageId: StorageId): Future[Done] = {
apiClient.resetStorageSessions(storageId).call()
}

// -----------------------------------------------------------------------
// Keys
// -----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class StorageConfigView(storageId: StorageId)(implicit context: AppContext, regi
.foreach(_ regionContext.updateAll())
}

def doReset() = {
context.api
.resetStorageSessions(storageId)
.foreach(_ regionContext.updateStorage(storageId))
}

val suspendButton =
if (storageStatus.suspended)
Button(ButtonStyle.success, ButtonSize.extraSmall)(AppIcons.resume, context.locale.resume, onclick := Callback.onClick(_ doResume()))
Expand All @@ -69,7 +75,10 @@ class StorageConfigView(storageId: StorageId)(implicit context: AppContext, regi
val deleteButton =
Button(ButtonStyle.danger, ButtonSize.extraSmall)(AppIcons.delete, context.locale.delete, onclick := Callback.onClick(_ doDelete()))

ButtonGroup(ButtonGroupSize.extraSmall, suspendButton, deleteButton)
val resetButton =
Button(ButtonStyle.info, ButtonSize.extraSmall)(AppIcons.refresh, context.locale.reset, onclick := Callback.onClick(_ => doReset()))

ButtonGroup(ButtonGroupSize.extraSmall, suspendButton, deleteButton, resetButton)
}

private[this] def renderConfigField(storageStatus: StorageStatus) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ trait AppLocale {
def move: String
def copy: String
def rename: String
def reset: String

def rootPath: String
def emptyPath: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private[locales] object English extends AppLocale {
val move = "Move"
val copy = "Copy"
val rename = "Rename"
val reset = "Reset"

val rootPath = "(Root)"
val emptyPath = "(Empty)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private[locales] object Russian extends AppLocale {
val move = "Переместить"
val copy = "Копировать"
val rename = "Переименовать"
val reset = "Сбросить"

val rootPath = "(Корень)"
val emptyPath = "(Пусто)"
Expand Down

0 comments on commit 0ecb393

Please sign in to comment.