ROcket.Chat Apps manage pages, use one promise to ensure no race condition. Add a readme explaining a few terms

pull/9666/head
Bradley Hilton 8 years ago
parent 39918e9383
commit 23bf81e109
No known key found for this signature in database
GPG Key ID: 0666B2C24C43C358
  1. 11
      packages/rocketchat-apps/README.md
  2. 26
      packages/rocketchat-apps/client/admin/appLogs.js
  3. 35
      packages/rocketchat-apps/client/admin/appManage.js

@ -0,0 +1,11 @@
# Rocket.Chat Apps
Finally! :smile:
## What is an "Orchestrator"?
An orchestrator is the file/class which is responsible for orchestrating (starting up) everything which is required of the system to get up and going. There are two of these. One for the server and one for the client.
## What is a "Bridge"?
A bridge is a file/class which is responsible for bridging the Rocket.Chat system's data and the App system's data. They are implementations of the interfaces inside of the Rocket.Chat Apps-engine project `src/server/bridges`. They allow the two systems to talk to each other (hince the name bridge, as they "bridge the gap").
## What is a "Converter"?
A converter does what the name implies, it handles converting from one system's data type into the other's.

@ -9,26 +9,18 @@ Template.appLogs.onCreated(function() {
this.logs = new ReactiveVar([]);
const id = this.id.get();
const got = { info: false, logs: false };
RocketChat.API.get(`apps/${ id }`).then((result) => {
instance.app.set(result.app);
Promise.all([
RocketChat.API.get(`apps/${ id }`),
RocketChat.API.get(`apps/${ id }/logs`),
]).then((results) => {
got.info = true;
if (got.info && got.logs) {
this.ready.set(true);
}
});
RocketChat.API.get(`apps/${ id }/logs`).then((result) => {
console.log('logs result:', result);
instance.app.set(results[0].app);
instance.logs.set(results[1].logs);
instance.logs.set(result.logs);
got.logs = true;
if (got.info && got.logs) {
this.ready.set(true);
}
this.ready.set(true);
}).catch(() => {
//TODO: error handling
});
});

@ -10,32 +10,23 @@ Template.appManage.onCreated(function() {
this.settings = new ReactiveVar({});
const id = this.id.get();
const got = { info: false, settings: false };
RocketChat.API.get(`apps/${ id }`).then((result) => {
instance.app.set(result.app);
console.log(result.app);
Promise.all([
RocketChat.API.get(`apps/${ id }`),
RocketChat.API.get(`apps/${ id }/settings`),
]).then((results) => {
instance.app.set(results[0].app);
got.info = true;
if (got.info && got.settings) {
this.ready.set(true);
}
});
RocketChat.API.get(`apps/${ id }/settings`).then((result) => {
Object.keys(result.settings).forEach((k) => {
result.settings[k].i18nPlaceholder = result.settings[k].i18nPlaceholder || ' ';
result.settings[k].value = result.settings[k].value || result.settings[k].packageValue;
result.settings[k].oldValue = result.settings[k].value;
Object.keys(results[1].settings).forEach((k) => {
results[1].settings[k].i18nPlaceholder = results[1].settings[k].i18nPlaceholder || ' ';
results[1].settings[k].value = results[1].settings[k].value || results[1].settings[k].packageValue;
results[1].settings[k].oldValue = results[1].settings[k].value;
});
instance.settings.set(result.settings);
console.log(instance.settings.get());
got.settings = true;
if (got.info && got.settings) {
this.ready.set(true);
}
instance.settings.set(results[1].settings);
this.ready.set(true);
}).catch(() => {
//TODO: error handling
});
});

Loading…
Cancel
Save