Rename dashboard/upload to dashboard/install.

This commit is contained in:
Simo Kinnunen
2014-09-04 17:17:54 +09:00
parent fdfcdf913d
commit 2174de0eee
13 changed files with 13 additions and 13 deletions

View File

@@ -0,0 +1,96 @@
var _ = require('lodash')
module.exports = function ActivitiesCtrl($scope) {
$scope.selectedAction = ''
$scope.selectedCategory = ''
$scope.selectedData = ''
$scope.selectedPackageName = $scope.installation &&
$scope.installation.manifest && $scope.installation.manifest.package ?
$scope.installation.manifest.package : ''
$scope.selectedActivityName = ''
$scope.activityActions = []
$scope.activityCategories = []
$scope.activityData = []
$scope.packageNames = [$scope.selectedPackageName]
$scope.activityNames = []
$scope.$watch('installation.manifest.application', function (newValue) {
if (newValue.activities) {
var activityActions = []
var activityCategories = []
var activityData = []
var activityNames = []
_.forEach(newValue.activities, function (activity) {
if (activity.name) {
activityNames.push(activity.name)
}
_.forEach(activity.intentFilters, function (intentFilter) {
_.forEach(intentFilter.actions, function (action) {
if (action.name) {
activityActions.push(action.name)
}
})
_.forEach(intentFilter.categories, function (category) {
if (category.name) {
activityCategories.push(category.name)
}
})
_.forEach(intentFilter.data, function (data) {
if (data.scheme) {
var uri = data.scheme + '://'
if (data.host) {
uri += data.host
}
if (data.port) {
uri += data.port
}
if (data.path) {
uri += '/' + data.path
} else if (data.pathPrefix) {
uri += '/' + data.pathPrefix
} else if (data.pathPattern) {
uri += '/' + data.pathPattern
}
activityData.push(uri)
}
if (data.mimeType) {
activityData.push(data.mimeType)
}
})
})
})
$scope.activityActions = _.uniq(activityActions)
$scope.activityCategories = _.uniq(activityCategories)
$scope.activityData = _.uniq(activityData)
$scope.activityNames = _.uniq(activityNames)
}
})
$scope.runActivity = function () {
var command = 'am start'
if ($scope.selectedAction) {
command += ' -a ' + $scope.selectedAction
}
if ($scope.selectedCategory) {
command += ' -c ' + $scope.selectedCategory
}
if ($scope.selectedData) {
command += ' -d ' + $scope.selectedData
}
if ($scope.selectedPackageName && $scope.selectedActivityName) {
command += ' -n ' +
$scope.selectedPackageName + '/' + $scope.selectedActivityName
}
return $scope.control.shell(command)
.then(function (result) {
console.log(result)
})
}
}

View File

@@ -0,0 +1,17 @@
describe('ActivitiesCtrl', function () {
beforeEach(angular.mock.module(require('./').name));
var scope, ctrl;
beforeEach(inject(function ($rootScope, $controller) {
scope = $rootScope.$new();
ctrl = $controller('ActivitiesCtrl', {$scope: scope});
}));
it('should ...', inject(function () {
expect(1).toEqual(1);
}));
});

View File

@@ -0,0 +1,3 @@
.stf-activities {
}

View File

@@ -0,0 +1,48 @@
div(ng-controller='ActivitiesCtrl')
form
table.table.table-condensed
tbody
tr
td(translate) Package
td
input.form-control(type='text', placeholder='', ng-model='selectedPackageName',
list='packageList')
datalist(id='packageList')
option(ng-repeat='packageName in packageNames', ng-value='packageName')
//typeahead='packageName for packageName in packageNames')
tr
td(translate) Activity
td
input.form-control(type='text', placeholder='', ng-model='selectedActivityName',
list='activityList')
datalist(id='activityList')
option(ng-repeat='activityName in activityNames', ng-value='activityName')
//typeahead='activityName for activityName in activityNames')
tr
td(translate) Action
td
input.form-control(type='text', placeholder='', ng-model='selectedAction',
list='actionList')
datalist(id='actionList')
option(ng-repeat='action in activityActions', ng-value='action')
//typeahead='action for action in activityActions')
tr
td(translate) Category
td
input.form-control(type='text', placeholder='', ng-model='selectedCategory',
list='categoryList')
datalist(id='categoryList')
option(ng-repeat='category in activityCategories', ng-value='category')
//typeahead='category for category in activityCategories')
tr
td(translate) Data
td
input.form-control(type='text', placeholder='', ng-model='selectedData',
list='dataList')
datalist(id='dataList')
option(ng-repeat='data in activityData', ng-value='data')
//typeahead='data for data in activityData', id='selectedData')
button.btn.btn-sm.btn-primary-outline(ng-click='runActivity()').pull-right
i.fa.fa-play
span(translate) Launch Activity

