From f93f882b137b4a7bb8d37f148c03a206a6397e12 Mon Sep 17 00:00:00 2001 From: Qixiang Cheng Date: Fri, 1 Mar 2019 14:43:54 +0800 Subject: [PATCH 1/3] Webportal: add pai-version attribute to --- src/webportal/src/app/env.js.template | 6 ++++++ src/webportal/src/app/layout/layout.component.ejs | 2 +- src/webportal/src/app/plugin/plugin.component.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/webportal/src/app/env.js.template b/src/webportal/src/app/env.js.template index 26cbfa55d0..18d8d1e88b 100644 --- a/src/webportal/src/app/env.js.template +++ b/src/webportal/src/app/env.js.template @@ -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] || []; diff --git a/src/webportal/src/app/layout/layout.component.ejs b/src/webportal/src/app/layout/layout.component.ejs index 866173646a..91d2e383cc 100644 --- a/src/webportal/src/app/layout/layout.component.ejs +++ b/src/webportal/src/app/layout/layout.component.ejs @@ -137,6 +137,6 @@
- + diff --git a/src/webportal/src/app/plugin/plugin.component.js b/src/webportal/src/app/plugin/plugin.component.js index 778ea45a80..dbb700097e 100644 --- a/src/webportal/src/app/plugin/plugin.component.js +++ b/src/webportal/src/app/plugin/plugin.component.js @@ -46,7 +46,8 @@ $(document).ready(function() { loadScript(plugin.uri, function() { const $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')); From eb95c9160fcd8b14d9e50fb52461790e9374a4d6 Mon Sep 17 00:00:00 2001 From: Qixiang Cheng Date: Mon, 4 Mar 2019 11:20:04 +0800 Subject: [PATCH 2/3] Use preprocess to apply window.PAI_VERSION --- src/webportal/config/preprocess.js | 5 +++++ src/webportal/src/app/env.js.template | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/webportal/config/preprocess.js b/src/webportal/config/preprocess.js index 06b8be0bbc..d39c772a84 100644 --- a/src/webportal/config/preprocess.js +++ b/src/webportal/config/preprocess.js @@ -19,6 +19,7 @@ // module dependencies const fse = require('fs-extra'); const helpers = require('./helpers'); +const packageInfo = require('../package.json'); // copy docs to app fse.copySync( @@ -28,3 +29,7 @@ fse.copySync( fse.copySync( helpers.root('../../examples/tensorflow/tensorflow.distributed-cifar10.json'), helpers.root('src/app/job/job-submit/job-submit.example.json')); + +fse.appendFileSync( + helpers.root('src/app/env.js.template'), + 'window.PAI_VERSION = ' + JSON.stringify(packageInfo.version) + '\n'); diff --git a/src/webportal/src/app/env.js.template b/src/webportal/src/app/env.js.template index 18d8d1e88b..f3e970d2bd 100644 --- a/src/webportal/src/app/env.js.template +++ b/src/webportal/src/app/env.js.template @@ -8,10 +8,5 @@ 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] || []; +window.PAI_VERSION = "0.8.0" From 73069ab0eef72be828214550aa32071f9e21c2bd Mon Sep 17 00:00:00 2001 From: Qixiang Cheng Date: Mon, 4 Mar 2019 11:25:15 +0800 Subject: [PATCH 3/3] set version in layout.html --- src/webportal/config/preprocess.js | 5 ----- src/webportal/src/app/env.js.template | 1 - src/webportal/src/app/layout/layout.component.ejs | 3 ++- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/webportal/config/preprocess.js b/src/webportal/config/preprocess.js index d39c772a84..06b8be0bbc 100644 --- a/src/webportal/config/preprocess.js +++ b/src/webportal/config/preprocess.js @@ -19,7 +19,6 @@ // module dependencies const fse = require('fs-extra'); const helpers = require('./helpers'); -const packageInfo = require('../package.json'); // copy docs to app fse.copySync( @@ -29,7 +28,3 @@ fse.copySync( fse.copySync( helpers.root('../../examples/tensorflow/tensorflow.distributed-cifar10.json'), helpers.root('src/app/job/job-submit/job-submit.example.json')); - -fse.appendFileSync( - helpers.root('src/app/env.js.template'), - 'window.PAI_VERSION = ' + JSON.stringify(packageInfo.version) + '\n'); diff --git a/src/webportal/src/app/env.js.template b/src/webportal/src/app/env.js.template index f3e970d2bd..26cbfa55d0 100644 --- a/src/webportal/src/app/env.js.template +++ b/src/webportal/src/app/env.js.template @@ -9,4 +9,3 @@ window.ENV = { }; window.PAI_PLUGINS = [${WEBPORTAL_PLUGINS}][0] || []; -window.PAI_VERSION = "0.8.0" diff --git a/src/webportal/src/app/layout/layout.component.ejs b/src/webportal/src/app/layout/layout.component.ejs index 91d2e383cc..cbd3f8e5ea 100644 --- a/src/webportal/src/app/layout/layout.component.ejs +++ b/src/webportal/src/app/layout/layout.component.ejs @@ -137,6 +137,7 @@
- + +