Add Client.getApp that uses REST API
This commit is contained in:
@@ -735,6 +735,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
|||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.getApp = function (appId, callback) {
|
Client.prototype.getApp = function (appId, callback) {
|
||||||
|
get('/api/v1/apps/' + appId).success(function (data, status) {
|
||||||
|
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
||||||
|
callback(null, data);
|
||||||
|
}).error(defaultErrorHandler(callback));
|
||||||
|
};
|
||||||
|
|
||||||
|
Client.prototype.getCachedApp = function (appId, callback) {
|
||||||
var appFound = null;
|
var appFound = null;
|
||||||
this._installedApps.some(function (app) {
|
this._installedApps.some(function (app) {
|
||||||
if (app.id === appId) {
|
if (app.id === appId) {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ app.controller('LogsController', ['$scope', '$timeout', '$location', 'Client', f
|
|||||||
|
|
||||||
var appId = $scope.selected.value;
|
var appId = $scope.selected.value;
|
||||||
|
|
||||||
Client.getApp(appId, function (error, result) {
|
Client.getCachedApp(appId, function (error, result) {
|
||||||
if (error) return console.error(error);
|
if (error) return console.error(error);
|
||||||
|
|
||||||
$scope.selectedAppInfo = result;
|
$scope.selectedAppInfo = result;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
|||||||
Client.refreshInstalledApps(function (error) {
|
Client.refreshInstalledApps(function (error) {
|
||||||
if (error) return callback(error);
|
if (error) return callback(error);
|
||||||
|
|
||||||
Client.getApp(appId, function (error, result) {
|
Client.getCachedApp(appId, function (error, result) {
|
||||||
if (error) return callback(error);
|
if (error) return callback(error);
|
||||||
|
|
||||||
if (result.runState === 'stopped') return callback();
|
if (result.runState === 'stopped') return callback();
|
||||||
@@ -174,7 +174,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
|||||||
Client.refreshInstalledApps(function (error) {
|
Client.refreshInstalledApps(function (error) {
|
||||||
if (error) return console.error('Failed to refresh app status.', error);
|
if (error) return console.error('Failed to refresh app status.', error);
|
||||||
|
|
||||||
Client.getApp($scope.selected.value, function (error, result) {
|
Client.getCachedApp($scope.selected.value, function (error, result) {
|
||||||
if (error) return console.error('Failed to get app status.', error);
|
if (error) return console.error('Failed to get app status.', error);
|
||||||
|
|
||||||
if (result.installationState === 'installed') $scope.appBusy = false;
|
if (result.installationState === 'installed') $scope.appBusy = false;
|
||||||
@@ -203,7 +203,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
|||||||
Client.refreshInstalledApps(function (error) {
|
Client.refreshInstalledApps(function (error) {
|
||||||
if (error) return console.error('Failed to refresh app status.', error);
|
if (error) return console.error('Failed to refresh app status.', error);
|
||||||
|
|
||||||
Client.getApp($scope.selected.value, function (error, result) {
|
Client.getCachedApp($scope.selected.value, function (error, result) {
|
||||||
if (error) return console.error('Failed to get app status.', error);
|
if (error) return console.error('Failed to get app status.', error);
|
||||||
|
|
||||||
if (result.installationState === 'installed') $scope.appBusy = false;
|
if (result.installationState === 'installed') $scope.appBusy = false;
|
||||||
@@ -249,7 +249,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
|||||||
|
|
||||||
var appId = $scope.selected.value;
|
var appId = $scope.selected.value;
|
||||||
|
|
||||||
Client.getApp(appId, function (error, result) {
|
Client.getCachedApp(appId, function (error, result) {
|
||||||
if (error) return console.error(error);
|
if (error) return console.error(error);
|
||||||
|
|
||||||
// we expect this to be called _after_ a reconfigure was issued
|
// we expect this to be called _after_ a reconfigure was issued
|
||||||
@@ -317,7 +317,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
|||||||
|
|
||||||
// var appId = $scope.selected.value;
|
// var appId = $scope.selected.value;
|
||||||
|
|
||||||
// Client.getApp(appId, function (error, result) {
|
// Client.getCachedApp(appId, function (error, result) {
|
||||||
// if (error) return console.error(error);
|
// if (error) return console.error(error);
|
||||||
|
|
||||||
// // we expect this to be called _after_ a reconfigure was issued
|
// // we expect this to be called _after_ a reconfigure was issued
|
||||||
|
|||||||
Reference in New Issue
Block a user