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
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class PluginInfo(
|
||||
val name: String,
|
||||
val description: String?,
|
||||
val version: String?,
|
||||
val enabled: Boolean,
|
||||
val installed: Boolean = true,
|
||||
val source: String?,
|
||||
@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(
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.m57.hermescontrol.data.model.ModelOptionsResponse
|
||||
import com.m57.hermescontrol.data.model.PairingApproveRequest
|
||||
import com.m57.hermescontrol.data.model.PairingResponse
|
||||
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.ProfilesResponse
|
||||
import com.m57.hermescontrol.data.model.RawConfigResponse
|
||||
@@ -212,8 +212,8 @@ interface HermesApiService {
|
||||
@GET("api/logs")
|
||||
suspend fun getLogs(): Response<LogResponse>
|
||||
|
||||
@GET("api/dashboard/plugins")
|
||||
suspend fun getPlugins(): Response<List<PluginInfo>>
|
||||
@GET("api/dashboard/plugins/hub")
|
||||
suspend fun getPlugins(): Response<PluginsHubResponse>
|
||||
|
||||
@POST("api/dashboard/agent-plugins/install")
|
||||
suspend fun installPlugin(
|
||||
@@ -222,22 +222,22 @@ interface HermesApiService {
|
||||
|
||||
@DELETE("api/dashboard/agent-plugins/{name}")
|
||||
suspend fun uninstallPlugin(
|
||||
@Path("name") name: String,
|
||||
@Path("name", encoded = true) name: String,
|
||||
): Response<Unit>
|
||||
|
||||
@POST("api/dashboard/agent-plugins/{name}/update")
|
||||
suspend fun updatePlugin(
|
||||
@Path("name") name: String,
|
||||
@Path("name", encoded = true) name: String,
|
||||
): Response<Unit>
|
||||
|
||||
@POST("api/dashboard/agent-plugins/{name}/enable")
|
||||
suspend fun enablePlugin(
|
||||
@Path("name") name: String,
|
||||
@Path("name", encoded = true) name: String,
|
||||
): Response<Unit>
|
||||
|
||||
@POST("api/dashboard/agent-plugins/{name}/disable")
|
||||
suspend fun disablePlugin(
|
||||
@Path("name") name: String,
|
||||
@Path("name", encoded = true) name: String,
|
||||
): Response<Unit>
|
||||
|
||||
@GET("api/messaging/platforms")
|
||||
|
||||
@@ -32,7 +32,8 @@ class PluginsViewModel : ViewModel() {
|
||||
ApiClient.hermesApi.getPlugins()
|
||||
}
|
||||
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 {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
|
||||
Reference in new issue
Block a user