agent, ui: move to post body to avoid encodeURI complications

This commit is contained in:
Aaron Greenspan
2021-01-13 08:46:58 -07:00
committed by Aiden McClelland
parent 234fc06f76
commit 90227c0606
2 changed files with 11 additions and 10 deletions

View File

@@ -57,6 +57,15 @@ instance FromJSON RestoreBackupReq where
restoreBackupPassword <- o .:? "password" .!= Nothing
pure RestoreBackupReq { .. }
data DeleteDisksReq = DeleteDisksReq
{ deleteDisksLogicalName :: Text
} deriving (Eq, Show)
instance FromJSON DeleteDisksReq where
parseJSON = withObject "Eject Disk Req" $ \o -> do
deleteDisksLogicalName <- o .: "logicalName"
pure DeleteDisksReq { .. }
-- Handlers
postCreateBackupR :: AppId -> Handler ()
@@ -99,14 +108,7 @@ getDisksR :: Handler (JSONResponse [AppMgr.DiskInfo])
getDisksR = fmap JSONResponse . runM . handleS9ErrC $ listDisksLogic
deleteDisksR :: Handler ()
deleteDisksR = runM . handleS9ErrC $ do
logicalName <- lookupGetParam "logicalName" >>= orThrow400
ejectDiskLogic logicalName
where
orThrow400 = \case
Nothing -> throwError $ ParamsE "logicalName"
Just p -> pure p
deleteDisksR = runM . handleS9ErrC $ requireCheckJsonBody >>= ejectDiskLogic . deleteDisksLogicalName
-- Logic

View File

@@ -13,7 +13,6 @@ import { modulateTime } from 'src/app/util/misc.util'
@Injectable()
export class LiveApiService extends ApiService {
constructor (
private readonly http: HttpService,
// TODO remove app + server model from here. updates to state should be done in a separate class wrapping ApiService + App/ServerModel
@@ -63,7 +62,7 @@ export class LiveApiService extends ApiService {
}
async ejectExternalDisk (logicalName: string): Promise<Unit> {
return this.authRequest({ method: Method.DELETE, url: `/disks?logicalName=${encodeURIComponent(logicalName)}` })
return this.authRequest({ method: Method.DELETE, url: `/disks`, data: { logicalName } })
}
async updateAgent (version: string): Promise<Unit> {