View File

@@ -0,0 +1,12 @@
require('./activities.css')
module.exports = angular.module('stf.activities', [
require('stf/common-ui').name
])
.run(["$templateCache", function ($templateCache) {
$templateCache.put(
'control-panes/dashboard/install/activities/activities.jade',
require('./activities.jade')
)
}])
.controller('ActivitiesCtrl', require('./activities-controller'))

View File

@@ -0,0 +1,376 @@
{
"versionCode": 20,
"versionName": "1.0.18",
"installLocation": 0,
"package": "jp.ameba.palette",
"usesPermissions": [
{
"name": "android.permission.INTERNET"
},
{
"name": "android.permission.ACCESS_NETWORK_STATE"
},
{
"name": "android.permission.WRITE_EXTERNAL_STORAGE"
},
{
"name": "jp.ameba.palette.permission.C2D_MESSAGE"
},
{
"name": "com.google.android.c2dm.permission.RECEIVE"
},
{
"name": "android.permission.GET_ACCOUNTS"
},
{
"name": "android.permission.WAKE_LOCK"
},
{
"name": "android.permission.VIBRATE"
}
],
"permissions": [
{
"name": "jp.ameba.palette.permission.C2D_MESSAGE",
"protectionLevel": 2
}
],
"permissionTrees": [],
"permissionGroups": [],
"instrumentation": null,
"usesSdk": {
"minSdkVersion": 10
},
"usesConfiguration": null,
"usesFeatures": [],
"supportsScreens": {
"xlargeScreens": false
},
"compatibleScreens": [],
"supportsGlTextures": [],
"application": {
"theme": "resourceId:0x7f0d005c",
"label": "resourceId:0x7f090019",
"icon": "resourceId:0x7f0200b4",
"name": "jp.ameba.palette.LaPaletteApplication",
"debuggable": true,
"allowBackup": true,
"hardwareAccelerated": true,
"activities": [
{
"theme": "resourceId:0x7f0d0055",
"label": "resourceId:0x7f090023",
"name": "jp.ameba.palette.SplashActivity",
"screenOrientation": 1,
"configChanges": 160,
"intentFilters": [
{
"actions": [
{
"name": "android.intent.action.MAIN"
}
],
"categories": [
{
"name": "android.intent.category.LAUNCHER"
}
],
"data": []
},
{
"actions": [
{
"name": "android.intent.action.VIEW"
}
],
"categories": [
{
"name": "android.intent.category.DEFAULT"
}
],
"data": []
}
],
"metaData": []
},
{
"theme": "resourceId:0x7f0d0055",
"label": "resourceId:0x7f090023",
"name": "jp.ameba.palette.MainActivity",
"screenOrientation": 1,
"configChanges": 160,
"intentFilters": [
{
"actions": [
{
"name": "android.intent.action.VIEW"
}
],
"categories": [
{
"name": "android.intent.category.BROWSABLE"
},
{
"name": "android.intent.category.DEFAULT"
}
],
"data": [
{
"scheme": "jp-ajmp-6333"
}
]
}
],
"metaData": []
},
{
"theme": "resourceId:0x1030006",
"label": "resourceId:0x7f090019",
"name": "jp.ameba.palette.DecoEditorActivity",
"screenOrientation": 1,
"configChanges": 160,
"windowSoftInputMode": 16,
"intentFilters": [],
"metaData": []
},
{
"name": "jp.ameba.palette.GateWayActivity",
"intentFilters": [
{
"actions": [
{
"name": "android.intent.action.VIEW"
}
],
"categories": [
{
"name": "android.intent.category.DEFAULT"
},
{
"name": "android.intent.category.BROWSABLE"
}
],
"data": [
{
"scheme": "ca-palette"
}
]
},
{
"actions": [
{
"name": "android.intent.action.VIEW"
}
],
"categories": [
{
"name": "android.intent.category.DEFAULT"
},
{
"name": "android.intent.category.BROWSABLE"
}
],
"data": [
{
"scheme": "https",
"host": "ca-palette.jp"
},
{
"scheme": "http",
"host": "ca-palette.jp"
}
]
},
{
"actions": [
{
"name": "android.intent.action.VIEW"
}
],
"categories": [
{
"name": "android.intent.category.DEFAULT"
},
{
"name": "android.intent.category.BROWSABLE"
}
],
"data": [
{
"scheme": "https",
"host": "stg-ca-palette.jp"
},
{
"scheme": "http",
"host": "stg-ca-palette.jp"
}
]
}
],
"metaData": []
},
{
"theme": "resourceId:0x1030006",
"label": "resourceId:0x7f090019",
"name": "jp.ameba.palette.CredibleSiteActivity",
"screenOrientation": 1,
"configChanges": 160,
"intentFilters": [],
"metaData": []
}
],
"activityAliases": [],
"launcherActivities": [
{
"theme": "resourceId:0x7f0d0055",
"label": "resourceId:0x7f090023",
"name": "jp.ameba.palette.SplashActivity",
"screenOrientation": 1,
"configChanges": 160,
"intentFilters": [
{
"actions": [
{
"name": "android.intent.action.MAIN"
}
],
"categories": [
{
"name": "android.intent.category.LAUNCHER"
}
],
"data": []
},
{
"actions": [
{
"name": "android.intent.action.VIEW"
}
],
"categories": [
{
"name": "android.intent.category.DEFAULT"
}
],
"data": []
}
],
"metaData": []
}
],
"services": [
{
"name": "jp.ameba.palette.service.DecoResourceService",
"intentFilters": [],
"metaData": []
},
{
"name": "jp.ameba.palette.service.PushSynchronizeService",
"intentFilters": [],
"metaData": []
},
{
"name": ".GCMIntentService",
"intentFilters": [],
"metaData": []
},
{
"name": "jp.co.CAReward_Ack.CARAck",
"intentFilters": [],
"metaData": []
},
{
"name": "com.appanalyzerseed.ReferrerService",
"intentFilters": [],
"metaData": []
}
],
"receivers": [
{
"name": "com.google.android.gcm.GCMBroadcastReceiver",
"permission": "com.google.android.c2dm.permission.SEND",
"intentFilters": [
{
"actions": [
{
"name": "com.google.android.c2dm.intent.RECEIVE"
},
{
"name": "com.google.android.c2dm.intent.REGISTRATION"
}
],
"categories": [
{
"name": "jp.ameba.palette"
}
],
"data": []
}
],
"metaData": []
},
{
"name": "jp.ameba.palette.push.GrowthPushReceiver",
"permission": "com.google.android.c2dm.permission.SEND",
"intentFilters": [
{
"actions": [
{
"name": "com.google.android.c2dm.intent.RECEIVE"
},
{
"name": "com.google.android.c2dm.intent.REGISTRATION"
}
],
"categories": [
{
"name": "jp.ameba.palette"
}
],
"data": []
}
],
"metaData": []
},
{
"name": "jp.co.CAReward_Receiver.CARReceiver",
"exported": true,
"intentFilters": [
{
"actions": [
{
"name": "com.android.vending.INSTALL_REFERRER"
}
],
"categories": [],
"data": []
}
],
"metaData": []
},
{
"name": "com.appanalyzerseed.ReferrerReceiver",
"exported": true,
"intentFilters": [
{
"actions": [
{
"name": "com.android.vending.INSTALL_REFERRER"
}
],
"categories": [],
"data": []
}
],
"metaData": [
{
"name": " com.appanalyzerseed.FORWARD_REFERRER",
"value": "jp.co.CAReward_Receiver.CARReceiver"
}
]
}
],
"providers": [],
"usesLibraries": []
}
}

