Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Webportal: add pai-version attribute to <pai-plugin>
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhut committed Mar 1, 2019
1 parent 4294699 commit f93f882
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/webportal/src/app/env.js.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ window.ENV = {
promScrapeTime: '${PROM_SCRAPE_TIME}'
};

window.PAI_VERSION = function (src) {
var match = src.match(/(?:\?|&)version=(.+)(?:&|$)/) || [];
var version = match[1] || '';
return decodeURIComponent(version);
}(document.currentScript.src);

window.PAI_PLUGINS = [${WEBPORTAL_PLUGINS}][0] || [];
2 changes: 1 addition & 1 deletion src/webportal/src/app/layout/layout.component.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@
<div class="control-sidebar-bg"></div>

</div>
<script src="/scripts/env.js"></script>
<script src="/scripts/env.js?version=<%=encodeURIComponent(htmlWebpackPlugin.options.version)%>"></script>
</body>
</html>
3 changes: 2 additions & 1 deletion src/webportal/src/app/plugin/plugin.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ $(document).ready(function() {

loadScript(plugin.uri, function() {
const $plugin = $('<pai-plugin>')
.attr('pai-rest-server-uri', window.ENV.restServerUri);
.attr('pai-rest-server-uri', window.ENV.restServerUri)
.attr('pai-version', window.PAI_VERSION);
if (cookies.get('token')) {
$plugin.attr('pai-user', cookies.get('user'))
.attr('pai-rest-server-token', cookies.get('token'));
Expand Down

0 comments on commit f93f882

Please sign in to comment.