IGNITE-6435 Web Console: Added version to footer. (cherry picked from commit 3c75184)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4e38b792 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4e38b792 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4e38b792 Branch: refs/heads/ignite-2.1.5-p1 Commit: 4e38b792517ff182391b78821937db57353a7388 Parents: 668e29f Author: Dmitriy Shabalin <[email protected]> Authored: Wed Sep 20 19:00:09 2017 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Wed Sep 20 19:01:58 2017 +0700 ---------------------------------------------------------------------- modules/web-console/frontend/app/app.js | 2 + .../app/components/version-picker/index.js | 2 +- .../app/modules/branding/branding.module.js | 4 +- .../app/modules/branding/branding.provider.js | 111 ------------ .../app/modules/branding/branding.service.js | 47 +++++ .../modules/configuration/Version.service.js | 169 ------------------ .../configuration/configuration.module.js | 4 - .../generator/ConfigurationGenerator.js | 2 +- .../configuration/generator/Maven.service.js | 2 +- .../frontend/app/services/Version.service.js | 171 +++++++++++++++++++ .../frontend/app/services/Version.spec.js | 106 ++++++++++++ .../web-console/frontend/app/services/index.js | 23 +++ .../frontend/test/unit/Version.test.js | 106 ------------ 13 files changed, 354 insertions(+), 395 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/app.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js index f072fc5..f2ee8ef 100644 --- a/modules/web-console/frontend/app/app.js +++ b/modules/web-console/frontend/app/app.js @@ -128,6 +128,7 @@ import gridItemSelected from './components/grid-item-selected'; import bsSelectMenu from './components/bs-select-menu'; import protectFromBsSelectRender from './components/protect-from-bs-select-render'; import uiGridHovering from './components/ui-grid-hovering'; +import igniteServices from './services'; // Inject external modules. import IgniteModules from 'IgniteModules/index'; @@ -188,6 +189,7 @@ angular.module('ignite-console', [ webConsoleHeader.name, webConsoleFooter.name, igniteIcon.name, + igniteServices.name, versionPicker.name, userNotifications.name, pageConfigure.name, http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/components/version-picker/index.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/components/version-picker/index.js b/modules/web-console/frontend/app/components/version-picker/index.js index f58753e..04ff903 100644 --- a/modules/web-console/frontend/app/components/version-picker/index.js +++ b/modules/web-console/frontend/app/components/version-picker/index.js @@ -20,6 +20,6 @@ import component from './component'; export default angular .module('ignite-console.version-picker', [ - 'ignite-console.configuration' + 'ignite-console.services' ]) .component('versionPicker', component); http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/branding/branding.module.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/branding/branding.module.js b/modules/web-console/frontend/app/modules/branding/branding.module.js index 9c4a5e5..2313728 100644 --- a/modules/web-console/frontend/app/modules/branding/branding.module.js +++ b/modules/web-console/frontend/app/modules/branding/branding.module.js @@ -17,7 +17,7 @@ import angular from 'angular'; -import IgniteBranding from './branding.provider'; +import IgniteBranding from './branding.service'; import igniteHeaderLogo from './header-logo.directive'; import igniteHeaderTitle from './header-title.directive'; @@ -30,7 +30,7 @@ angular .module('ignite-console.branding', [ 'tf.metatags' ]) -.provider(...IgniteBranding) +.service('IgniteBranding', IgniteBranding) .config(['tfMetaTagsProvider', (tfMetaTagsProvider) => { tfMetaTagsProvider.setDefaults({ title: 'Apache Ignite - Management Tool and Configuration Wizard', http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/branding/branding.provider.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/branding/branding.provider.js b/modules/web-console/frontend/app/modules/branding/branding.provider.js deleted file mode 100644 index 280325e..0000000 --- a/modules/web-console/frontend/app/modules/branding/branding.provider.js +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default ['IgniteBranding', [function() { - let titleSuffix = ' â Apache Ignite Web Console'; - - let headerLogo = '/images/ignite-logo.svg'; - - let headerText = 'Management console for Apache Ignite'; - - let showIgniteLogo = false; - - let footerHtml = [ - '<p>Apache Ignite Web Console</p>', - '<p>© 2017 The Apache Software Foundation.</p>', - '<p>Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are trademarks of The Apache Software Foundation.</p>' - ]; - - let termsState; - - let featuresHtml = [ - '<p>Web Console is an interactive management tool which allows to:</p>', - '<ul>', - ' <li>Create and download cluster configurations</li>', - ' <li>Automatically import domain model from any RDBMS</li>', - ' <li>Connect to cluster and run SQL analytics on it</li>', - '</ul>' - ]; - - /** - * Change title suffix. - * - * @param {String} suffix. - */ - this.titleSuffix = (suffix) => { - titleSuffix = suffix; - }; - - /** - * Change logo in header. - * - * @param {String} url Logo path. - */ - this.headerLogo = (url) => { - headerLogo = url; - - showIgniteLogo = true; - }; - - /** - * Change text in header. - * - * @param {String} text Header text. - */ - this.headerText = (text) => { - headerText = text; - }; - - /** - * Change text in features. - * - * @param {Array.<String>} rows Features text. - */ - this.featuresHtml = (rows) => { - featuresHtml = rows; - }; - - /** - * Change text in footer. - * - * @param {Array.<String>} rows Footer text. - */ - this.footerHtml = (rows) => { - footerHtml = rows; - }; - - /** - * Set terms and conditions stage. - * - * @param {String} state - */ - this.termsState = (state) => { - termsState = state; - }; - - this.$get = [() => { - return { - titleSuffix, - headerLogo, - headerText, - featuresHtml: featuresHtml.join('\n'), - footerHtml: footerHtml.join('\n'), - showIgniteLogo, - termsState - }; - }]; -}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/branding/branding.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/branding/branding.service.js b/modules/web-console/frontend/app/modules/branding/branding.service.js new file mode 100644 index 0000000..46bc358 --- /dev/null +++ b/modules/web-console/frontend/app/modules/branding/branding.service.js @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class { + static $inject = ['IgniteVersion']; + + constructor(Version) { + this.titleSuffix = ' â Apache Ignite Web Console'; + + this.headerLogo = '/images/ignite-logo.svg'; + + this.headerText = 'Management console for Apache Ignite'; + + this.showIgniteLogo = false; + + this.footerHtml = [ + `<p>Apache Ignite Web Console (${Version.webConsole})</p>`, + '<p>© 2017 The Apache Software Foundation.</p>', + '<p>Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are trademarks of The Apache Software Foundation.</p>' + ].join('\n'); + + this.termsState = null; + + this.featuresHtml = [ + '<p>Web Console is an interactive management tool which allows to:</p>', + '<ul>', + ' <li>Create and download cluster configurations</li>', + ' <li>Automatically import domain model from any RDBMS</li>', + ' <li>Connect to cluster and run SQL analytics on it</li>', + '</ul>' + ].join('\n'); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/configuration/Version.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/Version.service.js b/modules/web-console/frontend/app/modules/configuration/Version.service.js deleted file mode 100644 index 210b34a..0000000 --- a/modules/web-console/frontend/app/modules/configuration/Version.service.js +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; - -/** - * Utility service for version parsing and comparing - */ -const VERSION_MATCHER = /(\d+)\.(\d+)\.(\d+)([-.]([^0123456789][^-]+)(-SNAPSHOT)?)?(-(\d+))?(-([\da-f]+))?/i; - -/** - * Tries to parse product version from it's string representation. - * - * @param {String} ver - String representation of version. - * @returns {{major: Number, minor: Number, maintenance: Number, stage: String, revTs: Number, revHash: String}} - Object that contains product version fields. - */ -const parse = (ver) => { - // Development or built from source ZIP. - ver = ver.replace(/(-DEV|-n\/a)$/i, ''); - - const [, major, minor, maintenance, stage, ...chunks] = ver.match(VERSION_MATCHER); - - return { - major: parseInt(major, 10), - minor: parseInt(minor, 10), - maintenance: parseInt(maintenance, 10), - stage: (stage || '').substring(1), - revTs: chunks[2] ? parseInt(chunks[3], 10) : 0, - revHash: chunks[4] ? chunks[5] : null - }; -}; - -const numberComparator = (a, b) => a > b ? 1 : a < b ? -1 : 0; - -/** - * Compare to version. - * @param a {Object} first compared version. - * @param b {Object} second compared version. - * @returns {Number} 1 if a > b, 0 if versions equals, -1 if a < b - */ -const compare = (a, b) => { - let res = numberComparator(a.major, b.major); - - if (res !== 0) - return res; - - res = numberComparator(a.minor, b.minor); - - if (res !== 0) - return res; - - res = numberComparator(a.maintenance, b.maintenance); - - if (res !== 0) - return res; - - return numberComparator(a.stage, b.stage); -}; - -export default class IgniteVersion { - constructor() { - this.supportedVersions = [ - { - label: 'Ignite 2.1', - ignite: '2.1.0' - }, - { - label: 'Ignite 2.0', - ignite: '2.0.0' - }, - { - label: 'Ignite 1.x', - ignite: '1.9.0' - } - ]; - - /** Current product version. */ - let current = _.head(this.supportedVersions); - - try { - const ignite = localStorage.configurationVersion; - - const restored = _.find(this.supportedVersions, {ignite}); - - if (restored) - current = restored; - } - catch (ignored) { - // No-op. - } - - this.currentSbj = new BehaviorSubject(current); - - this.currentSbj.subscribe({ - next: (ver) => { - try { - localStorage.setItem('configurationVersion', ver.ignite); - } - catch (ignored) { - // No-op. - } - } - }); - } - - /** - * @return {String} Current Ignite version. - */ - get current() { - return this.currentSbj.getValue().ignite; - } - - /** - * Check if version in range. - * - * @param {String} target Target version. - * @param {String | Array.<String>} ranges Version ranges to compare with. - * @returns {Boolean} `True` if version is equal or greater than specified range. - */ - since(target, ...ranges) { - const targetVer = parse(target); - - return !!_.find(ranges, (range) => { - if (_.isArray(range)) { - const [after, before] = range; - - return compare(targetVer, parse(after)) >= 0 && - (_.isNil(before) || compare(targetVer, parse(before)) < 0); - } - - return compare(targetVer, parse(range)) >= 0; - }); - } - - /** - * Check whether version before than specified version. - * - * @param {String} target Target version. - * @param {String} ranges Version ranges to compare with. - * @return {Boolean} `True` if version before than specified version. - */ - before(target, ...ranges) { - return !this.since(target, ...ranges); - } - - /** - * Check if current version in specified range. - * - * @param {String|Array.<String>} ranges Version ranges to compare with. - * @returns {Boolean} `True` if configuration version is equal or greater than specified range. - */ - available(...ranges) { - return this.since(this.current, ...ranges); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/configuration/configuration.module.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/configuration.module.js b/modules/web-console/frontend/app/modules/configuration/configuration.module.js index 54c6bf1..a350871 100644 --- a/modules/web-console/frontend/app/modules/configuration/configuration.module.js +++ b/modules/web-console/frontend/app/modules/configuration/configuration.module.js @@ -17,9 +17,6 @@ import angular from 'angular'; - -import IgniteVersion from './Version.service'; - import IgniteClusterDefaults from './generator/defaults/Cluster.service'; import IgniteClusterPlatformDefaults from './generator/defaults/Cluster.platform.service'; import IgniteCacheDefaults from './generator/defaults/Cache.service'; @@ -50,7 +47,6 @@ angular .service('SpringTransformer', () => IgniteSpringTransformer) .service('JavaTransformer', () => IgniteJavaTransformer) .service('IgniteSharpTransformer', SharpTransformer) -.service('IgniteVersion', IgniteVersion) .service('IgniteEventGroups', IgniteEventGroups) .service('IgniteClusterDefaults', IgniteClusterDefaults) .service('IgniteClusterPlatformDefaults', IgniteClusterPlatformDefaults) http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js index 428a8d0..9d7887a 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js @@ -25,7 +25,7 @@ import IgniteCacheDefaults from './defaults/Cache.service'; import IgniteIGFSDefaults from './defaults/IGFS.service'; import JavaTypes from '../../../services/JavaTypes.service'; -import VersionService from 'app/modules/configuration/Version.service'; +import VersionService from 'app/services/Version.service'; const clusterDflts = new IgniteClusterDefaults(); const cacheDflts = new IgniteCacheDefaults(); http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js b/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js index 9bf0a34..a145f2e 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js @@ -16,7 +16,7 @@ */ import StringBuilder from './StringBuilder'; -import VersionService from 'app/modules/configuration/Version.service'; +import VersionService from 'app/services/Version.service'; const versionService = new VersionService(); http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/services/Version.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/services/Version.service.js b/modules/web-console/frontend/app/services/Version.service.js new file mode 100644 index 0000000..8ae23d3 --- /dev/null +++ b/modules/web-console/frontend/app/services/Version.service.js @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; + +/** + * Utility service for version parsing and comparing + */ +const VERSION_MATCHER = /(\d+)\.(\d+)\.(\d+)([-.]([^0123456789][^-]+)(-SNAPSHOT)?)?(-(\d+))?(-([\da-f]+))?/i; + +/** + * Tries to parse product version from it's string representation. + * + * @param {String} ver - String representation of version. + * @returns {{major: Number, minor: Number, maintenance: Number, stage: String, revTs: Number, revHash: String}} - Object that contains product version fields. + */ +const parse = (ver) => { + // Development or built from source ZIP. + ver = ver.replace(/(-DEV|-n\/a)$/i, ''); + + const [, major, minor, maintenance, stage, ...chunks] = ver.match(VERSION_MATCHER); + + return { + major: parseInt(major, 10), + minor: parseInt(minor, 10), + maintenance: parseInt(maintenance, 10), + stage: (stage || '').substring(1), + revTs: chunks[2] ? parseInt(chunks[3], 10) : 0, + revHash: chunks[4] ? chunks[5] : null + }; +}; + +const numberComparator = (a, b) => a > b ? 1 : a < b ? -1 : 0; + +/** + * Compare to version. + * @param a {Object} first compared version. + * @param b {Object} second compared version. + * @returns {Number} 1 if a > b, 0 if versions equals, -1 if a < b + */ +const compare = (a, b) => { + let res = numberComparator(a.major, b.major); + + if (res !== 0) + return res; + + res = numberComparator(a.minor, b.minor); + + if (res !== 0) + return res; + + res = numberComparator(a.maintenance, b.maintenance); + + if (res !== 0) + return res; + + return numberComparator(a.stage, b.stage); +}; + +export default class IgniteVersion { + constructor() { + this.webConsole = '2.1.0'; + + this.supportedVersions = [ + { + label: 'Ignite 2.1', + ignite: '2.1.0' + }, + { + label: 'Ignite 2.0', + ignite: '2.0.0' + }, + { + label: 'Ignite 1.x', + ignite: '1.9.0' + } + ]; + + /** Current product version. */ + let current = _.head(this.supportedVersions); + + try { + const ignite = localStorage.configurationVersion; + + const restored = _.find(this.supportedVersions, {ignite}); + + if (restored) + current = restored; + } + catch (ignored) { + // No-op. + } + + this.currentSbj = new BehaviorSubject(current); + + this.currentSbj.subscribe({ + next: (ver) => { + try { + localStorage.setItem('configurationVersion', ver.ignite); + } + catch (ignored) { + // No-op. + } + } + }); + } + + /** + * @return {String} Current Ignite version. + */ + get current() { + return this.currentSbj.getValue().ignite; + } + + /** + * Check if version in range. + * + * @param {String} target Target version. + * @param {String | Array.<String>} ranges Version ranges to compare with. + * @returns {Boolean} `True` if version is equal or greater than specified range. + */ + since(target, ...ranges) { + const targetVer = parse(target); + + return !!_.find(ranges, (range) => { + if (_.isArray(range)) { + const [after, before] = range; + + return compare(targetVer, parse(after)) >= 0 && + (_.isNil(before) || compare(targetVer, parse(before)) < 0); + } + + return compare(targetVer, parse(range)) >= 0; + }); + } + + /** + * Check whether version before than specified version. + * + * @param {String} target Target version. + * @param {String} ranges Version ranges to compare with. + * @return {Boolean} `True` if version before than specified version. + */ + before(target, ...ranges) { + return !this.since(target, ...ranges); + } + + /** + * Check if current version in specified range. + * + * @param {String|Array.<String>} ranges Version ranges to compare with. + * @returns {Boolean} `True` if configuration version is equal or greater than specified range. + */ + available(...ranges) { + return this.since(this.current, ...ranges); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/services/Version.spec.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/services/Version.spec.js b/modules/web-console/frontend/app/services/Version.spec.js new file mode 100644 index 0000000..12e769c --- /dev/null +++ b/modules/web-console/frontend/app/services/Version.spec.js @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import VersionService from './Version.service'; + +const INSTANCE = new VersionService(); + +import { suite, test } from 'mocha'; +import { assert } from 'chai'; + +suite('VersionServiceTestsSuite', () => { + test.skip('Parse 1.7.0-SNAPSHOT', () => { + const version = INSTANCE.parse('1.7.0-SNAPSHOT'); + assert.equal(version.major, 1); + assert.equal(version.minor, 7); + assert.equal(version.maintenance, 0); + assert.equal(version.stage, 'SNAPSHOT'); + assert.equal(version.revTs, 0); + assert.isNull(version.revHash); + }); + + test.skip('Parse strip -DEV 1.7.0-DEV', () => { + const version = INSTANCE.parse('1.7.0-DEV'); + assert.equal(version.major, 1); + assert.equal(version.minor, 7); + assert.equal(version.maintenance, 0); + assert.equal(version.stage, ''); + }); + + test.skip('Parse strip -n/a 1.7.0-n/a', () => { + const version = INSTANCE.parse('1.7.0-n/a'); + assert.equal(version.major, 1); + assert.equal(version.minor, 7); + assert.equal(version.maintenance, 0); + assert.equal(version.stage, ''); + }); + + test.skip('Check patch version', () => { + assert.equal(INSTANCE.compare(INSTANCE.parse('1.7.2'), INSTANCE.parse('1.7.1')), 1); + }); + + test.skip('Check minor version', () => { + assert.equal(INSTANCE.compare(INSTANCE.parse('1.8.1'), INSTANCE.parse('1.7.1')), 1); + }); + + test.skip('Check major version', () => { + assert.equal(INSTANCE.compare(INSTANCE.parse('2.7.1'), INSTANCE.parse('1.7.1')), 1); + }); + + test.skip('Version a > b', () => { + assert.equal(INSTANCE.compare(INSTANCE.parse('1.7.0'), INSTANCE.parse('1.5.0')), 1); + }); + + test.skip('Version a = b', () => { + assert.equal(INSTANCE.compare(INSTANCE.parse('1.0.0'), INSTANCE.parse('1.0.0')), 0); + assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.0'), INSTANCE.parse('1.2.0')), 0); + assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.3'), INSTANCE.parse('1.2.3')), 0); + + assert.equal(INSTANCE.compare(INSTANCE.parse('1.0.0-1'), INSTANCE.parse('1.0.0-1')), 0); + assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.0-1'), INSTANCE.parse('1.2.0-1')), 0); + assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.3-1'), INSTANCE.parse('1.2.3-1')), 0); + }); + + test.skip('Version a < b', () => { + assert.equal(INSTANCE.compare(INSTANCE.parse('1.5.1'), INSTANCE.parse('1.5.2')), -1); + }); + + test('Check since call', () => { + assert.equal(INSTANCE.since('1.5.0', '1.5.0'), true); + assert.equal(INSTANCE.since('1.6.0', '1.5.0'), true); + assert.equal(INSTANCE.since('1.5.4', ['1.5.5', '1.6.0'], ['1.6.2']), false); + assert.equal(INSTANCE.since('1.5.5', ['1.5.5', '1.6.0'], ['1.6.2']), true); + assert.equal(INSTANCE.since('1.5.11', ['1.5.5', '1.6.0'], ['1.6.2']), true); + assert.equal(INSTANCE.since('1.6.0', ['1.5.5', '1.6.0'], ['1.6.2']), false); + assert.equal(INSTANCE.since('1.6.1', ['1.5.5', '1.6.0'], '1.6.2'), false); + assert.equal(INSTANCE.since('1.6.2', ['1.5.5', '1.6.0'], ['1.6.2']), true); + assert.equal(INSTANCE.since('1.6.3', ['1.5.5', '1.6.0'], '1.6.2'), true); + }); + + test('Check wrong since call', () => { + assert.equal(INSTANCE.since('1.3.0', '1.5.0'), false); + }); + + test('Check before call', () => { + assert.equal(INSTANCE.before('1.5.0', '1.5.0'), false); + assert.equal(INSTANCE.before('1.5.0', '1.6.0'), true); + }); + + test('Check wrong before call', () => { + assert.equal(INSTANCE.before('1.5.0', '1.3.0'), false); + }); +}); http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/app/services/index.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/services/index.js b/modules/web-console/frontend/app/services/index.js new file mode 100644 index 0000000..49e7632 --- /dev/null +++ b/modules/web-console/frontend/app/services/index.js @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import angular from 'angular'; +import IgniteVersion from './Version.service'; + +export default angular + .module('ignite-console.services', []) + .service('IgniteVersion', IgniteVersion); http://git-wip-us.apache.org/repos/asf/ignite/blob/4e38b792/modules/web-console/frontend/test/unit/Version.test.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/test/unit/Version.test.js b/modules/web-console/frontend/test/unit/Version.test.js deleted file mode 100644 index b0ca3d9..0000000 --- a/modules/web-console/frontend/test/unit/Version.test.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import VersionService from '../../app/modules/configuration/Version.service'; - -const INSTANCE = new VersionService(); - -import { suite, test } from 'mocha'; -import { assert } from 'chai'; - -suite('VersionServiceTestsSuite', () => { - test.skip('Parse 1.7.0-SNAPSHOT', () => { - const version = INSTANCE.parse('1.7.0-SNAPSHOT'); - assert.equal(version.major, 1); - assert.equal(version.minor, 7); - assert.equal(version.maintenance, 0); - assert.equal(version.stage, 'SNAPSHOT'); - assert.equal(version.revTs, 0); - assert.isNull(version.revHash); - }); - - test.skip('Parse strip -DEV 1.7.0-DEV', () => { - const version = INSTANCE.parse('1.7.0-DEV'); - assert.equal(version.major, 1); - assert.equal(version.minor, 7); - assert.equal(version.maintenance, 0); - assert.equal(version.stage, ''); - }); - - test.skip('Parse strip -n/a 1.7.0-n/a', () => { - const version = INSTANCE.parse('1.7.0-n/a'); - assert.equal(version.major, 1); - assert.equal(version.minor, 7); - assert.equal(version.maintenance, 0); - assert.equal(version.stage, ''); - }); - - test.skip('Check patch version', () => { - assert.equal(INSTANCE.compare(INSTANCE.parse('1.7.2'), INSTANCE.parse('1.7.1')), 1); - }); - - test.skip('Check minor version', () => { - assert.equal(INSTANCE.compare(INSTANCE.parse('1.8.1'), INSTANCE.parse('1.7.1')), 1); - }); - - test.skip('Check major version', () => { - assert.equal(INSTANCE.compare(INSTANCE.parse('2.7.1'), INSTANCE.parse('1.7.1')), 1); - }); - - test.skip('Version a > b', () => { - assert.equal(INSTANCE.compare(INSTANCE.parse('1.7.0'), INSTANCE.parse('1.5.0')), 1); - }); - - test.skip('Version a = b', () => { - assert.equal(INSTANCE.compare(INSTANCE.parse('1.0.0'), INSTANCE.parse('1.0.0')), 0); - assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.0'), INSTANCE.parse('1.2.0')), 0); - assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.3'), INSTANCE.parse('1.2.3')), 0); - - assert.equal(INSTANCE.compare(INSTANCE.parse('1.0.0-1'), INSTANCE.parse('1.0.0-1')), 0); - assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.0-1'), INSTANCE.parse('1.2.0-1')), 0); - assert.equal(INSTANCE.compare(INSTANCE.parse('1.2.3-1'), INSTANCE.parse('1.2.3-1')), 0); - }); - - test.skip('Version a < b', () => { - assert.equal(INSTANCE.compare(INSTANCE.parse('1.5.1'), INSTANCE.parse('1.5.2')), -1); - }); - - test('Check since call', () => { - assert.equal(INSTANCE.since('1.5.0', '1.5.0'), true); - assert.equal(INSTANCE.since('1.6.0', '1.5.0'), true); - assert.equal(INSTANCE.since('1.5.4', ['1.5.5', '1.6.0'], ['1.6.2']), false); - assert.equal(INSTANCE.since('1.5.5', ['1.5.5', '1.6.0'], ['1.6.2']), true); - assert.equal(INSTANCE.since('1.5.11', ['1.5.5', '1.6.0'], ['1.6.2']), true); - assert.equal(INSTANCE.since('1.6.0', ['1.5.5', '1.6.0'], ['1.6.2']), false); - assert.equal(INSTANCE.since('1.6.1', ['1.5.5', '1.6.0'], '1.6.2'), false); - assert.equal(INSTANCE.since('1.6.2', ['1.5.5', '1.6.0'], ['1.6.2']), true); - assert.equal(INSTANCE.since('1.6.3', ['1.5.5', '1.6.0'], '1.6.2'), true); - }); - - test('Check wrong since call', () => { - assert.equal(INSTANCE.since('1.3.0', '1.5.0'), false); - }); - - test('Check before call', () => { - assert.equal(INSTANCE.before('1.5.0', '1.5.0'), false); - assert.equal(INSTANCE.before('1.5.0', '1.6.0'), true); - }); - - test('Check wrong before call', () => { - assert.equal(INSTANCE.before('1.5.0', '1.3.0'), false); - }); -});
