From 8eac36a1d78a50aeb6e38e634c4deb546758c750 Mon Sep 17 00:00:00 2001 From: Serhii Manko Date: Mon, 19 Sep 2022 16:52:18 +0300 Subject: [PATCH] Upload the ipa files for the iOS platform Signed-off-by: Serhii Manko --- .../stf/app-state/app-state-provider.js | 3 + .../enhance-device/enhance-device-service.js | 5 ++ .../components/stf/install/install-service.js | 58 ++++++++++++------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/res/app/components/stf/app-state/app-state-provider.js b/res/app/components/stf/app-state/app-state-provider.js index 6653817789..ef74f2cc21 100644 --- a/res/app/components/stf/app-state/app-state-provider.js +++ b/res/app/components/stf/app-state/app-state-provider.js @@ -5,6 +5,9 @@ module.exports = function AppStateProvider() { }, user: { settings: {} + }, + device: { + platform: '' } } diff --git a/res/app/components/stf/device/enhance-device/enhance-device-service.js b/res/app/components/stf/device/enhance-device/enhance-device-service.js index 4346dffdbf..0cd5135532 100644 --- a/res/app/components/stf/device/enhance-device/enhance-device-service.js +++ b/res/app/components/stf/device/enhance-device/enhance-device-service.js @@ -94,10 +94,15 @@ module.exports = function EnhanceDeviceServiceFactory($filter, AppState) { return url } + function enhanceDeviceAppState(device) { + AppState.device.platform = device.platform + } + service.enhance = function(device) { setState(device) enhanceDevice(device) enhanceDeviceDetails(device) + enhanceDeviceAppState(device) } return service diff --git a/res/app/components/stf/install/install-service.js b/res/app/components/stf/install/install-service.js index 3c7cd98ee9..de56713ccc 100644 --- a/res/app/components/stf/install/install-service.js +++ b/res/app/components/stf/install/install-service.js @@ -7,6 +7,7 @@ module.exports = function InstallService( , $http , $filter , StorageService +, AppState ) { var installService = Object.create(null) @@ -71,9 +72,9 @@ module.exports = function InstallService( installation.update(uploadResult.progress / 2, uploadResult.lastData) installation.manifest = uploadResult.body return control.install({ - href: installation.href - , manifest: installation.manifest - , launch: installation.launch + href: installation.href, + manifest: installation.manifest, + launch: installation.launch }) .progressed(function(result) { installation.update(50 + result.progress / 2, result.lastData) @@ -89,12 +90,13 @@ module.exports = function InstallService( installService.installFile = function(control, $files) { var installation = new Installation('uploading') + let isIOSPlatform = AppState.device.platform === 'iOS' $rootScope.$broadcast('installation', installation) return StorageService.storeFile('apk', $files, { filter: function(file) { - return /\.(apk|aab)$/i.test(file.name) + return isIOSPlatform ? /\.(ipa)$/i.test(file.name) : /\.(apk|aab)$/i.test(file.name) } - }) + }) .progressed(function(e) { if (e.lengthComputable) { installation.update(e.loaded / e.total * 100 / 2, 'uploading') @@ -103,23 +105,35 @@ module.exports = function InstallService( .then(function(res) { installation.update(100 / 2, 'processing') installation.href = res.data.resources.file.href - return $http.get(installation.href + '/manifest') - .then(function(res) { - if (res.data.success) { - installation.manifest = res.data.manifest - return control.install({ - href: installation.href - , manifest: installation.manifest - , launch: installation.launch - }) - .progressed(function(result) { - installation.update(50 + result.progress / 2, result.lastData) - }) - } - else { - throw new Error('Unable to retrieve manifest') - } + if(isIOSPlatform) { + installation.manifest = {'application': {'activities': {}}} + return control.install({ + href: installation.href, + manifest: installation.manifest, + launch: installation.launch }) + .progressed(function(result) { + installation.update(50 + result.progress / 2, result.lastData) + }) + } else { + return $http.get(installation.href + '/manifest') + .then(function(res) { + if (res.data.success) { + installation.manifest = res.data.manifest + return control.install({ + href: installation.href, + manifest: installation.manifest, + launch: installation.launch + }) + .progressed(function(result) { + installation.update(50 + result.progress / 2, result.lastData) + }) + } + else { + throw new Error('Unable to retrieve manifest') + } + }) + } }) .then(function() { installation.okay('installed') @@ -127,7 +141,7 @@ module.exports = function InstallService( .catch(function(err) { installation.fail(err.code || err.message) }) - } + } return installService }