Add Client.getApp that uses REST API

This commit is contained in:
Girish Ramakrishnan
2018-06-25 18:55:07 -07:00
parent a77918bef9
commit 091663afe0
3 changed files with 13 additions and 6 deletions

View File

@@ -735,6 +735,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
};
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;
this._installedApps.some(function (app) {
if (app.id === appId) {

View File

@@ -72,7 +72,7 @@ app.controller('LogsController', ['$scope', '$timeout', '$location', 'Client', f
var appId = $scope.selected.value;
Client.getApp(appId, function (error, result) {
Client.getCachedApp(appId, function (error, result) {
if (error) return console.error(error);
$scope.selectedAppInfo = result;

View File

@@ -139,7 +139,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
Client.refreshInstalledApps(function (error) {
if (error) return callback(error);
Client.getApp(appId, function (error, result) {
Client.getCachedApp(appId, function (error, result) {
if (error) return callback(error);
if (result.runState === 'stopped') return callback();
@@ -174,7 +174,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
Client.refreshInstalledApps(function (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 (result.installationState === 'installed') $scope.appBusy = false;
@@ -203,7 +203,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
Client.refreshInstalledApps(function (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 (result.installationState === 'installed') $scope.appBusy = false;
@@ -249,7 +249,7 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
var appId = $scope.selected.value;
Client.getApp(appId, function (error, result) {
Client.getCachedApp(appId, function (error, result) {
if (error) return console.error(error);
// 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;
// Client.getApp(appId, function (error, result) {
// Client.getCachedApp(appId, function (error, result) {
// if (error) return console.error(error);
// // we expect this to be called _after_ a reconfigure was issued