various filemanager and logs improvements
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import moment from 'moment';
|
||||
import superagent from 'superagent';
|
||||
import { ansiToHtml } from 'anser';
|
||||
import { ISTATES } from '../constants.js';
|
||||
import { sleep } from 'pankow/utils';
|
||||
|
||||
// https://github.com/janl/mustache.js/blob/master/mustache.js#L60
|
||||
const entityMap = {
|
||||
@@ -93,6 +95,34 @@ export function create(origin, accessToken, type, id) {
|
||||
}
|
||||
|
||||
return result.body;
|
||||
},
|
||||
async restartApp() {
|
||||
if (type !== 'app') return;
|
||||
|
||||
let error, result;
|
||||
try {
|
||||
result = await superagent.post(`${origin}/api/v1/apps/${id}/restart`).query({ access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
if (error || result.statusCode !== 202) {
|
||||
console.error(`Failed to restart app ${this.id}`, error || result.statusCode);
|
||||
return;
|
||||
}
|
||||
|
||||
while(true) {
|
||||
let result;
|
||||
try {
|
||||
result = await superagent.get(`${origin}/api/v1/apps/${id}`).query({ access_token: accessToken });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
if (result && result.statusCode === 200 && result.body.installationState === ISTATES.INSTALLED) break;
|
||||
|
||||
await sleep(2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user