Improve app display configuration
This commit is contained in:
@@ -70,23 +70,19 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
|
||||
$scope.display.label = $scope.app.label || '';
|
||||
$scope.display.icon = { data: null };
|
||||
|
||||
$('#iconFileInput').get(0).onchange = function (event) {
|
||||
var fr = new FileReader();
|
||||
fr.onload = function () {
|
||||
$scope.$apply(function () {
|
||||
// var file = event.target.files[0];
|
||||
$scope.display.icon.data = fr.result;
|
||||
});
|
||||
};
|
||||
fr.readAsDataURL(event.target.files[0]);
|
||||
};
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.display.busy = true;
|
||||
$scope.display.error = {};
|
||||
|
||||
function done() {
|
||||
$scope.display.busy = false;
|
||||
$scope.display.success = true;
|
||||
$scope.displayForm.$setPristine();
|
||||
refreshApp($scope.display.show);
|
||||
}
|
||||
|
||||
// TODO break those apart
|
||||
Client.configureApp($scope.app.id, 'label', { label: $scope.display.label }, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
@@ -97,11 +93,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
if (error) return Client.error(error);
|
||||
|
||||
// skip if icon is unchanged
|
||||
if ($scope.display.icon.data === null) {
|
||||
$scope.display.busy = false;
|
||||
$scope.display.success = true;
|
||||
return;
|
||||
}
|
||||
if ($scope.display.icon.data === null) return done();
|
||||
|
||||
var icon;
|
||||
if ($scope.display.icon.data === '__original__') { // user reset the icon
|
||||
@@ -112,9 +104,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
|
||||
Client.configureApp($scope.app.id, 'icon', { icon: icon }, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.display.busy = false;
|
||||
$scope.display.success = true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -447,6 +437,16 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
});
|
||||
}
|
||||
|
||||
function refreshApp(callback) {
|
||||
Client.getApp(appId, function (error, app) {
|
||||
if (error) return callback(error);
|
||||
|
||||
$scope.app = app;
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function trackAppTask() {
|
||||
Client.getApp(appId, function (error, app) {
|
||||
if (error) Client.error(error);
|
||||
@@ -486,8 +486,19 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
});
|
||||
});
|
||||
|
||||
$('#iconFileInput').get(0).onchange = function (event) {
|
||||
var fr = new FileReader();
|
||||
fr.onload = function () {
|
||||
$scope.$apply(function () {
|
||||
// var file = event.target.files[0];
|
||||
$scope.display.icon.data = fr.result;
|
||||
});
|
||||
};
|
||||
fr.readAsDataURL(event.target.files[0]);
|
||||
};
|
||||
|
||||
// setup all the dialog focus handling
|
||||
['appConfigureModal', 'appUninstallModal', 'appUpdateModal', 'appRestoreModal', 'appInfoModal', 'appErrorModal'].forEach(function (id) {
|
||||
['appUninstallModal', 'appUpdateModal', 'appRestoreModal'].forEach(function (id) {
|
||||
$('#' + id).on('shown.bs.modal', function () {
|
||||
$(this).find("[autofocus]:first").focus();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user