View File

@@ -0,0 +1,18 @@
require('./install.css')
require('ng-file-upload')
module.exports = angular.module('stf.install', [
'angularFileUpload',
require('./activities').name,
require('stf/settings').name,
require('stf/storage').name,
require('stf/install').name,
require('stf/upload').name
])
.run(["$templateCache", function ($templateCache) {
$templateCache.put('control-panes/dashboard/install/install.jade',
require('./install.jade')
)
}])
.controller('InstallCtrl', require('./install-controller'))

View File

@@ -0,0 +1,190 @@
module.exports = function InstallCtrl(
$scope
, $http
, SettingsService
, StorageService
) {
$scope.upload = null
$scope.installation = null
$scope.installEnabled = true
$scope.launchEnabled = true
$scope.clear = function () {
$scope.upload = null
$scope.installation = null
}
$scope.installUrl = function (url) {
$scope.upload = {
progress: 0,
lastData: 'uploading'
}
$scope.installation = null
return $scope.control.uploadUrl(url)
.progressed(function (uploadResult) {
$scope.$apply(function () {
$scope.upload = uploadResult
})
})
.then(function (uploadResult) {
$scope.$apply(function () {
$scope.upload = uploadResult
})
if (uploadResult.success) {
return $scope.maybeInstall(uploadResult.body)
}
})
}
$scope.installFile = function ($files) {
$scope.$apply(function () {
$scope.upload = {
progress: 0
, lastData: 'uploading'
}
})
return StorageService.storeFile('apk', $files, {
filter: function(file) {
return /\.apk$/i.test(file.name)
}
})
.progressed(function(e) {
if (e.lengthComputable) {
$scope.$apply(function () {
$scope.upload = {
progress: e.loaded / e.total * 100
, lastData: 'uploading'
}
})
}
})
.then(function(res) {
$scope.$apply(function () {
$scope.upload = {
progress: 100
, lastData: 'processing'
}
})
var href = res.data.resources.file.href
return $http.get(href + '/manifest')
.then(function(res) {
$scope.upload = {
progress: 100
, lastData: 'success'
, settled: true
}
if (res.data.success) {
return $scope.maybeInstall({
href: href
, launch: $scope.launchEnabled
, manifest: res.data.manifest
})
}
})
})
.catch(function(err) {
$scope.$apply(function () {
if (err.code === 'no_input_files') {
$scope.upload = null
}
else {
$scope.upload = {
progress: 100
, lastData: 'fail'
, settled: true
, error: err.message
}
}
})
})
}
$scope.maybeInstall = function (options) {
if ($scope.installEnabled) {
return $scope.control.install(options)
.progressed(function (installResult) {
$scope.$apply(function () {
installResult.manifest = options.manifest
$scope.installation = installResult
})
})
.then(function (installResult) {
$scope.$apply(function () {
$scope.accordionOpen = false
installResult.manifest = options.manifest
$scope.treeData = installResult.manifest
$scope.installation = installResult
$scope.installationError = installResult.error
})
})
}
else {
return Promise.reject(new Error('Installation not enabled'))
}
}
$scope.uninstall = function (packageName) {
// TODO: After clicking uninstall accordion opens
return $scope.control.uninstall(packageName)
.then(function (result) {
if (result.success) {
$scope.$apply(function () {
$scope.clear()
})
} else {
console.error(result.error)
}
})
}
$scope.taskFinished = function () {
if ($scope.installEnabled) {
return $scope.upload && ($scope.upload.error || $scope.upload.settled &&
$scope.installation && $scope.installation.settled)
} else {
return $scope.upload && $scope.upload.settled
}
return false
}
$scope.taskProgress = function () {
var progress = 0
if ($scope.installEnabled) {
if ($scope.upload) {
progress += $scope.upload.progress
}
if ($scope.installation) {
progress += $scope.installation.progress
}
progress = Math.floor(progress / 2)
} else {
if ($scope.upload) {
progress = $scope.upload.progress
}
}
return progress
}
$scope.accordionOpen = true
//
// $scope.installEnabled = true
// SettingsService.bind($scope, {
// key: 'installEnabled',
// storeName: 'Upload'
// })
//
// //$scope.launchEnabled = true
// SettingsService.bind($scope, {
// key: 'launchEnabled',
// storeName: 'Upload'
// })
}

