Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions frontend/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,21 @@ Promise.all([plugins.dbConnection(countlyConfig), plugins.dbConnection("countly_
isLocked: isLocked,
};

if (IS_FLEX) {
// Set flexDeploymentId from /opt/deployment_env.json if available
try {
const deploymentFile = path.resolve("/opt/deployment_env.json");
if (fs.existsSync(deploymentFile)) {
const deploymentConf = fs.readFileSync(deploymentFile, "utf8");
const CONF = JSON.parse(deploymentConf);
if (CONF && CONF.DEPLOYMENT_ID) {
countlyGlobal.flexDeploymentId = CONF.DEPLOYMENT_ID;
}
}
} catch (e) {
// ignore fs/JSON errors
}
}

var toDashboard = {
countlyTitle: req.countly.title,
Expand Down
31 changes: 30 additions & 1 deletion frontend/express/public/javascripts/countly/vue/components/sidebar.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,13 @@
noSelect: true,
tooltip: "Report Manager"
}
]
],
flexWidget: {
status: 'loading',
used: 0,
available: 0,
nextResetAt: ''
}
};
},
computed: {
Expand Down Expand Up @@ -745,9 +751,21 @@
},
isCommunityEdition: function() {
return countlyGlobal.countlyTypeCE;
},
isFlex: function() {
return typeof countlyGlobal.flexDeploymentId !== "undefined";
},
mauPercentage: function() {
if (this.flexWidget.available && this.flexWidget.used) {
return this.flexWidget.used / this.flexWidget.available * 100;
}
return 0;
}
},
methods: {
openFlexManageModal: function() {
window.dispatchEvent(new CustomEvent('open-flex-manage-modal'));
},
guidesMouseOver: function() {
var state = this.$store.getters["countlySidebar/getGuidesButton"];
if (state !== 'selected' && state !== 'highlighted') {
Expand Down Expand Up @@ -1005,6 +1023,17 @@
});
});
}, 0);

window.addEventListener('flex-server-info-updated', () => {
this.flexWidget.status = 'loaded';
this.flexWidget.used = countlyGlobal.mau.used.value;
this.flexWidget.available = countlyGlobal.mau.available.value;
this.flexWidget.nextResetAt = countlyGlobal.mau.term.endsAt;
});

window.addEventListener('flex-server-info-failed', () => {
this.flexWidget.status = 'failed';
});
},
created: function() {
var self = this;
Expand Down
22 changes: 22 additions & 0 deletions frontend/express/public/javascripts/countly/vue/templates/sidebar/sidebar.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@
<el-button class="button" type="success" @click="handleButtonClick">{{i18n('sidebar.banner.upgrade-button')}}</el-button>
</div>
</div>
<div v-else-if="isFlex" class="cly-vue-sidebar__version">
<div v-if="flexWidget.status === 'loaded'" class="cly-vue-sidebar__flex-widget">
<div class="cly-vue-sidebar__flex-widget__header">
<div class="cly-vue-sidebar__flex-widget__header--left">
{{ flexWidget.used.toLocaleString() }}/{{ flexWidget.available.toLocaleString() }} MAU
</div>
<div class="cly-vue-sidebar__flex-widget__header--right" v-if="member.global_admin" @click="openFlexManageModal">
<a href="javascript:void(0)">Manage</a>
</div>
</div>
<div class="cly-vue-sidebar__flex-widget__body__progress-wrapper">
<div class="cly-vue-sidebar__flex-widget__body__progress-bar" :style="{ width: mauPercentage + '%' }">
</div>
</div>
</div>
<div v-else-if="flexWidget.status === 'loading'" class="cly-vue-sidebar__flex-widget__body__status">
Fetching subscription info...
</div>
<div v-else class="cly-vue-sidebar__flex-widget__body__status">
Failed to fetch subscription info
</div>
</div>
<a v-else :href="countlySidebarVersionPath">
<div class="cly-vue-sidebar__version" data-test-id="sidebar-menu-version">
{{versionInfo}}
Expand Down
39 changes: 39 additions & 0 deletions frontend/express/public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5022,4 +5022,43 @@ x-vue-echarts > div:has(> .graph-tooltip-wrapper), x-vue-echarts > div:has(> .gr
top: 8px;
color: #81868D;
cursor: pointer;
}

.cly-vue-sidebar__flex-widget {
position: absolute;
bottom: 12px;
left: 12px;
right: 12px;
background-color: #383A3F;
padding: 12px;
border-radius: 8px;
display: flex;
flex-direction: column;
gap: 8px;
}

.cly-vue-sidebar__flex-widget__header {
display: flex;
justify-content: space-between;
align-items: center;
}

.cly-vue-sidebar__flex-widget__header--left {
color: white; font-weight: 500; font-size: 12px;
}

.cly-vue-sidebar__flex-widget__header--right {
color: white; font-size: 10px; cursor:pointer;
}

.cly-vue-sidebar__flex-widget__body__progress-wrapper {
background-color: #E2E4E8; height: 6px; border-radius: 40px; width: 100%;
}

.cly-vue-sidebar__flex-widget__body__progress-bar {
background-color: #0166D6; height: 6px; border-radius: 40px;
}

.cly-vue-sidebar__flex-widget__body__status {
position: absolute; bottom: 12px; left: 12px; right: 12px;background-color: #383A3F; padding: 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 8px;
}
Loading