Add initial support to add applinks
This commit is contained in:
105
src/js/client.js
105
src/js/client.js
@@ -1844,6 +1844,38 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.getApplinks = function (callback) {
|
||||
get('/api/v1/applinks', null, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
// amend properties to mimick full app
|
||||
data.applinks.forEach(function (applink) {
|
||||
applink.fqdn = applink.upstreamUri; // this fqdn may contain the protocol!
|
||||
applink.manifest = { addons: {}};
|
||||
applink.installationState = ISTATES.INSTALLED;
|
||||
applink.runState = RSTATES.RUNNING;
|
||||
applink.health = HSTATES.HEALTHY;
|
||||
applink.accessLevel = 'operator';
|
||||
});
|
||||
|
||||
callback(null, data.applinks);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.addApplink = function (applink, callback) {
|
||||
var data = {
|
||||
upstreamUri: applink.upstreamUri
|
||||
};
|
||||
|
||||
post('/api/v1/applinks', data, null, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 201) return callback(new ClientError(status, data));
|
||||
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.addUser = function (user, callback) {
|
||||
var data = {
|
||||
email: user.email,
|
||||
@@ -2223,49 +2255,56 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
this.getApps(function (error, apps) {
|
||||
if (error) return callback(error);
|
||||
|
||||
async.eachLimit(apps, 20, function (app, iteratorCallback) {
|
||||
app.ssoAuth = (app.manifest.addons['ldap'] || app.manifest.addons['proxyAuth']) && app.sso;
|
||||
that.getApplinks(function (error, applinks) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (app.accessLevel !== 'operator' && app.accessLevel !== 'admin') { // only fetch if we have permissions
|
||||
app.progress = 0;
|
||||
app.message = '';
|
||||
app.taskMinutesActive = 0;
|
||||
apps = apps.concat(applinks);
|
||||
|
||||
that._updateAppCache(app);
|
||||
async.eachLimit(apps, 20, function (app, iteratorCallback) {
|
||||
app.ssoAuth = (app.manifest.addons['ldap'] || app.manifest.addons['proxyAuth']) && app.sso;
|
||||
|
||||
return iteratorCallback();
|
||||
}
|
||||
|
||||
var getTaskFunc = app.taskId ? that.getAppTask.bind(null, app.id) : function (next) { return next(); };
|
||||
getTaskFunc(function (error, task) {
|
||||
if (error) return iteratorCallback(error);
|
||||
|
||||
if (task) {
|
||||
app.progress = task.percent;
|
||||
app.message = task.message;
|
||||
app.taskMinutesActive = moment.duration(moment.utc().diff(moment.utc(task.creationTime))).asMinutes();
|
||||
} else {
|
||||
if (app.accessLevel !== 'operator' && app.accessLevel !== 'admin') { // only fetch if we have permissions
|
||||
app.progress = 0;
|
||||
app.message = '';
|
||||
app.taskMinutesActive = 0;
|
||||
|
||||
that._updateAppCache(app);
|
||||
|
||||
return iteratorCallback();
|
||||
}
|
||||
|
||||
that._updateAppCache(app);
|
||||
var getTaskFunc = app.taskId ? that.getAppTask.bind(null, app.id) : function (next) { return next(); };
|
||||
getTaskFunc(function (error, task) {
|
||||
if (error) return iteratorCallback(error);
|
||||
|
||||
iteratorCallback();
|
||||
if (task) {
|
||||
app.progress = task.percent;
|
||||
app.message = task.message;
|
||||
app.taskMinutesActive = moment.duration(moment.utc().diff(moment.utc(task.creationTime))).asMinutes();
|
||||
} else {
|
||||
app.progress = 0;
|
||||
app.message = '';
|
||||
app.taskMinutesActive = 0;
|
||||
}
|
||||
|
||||
that._updateAppCache(app);
|
||||
|
||||
iteratorCallback();
|
||||
});
|
||||
}, function iteratorDone(error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
|
||||
// filter out old apps, going backwards to allow splicing
|
||||
for (var i = that._installedApps.length - 1; i >= 0; --i) {
|
||||
if (!apps.some(function (elem) { return (elem.id === that._installedApps[i].id); })) {
|
||||
var removed = that._installedApps.splice(i, 1);
|
||||
delete that._installedAppsById[removed[0].id];
|
||||
}
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, function iteratorDone(error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
// filter out old apps, going backwards to allow splicing
|
||||
for (var i = that._installedApps.length - 1; i >= 0; --i) {
|
||||
if (!apps.some(function (elem) { return (elem.id === that._installedApps[i].id); })) {
|
||||
var removed = that._installedApps.splice(i, 1);
|
||||
delete that._installedAppsById[removed[0].id];
|
||||
}
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user