View File

@@ -0,0 +1,17 @@
describe('InstallCtrl', function () {
beforeEach(angular.mock.module(require('./').name));
var scope, ctrl;
beforeEach(inject(function ($rootScope, $controller) {
scope = $rootScope.$new();
ctrl = $controller('InstallCtrl', {$scope: scope});
}));
it('should ...', inject(function () {
expect(1).toEqual(1);
}));
});

View File

@@ -0,0 +1,53 @@
.stf-upload .btn-file {
position: relative;
overflow: hidden;
}
.stf-upload .btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 999px;
text-align: right;
opacity: 0;
outline: none;
background: white;
cursor: inherit;
display: block;
}
.stf-upload .drop-area {
text-align: center;
color: #b7b7b7;
padding-top: 10px;
border: 2px transparent dashed;
border-radius: 2px;
/*background-color: #f6f6f6;*/
cursor: pointer;
}
.stf-upload .dragover {
border-color: #157afb !important;
}
.stf-upload .upload-status {
margin-top: 15px;
}
.stf-upload .manifest-text {
font-size: 10px;
}
.stf-upload .drop-area-text {
/*border-top: 1px solid #e2e2e2;*/
/*opacity: 0;*/
font-size: 14px;
font-weight: 300;
/*transition: opacity 0.25s ease-in-out;*/
}
.stf-upload .drop-area:hover .drop-area-text {
/*opacity: 1;*/
}

