Allow non published versions to be shown if explicitly requested
Fixes #468
This commit is contained in:
@@ -63,6 +63,17 @@ angular.module('Application').service('AppStore', ['$http', 'Client', function (
|
||||
});
|
||||
};
|
||||
|
||||
AppStore.prototype.getAppByIdAndVersion = function (appId, version, callback) {
|
||||
if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm'));
|
||||
|
||||
$http.get(Client.getConfig().apiServerOrigin + '/api/v1/apps/' + appId + '/versions/' + version).success(function (data, status) {
|
||||
if (status !== 200) return callback(new AppStoreError(status, data));
|
||||
return callback(null, data);
|
||||
}).error(function (data, status) {
|
||||
return callback(new AppStoreError(status, data));
|
||||
});
|
||||
};
|
||||
|
||||
AppStore.prototype.getManifest = function (appId, callback) {
|
||||
if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm'));
|
||||
|
||||
|
||||
@@ -88,6 +88,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal app not found -->
|
||||
<div class="modal fade" id="appNotFoundModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">App not found</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
There is no such app <b>{{ appNotFound.appId }}</b><span ng-show="appNotFound.version"> with version <b>{{ appNotFound.version }}</b></span>.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="row-no-margin">
|
||||
<div class="col-md-2">
|
||||
|
||||
@@ -20,6 +20,10 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
|
||||
mediaLinks: []
|
||||
};
|
||||
|
||||
$scope.appNotFound = {
|
||||
appId: '',
|
||||
version: ''
|
||||
};
|
||||
|
||||
$scope.feedback = {
|
||||
error: null,
|
||||
@@ -169,6 +173,13 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showAppNotFound = function (appId, version) {
|
||||
$scope.appNotFound.appId = appId;
|
||||
$scope.appNotFound.version = version;
|
||||
|
||||
$('#appNotFoundModal').modal('show');
|
||||
};
|
||||
|
||||
$scope.doInstall = function () {
|
||||
$scope.appInstall.busy = true;
|
||||
$scope.appInstall.error.other = null;
|
||||
@@ -226,11 +237,26 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
|
||||
|
||||
// show install app dialog immediately if an app id was passed in the query
|
||||
if ($routeParams.appId) {
|
||||
var found = apps.filter(function (app) {
|
||||
return (app.id === $routeParams.appId) && ($routeParams.version ? $routeParams.version === app.manifest.version : true);
|
||||
});
|
||||
if (found.length) {
|
||||
$scope.showInstall(found[0]);
|
||||
if ($routeParams.version) {
|
||||
AppStore.getAppByIdAndVersion($routeParams.appId, $routeParams.version, function (error, result) {
|
||||
if (error) {
|
||||
$scope.showAppNotFound($routeParams.appId, $routeParams.version);
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.showInstall(result);
|
||||
});
|
||||
} else {
|
||||
var found = apps.filter(function (app) {
|
||||
return (app.id === $routeParams.appId) && ($routeParams.version ? $routeParams.version === app.manifest.version : true);
|
||||
});
|
||||
|
||||
if (found.length) {
|
||||
$scope.showInstall(found[0]);
|
||||
} else {
|
||||
$scope.showAppNotFound($routeParams.appId, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user