fix(data,ui): update plugin info model, API service, and plugins viewmodel
This commit is contained in:
1 parent
4c572509ec
commit
6152ee42b2
3 files changed
+31
-10
No files matched your search
@@ -1,11 +1,31 @@
|
|||||||
package com.m57.hermescontrol.data.model
|
package com.m57.hermescontrol.data.model
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
data class PluginInfo(
|
data class PluginInfo(
|
||||||
val name: String,
|
val name: String,
|
||||||
val description: String?,
|
val description: String?,
|
||||||
val version: String?,
|
val version: String?,
|
||||||
val enabled: Boolean,
|
val source: String?,
|
||||||
val installed: Boolean = true,
|
@SerializedName("runtime_status") val runtimeStatus: String?,
|
||||||
|
@SerializedName("has_dashboard_manifest") val hasDashboardManifest: Boolean = false,
|
||||||
|
@SerializedName("can_remove") val canRemove: Boolean = false,
|
||||||
|
@SerializedName("can_update_git") val canUpdateGit: Boolean = false,
|
||||||
|
@SerializedName("auth_required") val authRequired: Boolean = false,
|
||||||
|
@SerializedName("auth_command") val authCommand: String? = null,
|
||||||
|
@SerializedName("user_hidden") val userHidden: Boolean = false,
|
||||||
|
) {
|
||||||
|
val enabled: Boolean
|
||||||
|
get() = runtimeStatus.equals("enabled", ignoreCase = true)
|
||||||
|
|
||||||
|
val installed: Boolean
|
||||||
|
get() =
|
||||||
|
runtimeStatus.equals("enabled", ignoreCase = true) ||
|
||||||
|
runtimeStatus.equals("disabled", ignoreCase = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
data class PluginsHubResponse(
|
||||||
|
val plugins: List<PluginInfo>,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class TogglePluginRequest(
|
data class TogglePluginRequest(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import com.m57.hermescontrol.data.model.ModelOptionsResponse
|
|||||||
import com.m57.hermescontrol.data.model.PairingApproveRequest
|
import com.m57.hermescontrol.data.model.PairingApproveRequest
|
||||||
import com.m57.hermescontrol.data.model.PairingResponse
|
import com.m57.hermescontrol.data.model.PairingResponse
|
||||||
import com.m57.hermescontrol.data.model.PairingRevokeRequest
|
import com.m57.hermescontrol.data.model.PairingRevokeRequest
|
||||||
import com.m57.hermescontrol.data.model.PluginInfo
|
import com.m57.hermescontrol.data.model.PluginsHubResponse
|
||||||
import com.m57.hermescontrol.data.model.ProfileSoulResponse
|
import com.m57.hermescontrol.data.model.ProfileSoulResponse
|
||||||
import com.m57.hermescontrol.data.model.ProfilesResponse
|
import com.m57.hermescontrol.data.model.ProfilesResponse
|
||||||
import com.m57.hermescontrol.data.model.RawConfigResponse
|
import com.m57.hermescontrol.data.model.RawConfigResponse
|
||||||
@@ -212,8 +212,8 @@ interface HermesApiService {
|
|||||||
@GET("api/logs")
|
@GET("api/logs")
|
||||||
suspend fun getLogs(): Response<LogResponse>
|
suspend fun getLogs(): Response<LogResponse>
|
||||||
|
|
||||||
@GET("api/dashboard/plugins")
|
@GET("api/dashboard/plugins/hub")
|
||||||
suspend fun getPlugins(): Response<List<PluginInfo>>
|
suspend fun getPlugins(): Response<PluginsHubResponse>
|
||||||
|
|
||||||
@POST("api/dashboard/agent-plugins/install")
|
@POST("api/dashboard/agent-plugins/install")
|
||||||
suspend fun installPlugin(
|
suspend fun installPlugin(
|
||||||
@@ -222,22 +222,22 @@ interface HermesApiService {
|
|||||||
|
|
||||||
@DELETE("api/dashboard/agent-plugins/{name}")
|
@DELETE("api/dashboard/agent-plugins/{name}")
|
||||||
suspend fun uninstallPlugin(
|
suspend fun uninstallPlugin(
|
||||||
@Path("name") name: String,
|
@Path("name", encoded = true) name: String,
|
||||||
): Response<Unit>
|
): Response<Unit>
|
||||||
|
|
||||||
@POST("api/dashboard/agent-plugins/{name}/update")
|
@POST("api/dashboard/agent-plugins/{name}/update")
|
||||||
suspend fun updatePlugin(
|
suspend fun updatePlugin(
|
||||||
@Path("name") name: String,
|
@Path("name", encoded = true) name: String,
|
||||||
): Response<Unit>
|
): Response<Unit>
|
||||||
|
|
||||||
@POST("api/dashboard/agent-plugins/{name}/enable")
|
@POST("api/dashboard/agent-plugins/{name}/enable")
|
||||||
suspend fun enablePlugin(
|
suspend fun enablePlugin(
|
||||||
@Path("name") name: String,
|
@Path("name", encoded = true) name: String,
|
||||||
): Response<Unit>
|
): Response<Unit>
|
||||||
|
|
||||||
@POST("api/dashboard/agent-plugins/{name}/disable")
|
@POST("api/dashboard/agent-plugins/{name}/disable")
|
||||||
suspend fun disablePlugin(
|
suspend fun disablePlugin(
|
||||||
@Path("name") name: String,
|
@Path("name", encoded = true) name: String,
|
||||||
): Response<Unit>
|
): Response<Unit>
|
||||||
|
|
||||||
@GET("api/messaging/platforms")
|
@GET("api/messaging/platforms")
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class PluginsViewModel : ViewModel() {
|
|||||||
ApiClient.hermesApi.getPlugins()
|
ApiClient.hermesApi.getPlugins()
|
||||||
}
|
}
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
_uiState.update { it.copy(isLoading = false, plugins = response.body().orEmpty()) }
|
val plugins = response.body()?.plugins.orEmpty()
|
||||||
|
_uiState.update { it.copy(isLoading = false, plugins = plugins) }
|
||||||
} else {
|
} else {
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
|
|||||||
Reference in new issue
Block a user