View File

@@ -0,0 +1,89 @@
.widget-container.fluid-height.stf-upload(ng-controller='InstallCtrl')
.heading
i.fa.fa-upload
span(translate) App Upload
clear-button(ng-click='clear()', ng-disabled='!installation && !upload').btn-xs
//label.checkbox-inline.pull-right
input(type='checkbox', ng-model='launchEnabled')
span Launch
//label.checkbox-inline.pull-right
input(type='checkbox', ng-model='installEnabled')
span(translate) Install
.widget-content.padded()
//.widget-content.padded(style='padding: 0; padding-bottom: 15px;')
//.col-md-10.col-md-offset-1
//.input-group.form-inline
input(type=text, ng-model='remoteUrl', ng-enter='installUrl(remoteUrl)',
placeholder='http://...').form-control
span.input-group-btn
button.btn.btn-primary-outline(ng-click='installUrl(remoteUrl)',
tooltip='{{ "Upload From Link" | translate }}', ng-disabled='!remoteUrl')
i.fa.fa-upload
.drop-area(ng-file-drop='installFile($files)', ng-file-drag-over-class='dragover').file-input.btn-file
input(type='file', ng-file-select='installFile($files)')
i.fa.fa-2x.fa-download.drop-area-icon
.drop-area-text(translate) Drop file to upload
//treecontrol.tree-classic(tree-model='treeData', options='treeOptions')
span employee: {{node.name}} age {{node.age}}
.upload-status(ng-if='upload || installation')
accordion(close-others='false').pointer
accordion-group(is-open='accordionOpen')
accordion-heading.pointer
i.fa.fa-file-o
span {{installation.manifest.package || "App" }}
button.btn.btn-xs.btn-danger-outline.pull-right(
ng-click='uninstall(installation.manifest.package)', ng-show='installation.settled')
i.fa.fa-trash-o
span(translate) Uninstall
div
span(ng-switch='upload.lastData')
strong(ng-switch-when='uploading')
span(translate) Uploading...
strong(ng-switch-when='processing')
span(translate) Processing...
strong(ng-switch-when='fail')
span(translate) Upload failed
strong(ng-switch-when='success')
span(ng-show='!installation', translate) Upload complete
span(ng-switch='installation.lastData')
strong(ng-switch-when='pushing_app')
span(translate) Pushing app...
strong(ng-switch-when='installing_app')
span(translate) Installing app...
strong(ng-switch-when='launching_app')
span(translate) Launching activity...
strong(ng-switch-when='success')
div(ng-include='"control-panes/dashboard/install/activities/activities.jade"')
button.btn.btn-sm.btn-primary-outline(btn-checkbox, ng-model='showManifest')
i.fa.fa-list
span(ng-if='showManifest') Hide Manifest
span(ng-if='!showManifest') Show Manifest
pre.manifest-text(ng-if='showManifest') {{ installation.manifest | json }}
strong(ng-switch-when='fail')
span(translate) Installation failed
span(ng-hide='taskFinished()') ({{taskProgress()}}%)
progressbar(max='100', value='taskProgress()', ng-if='!taskFinished()',
ng-class='{"active": !taskFinished()}').progress-striped
alert(type='danger', close='upload.error = null', ng-show='upload.error')
strong(translate) Error:
span {{ upload.error | uploadError | translate }}
alert(type='danger', close='installationError = undefined', ng-show='installationError')
strong(translate) Error:
span {{ installationError | installError | translate }} ({{ installationError }})