mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Admin Panel / People / Cloud names the Cloud Panel Domain and its SuperAdmin - an existing administrator, by username or e-mail address - as Weddy's Cloud Panel does (caddy-wekan-plugin). At that domain, /cloud is an Admin-Panel-style page: - Domains, a table page: domain, customer name and e-mail, billing e-mail, start and end date, and where its data is - its own WeKan container and MongoDB database (connection string, or host, port, database, username, password, authentication database, replica set, TLS; no password is fine), or shared with this WeKan as an Organization claiming the domain. Passwords are written on the server and never sent back. - Import into this WeKan: a domain's own WeKan database merged into this one - its boards and all hanging off them, accounts matched by e-mail address or created (never administrators, no login tokens), everybody in the domain's Organization - and the domain then shares this WeKan. A dry run first. Ten containers and ten databases become one of each. - Invoices of the hosting, recorded by the SuperAdmin, earlier ones too; each customer sees their own, paid or not and when. - Chat per domain between its customer and the SuperAdmin, with earlier Rocket.Chat and SandChat conversations imported. - CloudFlare: the DNS records of every domain, created and updated; a record of another kind is reported, never replaced. - Caddy: the Caddyfile of every domain, loaded through its admin API. The panel answers only at its own domain, checked on the server by every method. A shared domain's Organization claims its host only after the same refusals as an Organization admin's: never the instance's own address, never another Organization's (TenantBleed). Requests go only to CloudFlare's API and the Caddy admin API an administrator set, without redirects (SyncBleed). 44 new strings are translated in every language. Lower-confidence translations: chr, ay, ak, bm, ee, bi, ace, bo, dz, bua, cv, ba, csb, bho, an, co, ff, fj, gn, gv, haw, iu, kl, kw, ks, kok, ig, ha, fur, hsb, ht, la, lg, lld, mg, mi, nah, nap, nd, nso, ny, om, pap, qu, rm, rn, rup, rw, sah, sc, scn, se, sm, sn, so, ss, tlh, vo, wal, ve-PP, wa, wa-RR, szl, zgh, tig, ve, ts, tn, st, wo, to, tpi, yi, uz-AR, wuu-Hans, yue_CN, ve-CC and vl-SS. Thanks to xet7 !
468 lines
19 KiB
JavaScript
468 lines
19 KiB
JavaScript
// Cloud Panel page (docs/Features/Admin-Panel/Cloud-Panel.md). Everything is
|
|
// read and written through the cloudPanel* methods of server/cloudPanel.js,
|
|
// which also decide who may see what; nothing is subscribed.
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { Template } from 'meteor/templating';
|
|
import { ReactiveVar } from 'meteor/reactive-var';
|
|
import { TAPi18n } from '/imports/i18n';
|
|
import { leftMenuData, paneTitle } from '/models/lib/leftMenu';
|
|
import { buildHeader, pageInfo, TABLE_PAGE_ROWS_PER_PAGE } from '/models/lib/tablePage';
|
|
const { formatMoney } = require('/models/lib/billing');
|
|
|
|
function errorText(error) {
|
|
return error ? (error.reason || error.message || String(error)) : '';
|
|
}
|
|
|
|
function language() {
|
|
try { return TAPi18n.getLanguage ? TAPi18n.getLanguage() : undefined; } catch (e) { return undefined; }
|
|
}
|
|
|
|
function field(form, name) {
|
|
const el = form.elements[name];
|
|
return el ? String(el.value).trim() : '';
|
|
}
|
|
|
|
function list(value) {
|
|
return String(value || '').split(/[\s,;]+/).map(s => s.trim()).filter(Boolean);
|
|
}
|
|
|
|
// Each pane's call goes through `done`, which shows its error above the pane.
|
|
function parentDone() {
|
|
const { done } = Template.currentData() || {};
|
|
return typeof done === 'function' ? done : promise => promise;
|
|
}
|
|
|
|
// ---------------------------------------------------------------- the page
|
|
|
|
const ADMIN_MENU = [
|
|
{ id: 'domains', icon: 'fa-globe', labelKey: 'domains' },
|
|
{ id: 'invoices', icon: 'fa-file-text-o', labelKey: 'billing-invoices' },
|
|
{ id: 'chat', icon: 'fa-comments', labelKey: 'board-view-chat' },
|
|
{ id: 'cloudflare', icon: 'fa-cloud', label: 'Cloudflare' },
|
|
{ id: 'caddy', icon: 'fa-server', label: 'Caddy' },
|
|
];
|
|
const CUSTOMER_MENU = ADMIN_MENU.filter(item => ['invoices', 'chat'].includes(item.id));
|
|
|
|
Template.cloudPanel.onCreated(function () {
|
|
this.loading = new ReactiveVar(true);
|
|
this.info = new ReactiveVar({ onCloudHost: false, isCloudAdmin: false, domains: [] });
|
|
this.config = new ReactiveVar(null);
|
|
this.pane = new ReactiveVar('');
|
|
this.actionError = new ReactiveVar('');
|
|
this.loadConfig = () => Meteor.callAsync('cloudPanelConfig').then(config => this.config.set(config));
|
|
this.done = promise => promise.then(result => { this.actionError.set(''); return result; })
|
|
.catch(error => { this.actionError.set(errorText(error)); });
|
|
Meteor.callAsync('cloudPanelWhoAmI')
|
|
.then(info => {
|
|
this.info.set(info);
|
|
this.pane.set(info.isCloudAdmin ? 'domains' : 'invoices');
|
|
return info.isCloudAdmin ? this.loadConfig() : null;
|
|
})
|
|
.catch(error => this.actionError.set(errorText(error)))
|
|
.finally(() => this.loading.set(false));
|
|
});
|
|
|
|
function menu(info) {
|
|
return info.isCloudAdmin ? ADMIN_MENU : CUSTOMER_MENU;
|
|
}
|
|
|
|
Template.cloudPanel.helpers({
|
|
loading: () => Template.instance().loading.get(),
|
|
info: () => Template.instance().info.get(),
|
|
config: () => Template.instance().config.get(),
|
|
pane: () => Template.instance().pane.get(),
|
|
actionError: () => Template.instance().actionError.get(),
|
|
// Not at the Cloud Panel Domain, or neither the SuperAdmin nor a customer.
|
|
notAllowed() {
|
|
const info = Template.instance().info.get();
|
|
return !info.onCloudHost || !(info.isCloudAdmin || info.domains.length > 0);
|
|
},
|
|
menuItems() {
|
|
const tpl = Template.instance();
|
|
return leftMenuData(menu(tpl.info.get()), tpl.pane.get(), 'js-cloud-menu');
|
|
},
|
|
paneTitleData() {
|
|
const tpl = Template.instance();
|
|
return paneTitle(menu(tpl.info.get()), tpl.pane.get());
|
|
},
|
|
reload() {
|
|
const tpl = Template.instance();
|
|
return () => tpl.loadConfig();
|
|
},
|
|
done() {
|
|
const tpl = Template.instance();
|
|
return promise => tpl.done(promise);
|
|
},
|
|
});
|
|
|
|
Template.cloudPanel.events({
|
|
'click a.js-cloud-menu'(event, tpl) {
|
|
event.preventDefault();
|
|
tpl.actionError.set('');
|
|
tpl.pane.set(event.currentTarget.getAttribute('data-id'));
|
|
},
|
|
});
|
|
|
|
// ---------------------------------------------------------------- Cloudflare
|
|
|
|
Template.cloudPanelCloudflare.onCreated(function () {
|
|
this.plan = new ReactiveVar(null);
|
|
});
|
|
|
|
Template.cloudPanelCloudflare.helpers({
|
|
plan: () => Template.instance().plan.get(),
|
|
});
|
|
|
|
Template.cloudPanelCloudflare.events({
|
|
'submit .js-cloud-cloudflare'(event) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
const { reload } = Template.currentData();
|
|
parentDone()(Meteor.callAsync('cloudPanelSetCloudflare', {
|
|
apiToken: field(form, 'apiToken'), zoneId: field(form, 'zoneId'), target: field(form, 'target'),
|
|
proxied: form.elements.proxied.checked === true,
|
|
}).then(() => { form.elements.apiToken.value = ''; return reload(); }));
|
|
},
|
|
'click .js-cloud-dns-plan'(event, tpl) {
|
|
event.preventDefault();
|
|
parentDone()(Meteor.callAsync('cloudPanelDnsPlan').then(plan => tpl.plan.set(plan)));
|
|
},
|
|
'click .js-cloud-dns-apply'(event, tpl) {
|
|
event.preventDefault();
|
|
parentDone()(Meteor.callAsync('cloudPanelDnsApply').then(() => Meteor.callAsync('cloudPanelDnsPlan')).then(plan => tpl.plan.set(plan)));
|
|
},
|
|
});
|
|
|
|
// ---------------------------------------------------------------- Caddy
|
|
|
|
Template.cloudPanelCaddy.onCreated(function () {
|
|
this.caddyfile = new ReactiveVar('');
|
|
this.pushed = new ReactiveVar(false);
|
|
});
|
|
|
|
Template.cloudPanelCaddy.helpers({
|
|
caddyfile: () => Template.instance().caddyfile.get(),
|
|
pushed: () => Template.instance().pushed.get(),
|
|
});
|
|
|
|
Template.cloudPanelCaddy.events({
|
|
'submit .js-cloud-caddy'(event) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
const { reload } = Template.currentData();
|
|
parentDone()(Meteor.callAsync('cloudPanelSetCaddy', {
|
|
adminUrl: field(form, 'adminUrl'), sharedUpstream: field(form, 'sharedUpstream'), email: field(form, 'email'),
|
|
}).then(() => reload()));
|
|
},
|
|
'click .js-cloud-caddyfile'(event, tpl) {
|
|
event.preventDefault();
|
|
parentDone()(Meteor.callAsync('cloudPanelCaddyfile').then(text => tpl.caddyfile.set(text)));
|
|
},
|
|
'click .js-cloud-caddy-push'(event, tpl) {
|
|
event.preventDefault();
|
|
tpl.pushed.set(false);
|
|
parentDone()(Meteor.callAsync('cloudPanelPushCaddy').then(() => tpl.pushed.set(true)));
|
|
},
|
|
});
|
|
|
|
// ---------------------------------------------------------------- Domains
|
|
|
|
// Weddy's Domains columns (caddy-wekan-plugin), and what WeKan adds: where
|
|
// the domain's data is.
|
|
const DOMAIN_COLUMNS = [
|
|
{ labelKey: 'domain', headerTemplate: 'cloudPanelDomainNew' },
|
|
{ labelKey: 'cloud-customer-name' },
|
|
{ labelKey: 'cloud-customer-email' },
|
|
{ labelKey: 'cloud-start-date' },
|
|
{ labelKey: 'cloud-end-date' },
|
|
{ labelKey: 'cloud-panel-mode' },
|
|
{ labelKey: 'cloud-panel-database' },
|
|
{ label: '' },
|
|
];
|
|
|
|
Template.cloudPanelDomains.onCreated(function () {
|
|
this.searchTerm = new ReactiveVar('');
|
|
this.page = new ReactiveVar(1);
|
|
this.total = new ReactiveVar(0);
|
|
this.rows = new ReactiveVar([]);
|
|
this.editing = new ReactiveVar(null);
|
|
this.report = new ReactiveVar(null);
|
|
this.loadPage = () => Meteor.callAsync('cloudPanelDomainsPage', { search: this.searchTerm.get(), page: this.page.get() })
|
|
.then(rows => this.rows.set(rows));
|
|
// The total only when the pane opens or the search changes, never per page.
|
|
this.loadAll = () => Meteor.callAsync('cloudPanelDomainsCount', this.searchTerm.get())
|
|
.then(total => { this.total.set(total); return this.loadPage(); });
|
|
this.loadAll();
|
|
});
|
|
|
|
Template.cloudPanelDomains.helpers({
|
|
tablePageData() {
|
|
const tpl = Template.instance();
|
|
const info = pageInfo(tpl.total.get(), tpl.page.get(), TABLE_PAGE_ROWS_PER_PAGE);
|
|
const rows = tpl.rows.get();
|
|
return {
|
|
emptyKey: 'no-items-message',
|
|
searchTerm: tpl.searchTerm.get(),
|
|
header: buildHeader(DOMAIN_COLUMNS),
|
|
rowTemplate: 'cloudPanelDomainRow',
|
|
docs: rows.map(domain => ({ domain })),
|
|
rowCount: rows.length,
|
|
page: info.page,
|
|
totalPages: info.totalPages,
|
|
hasPrev: info.hasPrev,
|
|
hasNext: info.hasNext,
|
|
total: info.total,
|
|
totalLabelKey: 'domains',
|
|
};
|
|
},
|
|
editing: () => Template.instance().editing.get(),
|
|
report: () => Template.instance().report.get(),
|
|
reportCollections() {
|
|
const report = Template.instance().report.get();
|
|
return Object.entries((report && report.collections) || {}).map(([name, c]) => ({ name, ...c }));
|
|
},
|
|
reportIsDryRun: () => !!(Template.instance().report.get() || {}).dryRun,
|
|
reportDomainId: () => (Template.instance().report.get() || {}).domainId,
|
|
close() {
|
|
const tpl = Template.instance();
|
|
return saved => { tpl.editing.set(null); if (saved) tpl.loadAll(); };
|
|
},
|
|
});
|
|
|
|
Template.cloudPanelDomains.events({
|
|
'keydown .js-table-page-search'(event, tpl) {
|
|
if (event.keyCode !== 13 || event.shiftKey) return;
|
|
event.preventDefault();
|
|
tpl.searchTerm.set(event.currentTarget.value || '');
|
|
tpl.page.set(1);
|
|
tpl.loadAll();
|
|
},
|
|
'click .js-table-page-prev'(event, tpl) {
|
|
event.preventDefault();
|
|
if (tpl.page.get() > 1) { tpl.page.set(tpl.page.get() - 1); tpl.loadPage(); }
|
|
},
|
|
'click .js-table-page-next'(event, tpl) {
|
|
event.preventDefault();
|
|
const { totalPages } = pageInfo(tpl.total.get(), tpl.page.get(), TABLE_PAGE_ROWS_PER_PAGE);
|
|
if (tpl.page.get() < totalPages) { tpl.page.set(tpl.page.get() + 1); tpl.loadPage(); }
|
|
},
|
|
'click .js-cloud-domain-new'(event, tpl) {
|
|
event.preventDefault();
|
|
tpl.editing.set({ mode: 'own', database: {}, customerUsernames: [], cloudflare: true });
|
|
},
|
|
'click .js-cloud-domain-edit'(event, tpl) {
|
|
event.preventDefault();
|
|
parentDone()(Meteor.callAsync('cloudPanelDomain', event.currentTarget.getAttribute('data-id'))
|
|
.then(domain => tpl.editing.set({ ...domain, database: domain.database || {} })));
|
|
},
|
|
'click .js-cloud-domain-import'(event, tpl) {
|
|
event.preventDefault();
|
|
const domainId = event.currentTarget.getAttribute('data-id');
|
|
// A dry run first: what would be copied, and nothing written.
|
|
parentDone()(Meteor.callAsync('cloudPanelImportDomain', domainId, { dryRun: true })
|
|
.then(report => tpl.report.set({ ...report, dryRun: true, domainId })));
|
|
},
|
|
'click .js-cloud-import-now'(event, tpl) {
|
|
event.preventDefault();
|
|
const domainId = event.currentTarget.getAttribute('data-id');
|
|
parentDone()(Meteor.callAsync('cloudPanelImportDomain', domainId, { dryRun: false })
|
|
.then(report => { tpl.report.set({ ...report, dryRun: false, domainId }); return tpl.loadAll(); }));
|
|
},
|
|
});
|
|
|
|
Template.cloudPanelDomainRow.onCreated(function () {
|
|
this.tested = new ReactiveVar('');
|
|
});
|
|
|
|
Template.cloudPanelDomainRow.helpers({
|
|
tested: () => Template.instance().tested.get(),
|
|
databaseLabel(db) {
|
|
if (!db) return '—';
|
|
if (db.uri) return db.uri;
|
|
return `${db.username ? `${db.username}@` : ''}${db.host}:${db.port}/${db.database}`;
|
|
},
|
|
});
|
|
|
|
Template.cloudPanelDomainRow.events({
|
|
'click .js-cloud-domain-test'(event, tpl) {
|
|
event.preventDefault();
|
|
tpl.tested.set('…');
|
|
Meteor.callAsync('cloudPanelTestDatabase', event.currentTarget.getAttribute('data-id'))
|
|
.then(r => tpl.tested.set(TAPi18n.__('cloud-panel-test-ok', { users: r.users, boards: r.boards, cards: r.cards })))
|
|
.catch(error => tpl.tested.set(errorText(error)));
|
|
},
|
|
});
|
|
|
|
Template.cloudPanelDomainForm.helpers({
|
|
customers: () => (Template.currentData().domain.customerUsernames || []).join(', '),
|
|
cloudflareOn: () => Template.currentData().domain.cloudflare !== false,
|
|
});
|
|
|
|
Template.cloudPanelDomainForm.events({
|
|
'submit .js-cloud-domain'(event) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
const { domain, close } = Template.currentData();
|
|
const database = {};
|
|
if (field(form, 'uri')) database.uri = field(form, 'uri');
|
|
else if (field(form, 'host')) {
|
|
database.host = field(form, 'host');
|
|
if (field(form, 'port')) database.port = parseInt(field(form, 'port'), 10);
|
|
database.database = field(form, 'database');
|
|
for (const name of ['username', 'authSource', 'replicaSet']) if (field(form, name)) database[name] = field(form, name);
|
|
if (form.elements.password.value) database.password = form.elements.password.value;
|
|
if (form.elements.tls.checked) database.tls = true;
|
|
}
|
|
const value = {
|
|
domain: field(form, 'domain'), customerName: field(form, 'customerName'), mode: field(form, 'mode'),
|
|
customerEmail: field(form, 'customerEmail'), billingEmail: field(form, 'billingEmail'),
|
|
startDate: field(form, 'startDate'), endDate: field(form, 'endDate'),
|
|
upstream: field(form, 'upstream'), customerUsernames: list(field(form, 'customerUsernames')),
|
|
notes: field(form, 'notes'), cloudflare: form.elements.cloudflare.checked === true,
|
|
};
|
|
if (Object.keys(database).length) value.database = database;
|
|
parentDone()(Meteor.callAsync('cloudPanelSaveDomain', domain._id || null, value).then(() => close(true)));
|
|
},
|
|
'click .js-cloud-domain-close'(event) {
|
|
event.preventDefault();
|
|
Template.currentData().close(false);
|
|
},
|
|
'click .js-cloud-domain-remove'(event) {
|
|
event.preventDefault();
|
|
const { close } = Template.currentData();
|
|
parentDone()(Meteor.callAsync('cloudPanelRemoveDomain', event.currentTarget.getAttribute('data-id')).then(() => close(true)));
|
|
},
|
|
});
|
|
|
|
// ---------------------------------------------------------------- Invoices
|
|
|
|
const INVOICE_STATE_KEYS = { open: 'cloud-panel-invoice-open', paid: 'billing-status-paid', void: 'billing-status-void' };
|
|
|
|
Template.cloudPanelInvoices.onCreated(function () {
|
|
this.invoices = new ReactiveVar([]);
|
|
this.allDomains = new ReactiveVar([]);
|
|
this.load = () => Meteor.callAsync('cloudPanelInvoices').then(invoices => this.invoices.set(invoices));
|
|
this.load();
|
|
if (Template.currentData().isCloudAdmin) {
|
|
Meteor.callAsync('cloudPanelDomainsCount', '')
|
|
.then(total => Promise.all(Array.from({ length: Math.ceil(total / TABLE_PAGE_ROWS_PER_PAGE) }, (_, i) =>
|
|
Meteor.callAsync('cloudPanelDomainsPage', { page: i + 1 }))))
|
|
.then(pages => this.allDomains.set(pages.flat()));
|
|
}
|
|
});
|
|
|
|
Template.cloudPanelInvoices.helpers({
|
|
invoices: () => Template.instance().invoices.get(),
|
|
allDomains: () => Template.instance().allDomains.get(),
|
|
money: (minor, currency) => formatMoney(minor, currency, language()),
|
|
statusLabel: status => TAPi18n.__(INVOICE_STATE_KEYS[status] || status),
|
|
});
|
|
|
|
Template.cloudPanelInvoices.events({
|
|
'submit .js-cloud-invoice'(event, tpl) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
const value = { number: field(form, 'number'), issueDate: field(form, 'issueDate'), amount: parseFloat(field(form, 'amount')),
|
|
currency: field(form, 'currency'), status: field(form, 'status') };
|
|
for (const name of ['dueDate', 'paidDate', 'description', 'link']) if (field(form, name)) value[name] = field(form, name);
|
|
parentDone()(Meteor.callAsync('cloudPanelSaveInvoice', field(form, 'domainId'), null, value).then(() => { form.reset(); return tpl.load(); }));
|
|
},
|
|
'click .js-cloud-invoice-remove'(event, tpl) {
|
|
event.preventDefault();
|
|
parentDone()(Meteor.callAsync('cloudPanelRemoveInvoice', event.currentTarget.getAttribute('data-id')).then(() => tpl.load()));
|
|
},
|
|
});
|
|
|
|
// ---------------------------------------------------------------- Chat
|
|
|
|
Template.cloudPanelChat.onCreated(function () {
|
|
this.domains = new ReactiveVar(Template.currentData().domains || []);
|
|
this.domainId = new ReactiveVar((this.domains.get()[0] || {})._id || '');
|
|
this.messages = new ReactiveVar([]);
|
|
this.imported = new ReactiveVar(0);
|
|
this.load = () => {
|
|
const id = this.domainId.get();
|
|
if (!id) return Promise.resolve();
|
|
return Meteor.callAsync('cloudPanelChat', id).then(messages => this.messages.set(messages));
|
|
};
|
|
if (Template.currentData().isCloudAdmin) {
|
|
Meteor.callAsync('cloudPanelDomainsCount', '')
|
|
.then(total => Promise.all(Array.from({ length: Math.ceil(total / TABLE_PAGE_ROWS_PER_PAGE) }, (_, i) =>
|
|
Meteor.callAsync('cloudPanelDomainsPage', { page: i + 1 }))))
|
|
.then(pages => {
|
|
this.domains.set(pages.flat());
|
|
if (!this.domainId.get() && pages.flat()[0]) this.domainId.set(pages.flat()[0]._id);
|
|
return this.load();
|
|
});
|
|
} else {
|
|
this.load();
|
|
}
|
|
// The chat is read again every 15 seconds while the pane is open.
|
|
this.poll = Meteor.setInterval(() => this.load(), 15000);
|
|
});
|
|
|
|
Template.cloudPanelChat.onDestroyed(function () {
|
|
Meteor.clearInterval(this.poll);
|
|
});
|
|
|
|
Template.cloudPanelChat.helpers({
|
|
chatDomains: () => Template.instance().domains.get(),
|
|
domainId: () => Template.instance().domainId.get(),
|
|
messages: () => Template.instance().messages.get(),
|
|
imported: () => Template.instance().imported.get(),
|
|
when: at => (at ? new Date(at).toLocaleString(language()) : ''),
|
|
});
|
|
|
|
Template.cloudPanelChat.events({
|
|
'change .js-cloud-chat-domain'(event, tpl) {
|
|
tpl.domainId.set(event.currentTarget.value);
|
|
tpl.load();
|
|
},
|
|
'submit .js-cloud-chat-send'(event, tpl) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
parentDone()(Meteor.callAsync('cloudPanelSendChat', tpl.domainId.get(), { text: form.elements.text.value })
|
|
.then(() => { form.reset(); return tpl.load(); }));
|
|
},
|
|
'submit .js-cloud-chat-import'(event, tpl) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
const file = form.elements.file.files[0];
|
|
if (!file) return;
|
|
const reader = new FileReader();
|
|
reader.onload = () => {
|
|
const zipBase64 = String(reader.result).split(',')[1] || '';
|
|
parentDone()(Meteor.callAsync('cloudPanelImportChat', tpl.domainId.get(), field(form, 'source'), { zipBase64 })
|
|
.then(result => { tpl.imported.set(result.imported); form.reset(); return tpl.load(); }));
|
|
};
|
|
reader.readAsDataURL(file);
|
|
},
|
|
});
|
|
|
|
// ---------------------------------------------------------------- Admin Panel
|
|
|
|
// Admin Panel / People / Cloud: the Cloud Panel Domain and its SuperAdmin.
|
|
Template.cloudPanelSettings.onCreated(function () {
|
|
this.settings = new ReactiveVar({ domain: '', superAdminUsername: '' });
|
|
this.saved = new ReactiveVar(false);
|
|
this.error = new ReactiveVar('');
|
|
Meteor.callAsync('cloudPanelGetSettings').then(s => this.settings.set(s)).catch(e => this.error.set(errorText(e)));
|
|
});
|
|
|
|
Template.cloudPanelSettings.helpers({
|
|
settings: () => Template.instance().settings.get(),
|
|
saved: () => Template.instance().saved.get(),
|
|
error: () => Template.instance().error.get(),
|
|
});
|
|
|
|
Template.cloudPanelSettings.events({
|
|
'submit .js-cloud-panel-settings'(event, tpl) {
|
|
event.preventDefault();
|
|
const form = event.currentTarget;
|
|
tpl.saved.set(false);
|
|
Meteor.callAsync('cloudPanelSetSettings', { domain: field(form, 'domain'), superAdminUsername: field(form, 'superAdminUsername') })
|
|
.then(s => { tpl.settings.set(s); tpl.saved.set(true); tpl.error.set(''); })
|
|
.catch(e => tpl.error.set(errorText(e)));
|
|
},
|
|
});
|