mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
adds action listings to AIS response
This commit is contained in:
committed by
Aiden McClelland
parent
39867478d0
commit
54ae7f82d6
@@ -303,6 +303,7 @@ getInstalledAppByIdLogic appId = do
|
|||||||
, appInstalledFullConfiguredRequirements = []
|
, appInstalledFullConfiguredRequirements = []
|
||||||
, appInstalledFullUninstallAlert = Nothing
|
, appInstalledFullUninstallAlert = Nothing
|
||||||
, appInstalledFullRestoreAlert = Nothing
|
, appInstalledFullRestoreAlert = Nothing
|
||||||
|
, appInstalledFullActions = []
|
||||||
}
|
}
|
||||||
serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|]
|
serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|]
|
||||||
let remapped = remapAppMgrInfo jobCache serverApps
|
let remapped = remapAppMgrInfo jobCache serverApps
|
||||||
@@ -339,15 +340,16 @@ getInstalledAppByIdLogic appId = do
|
|||||||
then LanAddress . (".onion" `Text.replace` ".local") . unTorAddress <$> infoResTorAddress
|
then LanAddress . (".onion" `Text.replace` ".local") . unTorAddress <$> infoResTorAddress
|
||||||
else Nothing
|
else Nothing
|
||||||
pure AppInstalledFull { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version)
|
pure AppInstalledFull { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version)
|
||||||
, appInstalledFullStatus = status
|
, appInstalledFullStatus = status
|
||||||
, appInstalledFullVersionInstalled = version
|
, appInstalledFullVersionInstalled = version
|
||||||
, appInstalledFullInstructions = instructions
|
, appInstalledFullInstructions = instructions
|
||||||
, appInstalledFullLastBackup = backupTime
|
, appInstalledFullLastBackup = backupTime
|
||||||
, appInstalledFullTorAddress = infoResTorAddress
|
, appInstalledFullTorAddress = infoResTorAddress
|
||||||
, appInstalledFullLanAddress = lanAddress
|
, appInstalledFullLanAddress = lanAddress
|
||||||
, appInstalledFullConfiguredRequirements = HM.elems requirements
|
, appInstalledFullConfiguredRequirements = HM.elems requirements
|
||||||
, appInstalledFullUninstallAlert = manifest >>= AppManifest.appManifestUninstallAlert
|
, appInstalledFullUninstallAlert = manifest >>= AppManifest.appManifestUninstallAlert
|
||||||
, appInstalledFullRestoreAlert = manifest >>= AppManifest.appManifestRestoreAlert
|
, appInstalledFullRestoreAlert = manifest >>= AppManifest.appManifestRestoreAlert
|
||||||
|
, appInstalledFullActions = fromMaybe [] $ AppManifest.appManifestActions <$> manifest
|
||||||
}
|
}
|
||||||
runMaybeT (installing <|> installed) `orThrowM` NotFoundE "appId" (show appId)
|
runMaybeT (installing <|> installed) `orThrowM` NotFoundE "appId" (show appId)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import Lib.Types.Core
|
|||||||
import Lib.Types.Emver
|
import Lib.Types.Emver
|
||||||
import Lib.Types.Emver.Orphans ( )
|
import Lib.Types.Emver.Orphans ( )
|
||||||
import Lib.Types.NetAddress
|
import Lib.Types.NetAddress
|
||||||
|
import qualified Lib.External.AppManifest as Manifest
|
||||||
data AppBase = AppBase
|
data AppBase = AppBase
|
||||||
{ appBaseId :: AppId
|
{ appBaseId :: AppId
|
||||||
, appBaseTitle :: Text
|
, appBaseTitle :: Text
|
||||||
@@ -137,6 +138,7 @@ data AppInstalledFull = AppInstalledFull
|
|||||||
, appInstalledFullConfiguredRequirements :: [Stripped AppDependencyRequirement]
|
, appInstalledFullConfiguredRequirements :: [Stripped AppDependencyRequirement]
|
||||||
, appInstalledFullUninstallAlert :: Maybe Text
|
, appInstalledFullUninstallAlert :: Maybe Text
|
||||||
, appInstalledFullRestoreAlert :: Maybe Text
|
, appInstalledFullRestoreAlert :: Maybe Text
|
||||||
|
, appInstalledFullActions :: [Manifest.Action]
|
||||||
}
|
}
|
||||||
instance ToJSON AppInstalledFull where
|
instance ToJSON AppInstalledFull where
|
||||||
toJSON AppInstalledFull {..} = object
|
toJSON AppInstalledFull {..} = object
|
||||||
@@ -152,6 +154,7 @@ instance ToJSON AppInstalledFull where
|
|||||||
, "status" .= appInstalledFullStatus
|
, "status" .= appInstalledFullStatus
|
||||||
, "uninstallAlert" .= appInstalledFullUninstallAlert
|
, "uninstallAlert" .= appInstalledFullUninstallAlert
|
||||||
, "restoreAlert" .= appInstalledFullRestoreAlert
|
, "restoreAlert" .= appInstalledFullRestoreAlert
|
||||||
|
, "actions" .= appInstalledFullActions
|
||||||
]
|
]
|
||||||
|
|
||||||
data AppVersionInfo = AppVersionInfo
|
data AppVersionInfo = AppVersionInfo
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import qualified Data.String as String
|
|||||||
import Lib.Algebra.Domain.AppMgr.Types
|
import Lib.Algebra.Domain.AppMgr.Types
|
||||||
import Lib.Algebra.Domain.AppMgr.TH
|
import Lib.Algebra.Domain.AppMgr.TH
|
||||||
import Lib.Error
|
import Lib.Error
|
||||||
import Lib.External.AppManifest
|
import qualified Lib.External.AppManifest as Manifest
|
||||||
import Lib.TyFam.ConditionalData
|
import Lib.TyFam.ConditionalData
|
||||||
import Lib.Types.Core ( AppId(..)
|
import Lib.Types.Core ( AppId(..)
|
||||||
, AppContainerStatus(..)
|
, AppContainerStatus(..)
|
||||||
@@ -65,8 +65,9 @@ data InfoRes a = InfoRes
|
|||||||
:: Include
|
:: Include
|
||||||
(Either_ (DefaultEqSym1 'OnlyDependencies) (ElemSym1 'IncludeDependencies) a)
|
(Either_ (DefaultEqSym1 'OnlyDependencies) (ElemSym1 'IncludeDependencies) a)
|
||||||
(HM.HashMap AppId DependencyInfo)
|
(HM.HashMap AppId DependencyInfo)
|
||||||
, infoResManifest :: Include (Either_ (DefaultEqSym1 'OnlyManifest) (ElemSym1 'IncludeManifest) a) AppManifest
|
, infoResManifest
|
||||||
, infoResStatus :: Include (Either_ (DefaultEqSym1 'OnlyStatus) (ElemSym1 'IncludeStatus) a) AppContainerStatus
|
:: Include (Either_ (DefaultEqSym1 'OnlyManifest) (ElemSym1 'IncludeManifest) a) Manifest.AppManifest
|
||||||
|
, infoResStatus :: Include (Either_ (DefaultEqSym1 'OnlyStatus) (ElemSym1 'IncludeStatus) a) AppContainerStatus
|
||||||
}
|
}
|
||||||
instance SingI (a :: Either OnlyInfoFlag [IncludeInfoFlag]) => FromJSON (InfoRes a) where
|
instance SingI (a :: Either OnlyInfoFlag [IncludeInfoFlag]) => FromJSON (InfoRes a) where
|
||||||
parseJSON = withObject "AppMgr Info/List Response" $ \o -> do
|
parseJSON = withObject "AppMgr Info/List Response" $ \o -> do
|
||||||
|
|||||||
28
agent/src/Lib/External/AppManifest.hs
vendored
28
agent/src/Lib/External/AppManifest.hs
vendored
@@ -47,6 +47,32 @@ instance FromJSON AssetMapping where
|
|||||||
assetMappingOverwrite <- o .: "overwrite"
|
assetMappingOverwrite <- o .: "overwrite"
|
||||||
pure $ AssetMapping { .. }
|
pure $ AssetMapping { .. }
|
||||||
|
|
||||||
|
data Action = Action
|
||||||
|
{ actionId :: Text
|
||||||
|
, actionName :: Text
|
||||||
|
, actionDescription :: Text
|
||||||
|
, actionWarning :: Maybe Text
|
||||||
|
, actionAllowedStatuses :: [AppContainerStatus]
|
||||||
|
}
|
||||||
|
instance FromJSON Action where
|
||||||
|
parseJSON = withObject "AppAction" $ \o -> do
|
||||||
|
actionId <- o .: "id"
|
||||||
|
actionName <- o .: "name"
|
||||||
|
actionDescription <- o .: "description"
|
||||||
|
actionWarning <- o .:? "warning"
|
||||||
|
actionAllowedStatuses <- o .: "allowed-statuses"
|
||||||
|
pure Action { .. }
|
||||||
|
instance ToJSON Action where
|
||||||
|
toJSON Action {..} =
|
||||||
|
object
|
||||||
|
$ [ "id" .= actionId
|
||||||
|
, "name" .= actionName
|
||||||
|
, "description" .= actionDescription
|
||||||
|
, "allowedStatuses" .= actionAllowedStatuses
|
||||||
|
]
|
||||||
|
<> maybeToList (("warning" .=) <$> actionWarning)
|
||||||
|
|
||||||
|
|
||||||
data AppManifest where
|
data AppManifest where
|
||||||
AppManifest ::{ appManifestId :: AppId
|
AppManifest ::{ appManifestId :: AppId
|
||||||
, appManifestVersion :: Version
|
, appManifestVersion :: Version
|
||||||
@@ -62,6 +88,7 @@ data AppManifest where
|
|||||||
, appManifestDependencies :: HM.HashMap AppId VersionRange
|
, appManifestDependencies :: HM.HashMap AppId VersionRange
|
||||||
, appManifestUninstallAlert :: Maybe Text
|
, appManifestUninstallAlert :: Maybe Text
|
||||||
, appManifestRestoreAlert :: Maybe Text
|
, appManifestRestoreAlert :: Maybe Text
|
||||||
|
, appManifestActions :: [Action]
|
||||||
} -> AppManifest
|
} -> AppManifest
|
||||||
|
|
||||||
uiAvailable :: AppManifest -> Bool
|
uiAvailable :: AppManifest -> Bool
|
||||||
@@ -83,6 +110,7 @@ instance FromJSON AppManifest where
|
|||||||
appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo
|
appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo
|
||||||
appManifestUninstallAlert <- o .:? "uninstall-alert"
|
appManifestUninstallAlert <- o .:? "uninstall-alert"
|
||||||
appManifestRestoreAlert <- o .:? "restore-alert"
|
appManifestRestoreAlert <- o .:? "restore-alert"
|
||||||
|
appManifestActions <- o .: "actions"
|
||||||
pure $ AppManifest { .. }
|
pure $ AppManifest { .. }
|
||||||
where
|
where
|
||||||
parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal")
|
parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal")
|
||||||
|
|||||||
Reference in New Issue
Block a user