Adjust to changed settings rest api
This commit is contained in:
@@ -151,15 +151,11 @@ angular.module('Application').service('AppStore', ['$http', '$base64', 'Client',
|
||||
});
|
||||
};
|
||||
|
||||
AppStore.prototype.registerCloudron = function (token, userId, fqdn, callback) {
|
||||
AppStore.prototype.getCloudronDetails = function (appstoreConfig, callback) {
|
||||
if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm'));
|
||||
|
||||
var data = {
|
||||
domain: fqdn
|
||||
};
|
||||
|
||||
$http.post(Client.getConfig().apiServerOrigin + '/api/v1/users/' + userId + '/cloudrons', data, { params: { accessToken: token }}).success(function (data, status) {
|
||||
if (status !== 201) return callback(new AppStoreError(status, data));
|
||||
$http.get(Client.getConfig().apiServerOrigin + '/api/v1/users/' + appstoreConfig.userId + '/cloudrons/' + appstoreConfig.cloudronId, { params: { accessToken: appstoreConfig.token }}).success(function (data, status) {
|
||||
if (status !== 200) return callback(new AppStoreError(status, data));
|
||||
return callback(null, data.cloudron);
|
||||
}).error(function (data, status) {
|
||||
return callback(new AppStoreError(status, data));
|
||||
|
||||
@@ -439,40 +439,25 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
|
||||
// only check after tutorial was shown
|
||||
if ($scope.user.showTutorial) return setTimeout(checkAppstoreAccount, 5000);
|
||||
|
||||
Client.getAppstoreConfig(function (error, appstoreConfig) {
|
||||
Client.getAppstoreConfig(function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
if (!appstoreConfig.token) {
|
||||
if (!result.token || !result.cloudronId) {
|
||||
$scope.appstoreLogin.show();
|
||||
} else {
|
||||
console.log('Got token', appstoreConfig.token);
|
||||
|
||||
AppStore.getProfile(appstoreConfig.token, function (error, result) {
|
||||
if (error) {
|
||||
console.error('failed to get profile', error);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Got profile', result);
|
||||
|
||||
if (!appstoreConfig.cloudronId) {
|
||||
console.log('No cloudronId, try to register');
|
||||
AppStore.registerCloudron(appstoreConfig.token, result.id, Client.getConfig().fqdn, function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
console.log('Successfully registered cloudron', result);
|
||||
|
||||
// TODO set the cloudron id now with the appstore details
|
||||
});
|
||||
} else {
|
||||
AppStore.getCloudron(appstoreConfig.token, result.id, appstoreConfig.cloudronId, function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
console.log('Successfully got cloudron', result);
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Got token', result);
|
||||
|
||||
AppStore.getCloudronDetails(result, function (error, result) {
|
||||
if (error) {
|
||||
console.error('Unable to get Cloudron details.', error);
|
||||
$scope.appstoreLogin.show();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Successfully got cloudron', result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user