Added ability to install from device screen. Still not synced to Upload panel.

This commit is contained in:
Gunther Brunner
2014-04-14 18:48:19 +09:00
parent 24afc6fbef
commit 3aa44f1a9c
3 changed files with 46 additions and 3 deletions

View File

@@ -1,5 +1,4 @@
module.exports = function ($scope, gettext, $routeParams, $location,
DeviceService, GroupService, ControlService) {
module.exports = function ($scope, gettext, $routeParams, $location, DeviceService, GroupService, ControlService) {
var sharedTabs = [
{
@@ -56,6 +55,48 @@ module.exports = function ($scope, gettext, $routeParams, $location,
$scope.control = null
$scope.installFileForced = function ($files) {
$scope.upload = {
progress: 0,
lastData: 'uploading'
}
var upload = $scope.control.uploadFile($files)
return upload.promise
.progressed(function (uploadResult) {
$scope.$apply(function () {
$scope.upload = uploadResult
})
})
.then(function (uploadResult) {
$scope.$apply(function () {
$scope.upload = uploadResult
})
if (uploadResult.success) {
return $scope.maybeInstallForced(uploadResult.body)
}
})
}
$scope.maybeInstallForced = function (options) {
var install = $scope.control.install(options)
return install.promise
.progressed(function (installResult) {
$scope.$apply(function () {
installResult.manifest = options.manifest
$scope.installation = installResult
})
})
.then(function (installResult) {
$scope.$apply(function () {
installResult.manifest = options.manifest
$scope.treeData = installResult.manifest
$scope.installation = installResult
})
})
}
DeviceService.get($routeParams.serial, $scope)
.then(function (device) {
return GroupService.invite(device)